diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c92485b --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +auth.cfg +*.pyc +logs/ diff --git a/README.md b/README.md index 2f9c7d4..de1762a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Allows WhatsApp users on Android to extract their backed up WhatsApp data from G ###### BRANCH UPDATES: v1.0 - Initial release. -v1.1 - Added Python 3 support. +v1.1 - Added Python 3 support. ###### PREREQUISITES: @@ -12,21 +12,24 @@ v1.1 - Added Python 3 support. 3. Android device with WhatsApp installed and the Google Drive backup feature enabled 4. Google services device id (if you want to reduce the risk of being logged out of Google) Search Google Play for "device id" for plenty of apps that can reveal this information - 5. Google account login credentials (username and password) + 5. Google account login credentials (username and password) + 6. Generate an App Password if your Google account has 2-factor-authentication. + App passwords are generated at https://security.google.com/settings/security/apppasswords. ###### INSTRUCTIONS: 1. Extract "WhatsApp-GD-Extractor-master.zip". - 2. Edit the [auth] section in "settings.cfg". - 3. Run python WhatsAppGDExtract.py from your command console. - 4. Read the usage examples that are displayed. - 5. Run any of the examples. + 2. Install dependencies (`pip install -r requirements.txt`) + 3. Copy `auth.cfg.example` to `auth.cfg`. Fill in your Google credentials in the file. + 4. Run python WhatsAppGDExtract.py from your command console. + 5. Read the usage examples that are displayed. + 6. Run any of the examples. ###### TROUBLESHOOTING: 1. Check you have the required imports installed (configparser and requests). - I.E.: pip install configparser requests - + I.E.: `pip install -r requirements.txt` + 2. If you have 2-factor-authentication enabled, make sure you use an App Password instead of your Google passsword. ###### CREDITS: AUTHOR: TripCode diff --git a/WhatsAppGDExtract.py b/WhatsAppGDExtract.py index 808572e..5ad2bee 100755 --- a/WhatsAppGDExtract.py +++ b/WhatsAppGDExtract.py @@ -62,11 +62,13 @@ def gDriveFileMap(): def getConfigs(): global gmail, passw, devid, pkg, sig, client_pkg, client_sig, client_ver config = ConfigParser() + auth = ConfigParser() try: config.read('settings.cfg') - gmail = config.get('auth', 'gmail') - passw = config.get('auth', 'passw') - devid = config.get('auth', 'devid') + auth.read('auth.cfg') + gmail = auth.get('auth', 'gmail') + passw = auth.get('auth', 'passw') + devid = auth.get('auth', 'devid') pkg = config.get('app', 'pkg') sig = config.get('app', 'sig') client_pkg = config.get('client', 'pkg') @@ -74,6 +76,8 @@ def getConfigs(): client_ver = config.get('client', 'ver') except(ConfigParser.NoSectionError, ConfigParser.NoOptionError): quit('The "settings.cfg" file is missing or corrupt!') + if passw == "" or passw is None: + quit('The "auth.cfg" file should contain your gmail password') def jsonPrint(data): print(json.dumps(json.loads(data), indent=4, sort_keys=True)) @@ -96,7 +100,11 @@ def localFileList(): def createSettingsFile(): with open('settings.cfg', 'w') as cfg: - cfg.write('[auth]\ngmail = alias@gmail.com\npassw = yourpassword\ndevid = 0000000000000000\n\n[app]\npkg = com.whatsapp\nsig = 38a0f7d505fe18fec64fbf343ecaaaf310dbd799\n\n[client]\npkg = com.google.android.gms\nsig = 38918a453d07199354f8b19af05ec6562ced5788\nver = 9877000') + cfg.write('[app]\npkg = com.whatsapp\nsig = 38a0f7d505fe18fec64fbf343ecaaaf310dbd799\n\n[client]\npkg = com.google.android.gms\nsig = 38918a453d07199354f8b19af05ec6562ced5788\nver = 9877000') + +def createAuthFile(): + with open('auth.cfg', 'w') as cfg: + cfg.write('[auth]\ngmail = alias@gmail.com\npassw=\ndevid = 0000000000000000\n\n') def getSingleFile(data, asset): data = json.loads(data) @@ -118,8 +126,11 @@ def getMultipleFiles(data, folder): def runMain(mode, asset, bID): global bearer - if os.path.isfile('settings.cfg') == False: + if not os.path.isfile('settings.cfg'): createSettingsFile() + if not os.path.exists('auth.cfg'): + createAuthFile() + quit("Please fill in your Google authentication details in auth.cfg") getConfigs() bearer = getGoogleDriveToken(getGoogleAccountTokenFromAuth()) drives = gDriveFileMap() diff --git a/auth.cfg.example b/auth.cfg.example new file mode 100644 index 0000000..2bebba8 --- /dev/null +++ b/auth.cfg.example @@ -0,0 +1,5 @@ +[auth] +gmail = alias@gmail.com +passw= +devid = 0000000000000000 + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e4c558c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +requests +configparser + diff --git a/settings.cfg b/settings.cfg index 400d974..6f3053a 100644 --- a/settings.cfg +++ b/settings.cfg @@ -1,8 +1,3 @@ -[auth] -gmail = alias@gmail.com -passw = yourpassword -devid = 0000000000000000 - [app] pkg = com.whatsapp sig = 38a0f7d505fe18fec64fbf343ecaaaf310dbd799 @@ -10,4 +5,4 @@ sig = 38a0f7d505fe18fec64fbf343ecaaaf310dbd799 [client] pkg = com.google.android.gms sig = 38918a453d07199354f8b19af05ec6562ced5788 -ver = 9877000 \ No newline at end of file +ver = 9877000