def RealDeal(SDKVersion, WhatsAppapkPath, versionName, sdPath): BackupWhatsAppApk(SDKVersion, versionName, WhatsAppapkPath) UninstallWhatsApp(SDKVersion) # Reboot here. if (isAllowReboot): if (not tcpIP): print('\n') CustomPrint('Rebooting device, please wait.', 'yellow') os.system(adb + ' reboot') while (subprocess.getoutput(adb + ' get-state') != 'device'): CustomPrint('Waiting for device...') time.sleep(5) CustomInput('Hit Enter key after unlocking device.', 'yellow') else: CustomPrint( 'Rebooting device in TCP mode break the connection and won\'t work until explicitly turned on in device and/or in PC. Skipping...', 'yellow') InstallLegacy(SDKVersion) # Before backup run app os.system(adb + ' shell am start -n com.whatsapp/.Main') CustomInput( '\aHit Enter key after running Legacy WhatsApp for a while. Ignore invalid date warning.', 'yellow') BackupWhatsAppDataasAb(SDKVersion) ReinstallWhatsApp() print('\n') CustomPrint( '\aOur work with device has finished, it is safe to remove it now.', 'yellow') print('\n') ExtractAB(isJAVAInstalled, sdPath=sdPath, ADBSerialId=ADBSerialId, isTarOnly=isTarOnly)
def main(): os.system('cls' if os.name == 'nt' else 'clear') CheckBin() ShowBanner() global isJAVAInstalled isJAVAInstalled = CheckJAVA() print('\n') try: CustomPrint('Arguments passed : ' + str(args)) print('\n') except: pass try: CustomPrint('System Info : ' + json.dumps(GetSysInfo(), indent=2, default=str)) print('\n') except: CustomPrint('Can\'t get system information. Continuing anyway...', 'yellow') CustomPrint('Current release date : 29/06/2021', 'cyan') print('\n') readInstruction = CustomInput( '\aPlease read above instructions carefully \u2191 . Continue? (default y) : ', 'yellow') or 'y' if (readInstruction.upper() == 'Y'): print('\n') CustomInput( '\aIf you haven\'t already, it is adviced to take a WhatsApp chat backup by going to WhatsApp settings \u2192 Chat Settings \u2192 Chat Backup. Hit Enter key to continue.', 'yellow') USBMode() else: Exit()
def Uncompress(userZip): if(not str(userZip).endswith('7z')): userZip = userZip + '.7z' if(not os.path.isfile(extracted + userZip)): CustomPrint('Could not find ' + extracted + userZip) elif(os.path.getsize(extracted + userZip) <= 0): CustomPrint(extracted + userZip + ' is empty.') Exit() else: password = CustomInput('Enter password, leave empty for none : ') if(password): password = '******' + password os.system(sevenZip + ' e -aot ' + extracted + userZip + ' -o' + extracted + userZip.replace('.7z', '') + password) print('\n') CustomPrint( 'If you see \'Everything is OK\' in above line then you can delete user zip file.') deleteUserZip = CustomInput( 'Delete ' + userZip + ' ? (default n) : ') or 'n' print('\n') CustomPrint('\aYour extracted \'' + userZip.replace('.7z', '') + '\' folder is in extracted folder.', 'yellow') print('\n') CustomInput('Hit Enter key to continue.') if(deleteUserZip.upper() == 'Y'): DeleteUserZip(userZip) else: Exit()
def main() : os.system('cls' if os.name == 'nt' else 'clear') CheckBinIfWindows() ShowBanner() global isJAVAInstalled isJAVAInstalled = CheckJAVA() # TODO : use -y flag to assume readinstruction read automatically. readInstruction = CustomInput('Please read above instructions carefully. Continue? (default y) : ') or 'y' if(readInstruction.upper() == 'Y') : USBMode() else : Exit()
def TakingOutMainFiles(userName, protectPass): os.mkdir(extracted + userName) if not (os.path.isdir(extracted + userName) ) else CustomPrint('Folder already exists.') CustomPrint('Taking out main files in ' + tmp + ' folder temporaily.') try: bin = '' if (isLinux) else 'bin\\' os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/f/key') os.replace('tmp/apps/com.whatsapp/f/key', extracted + userName + '/key') os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/db/msgstore.db') os.replace('tmp/apps/com.whatsapp/db/msgstore.db', extracted + userName + '/msgstore.db') os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/db/wa.db') os.replace('tmp/apps/com.whatsapp/db/wa.db', extracted + userName + '/wa.db') os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/db/axolotl.db') os.replace('tmp/apps/com.whatsapp/db/axolotl.db', extracted + userName + '/axolotl.db') os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/db/chatsettings.db') os.replace('tmp/apps/com.whatsapp/db/chatsettings.db', extracted + userName + '/chatsettings.db') # TODO : use -y flag to cleantmp automatically. CustomPrint( '\nIf you do not see any errors in above lines in extracting/fluffing whatsapp.ab you SHOULD choose to clean temporary folder. It contains your chats in UN-ENCRYPTED format.', 'yellow') _cleanTemp = CustomInput( 'Would you like to clean tmp folder? (default y) : ') or 'y' if (_cleanTemp.upper() == 'y'.upper()): CleanTmp() if (protectPass): CustomPrint( 'Now an archive will be created in extracted folder with password \'' + protectPass + '\' and original files will be deleted. To later \'un-archive\' and access these files you need to run \'python protect.py\' from root directory of this project.', 'yellow') protect.Compress(userName, protectPass) except Exception as e: CustomPrint(e) CleanTmp()
def Exit(): print('\n') CustomPrint('Exiting...') os.system( 'bin\\adb.exe kill-server') if(isWindows) else os.system('adb kill-server') CustomInput('Hit \'Enter\' key to continue....', 'cyan') quit()
def CheckJAVA(): JAVAVersion = re.search('(?<=version ")(.*)(?=")', str(subprocess.check_output( 'java -version'.split(), stderr=subprocess.STDOUT))).group(1) isJAVAInstalled = True if(JAVAVersion) else False if (isJAVAInstalled): CustomPrint('Found Java installed on system. Continuing...') return isJAVAInstalled else: noJAVAContinue = CustomInput( 'It looks like you don\'t have JAVA installed on your system. Would you like to (C)ontinue with the process and \'view extract\' later? or (S)top? : ', 'red') or 'c' if(noJAVAContinue.upper() == 'C'): CustomPrint( 'Continuing without JAVA, once JAVA is installed on system run \'view_extract.py\'', 'yellow') return isJAVAInstalled else: Exit()
def TakingOutOnlyTar(userName): os.mkdir(extracted) if not (os.path.isdir(extracted)) else CustomPrint( 'Folder ' + extracted + ' already exists.', 'yellow') try: CustomPrint('Moving tmp/whatsapp.tar to ' + extracted + userName + '.tar') os.replace(tmp + 'whatsapp.tar', extracted + userName + '.tar') except Exception as e: CustomPrint('\a' + e, 'red') Exit() CleanTmp() print('\n') CustomPrint('\aYour ' + userName + '.tar is in ' + os.path.realpath(extracted) + ' folder.', 'yellow') print('\n') CustomInput('Hit Enter key to continue.') try: # Open in explorer. if(isWindows): os.startfile(os.path.realpath(extracted)) elif(isLinux): os.system('xdg-open ' + os.path.realpath(extracted)) else: os.system('open ' + os.path.realpath(extracted)) except: Exit()
def Compress(userFolder): if(not os.path.isdir(extracted + userFolder)): CustomPrint('Could not find directory ' + extracted + userFolder) elif(len(os.listdir(extracted + userFolder)) == 0): CustomPrint('User folder is empty.') Exit() else: password = CustomInput('Choose a password for zip : ') if(password): password = '******' + password os.system(sevenZip + ' a -t7z -mhe ' + extracted + userFolder + ' ' + extracted + userFolder + '/* ' + password) print('\n') CustomPrint( 'If you see \'Everything is OK\' in above line then it is recommended to delete user folder.') deleteUserFolder = CustomInput( 'Delete ' + userFolder + ' folder? (default y) : ') or 'y' print('\n') CustomPrint('\aYour \'' + userFolder + '.7z\' file is in extracted folder. Password is : ' + password.replace(' -p', ''), 'yellow') print('\n') CustomInput('Hit Enter key to continue.') if(deleteUserFolder.upper() == 'Y'): DeleteUserFolder(userFolder) else: Exit()
def ExtractAB(isJAVAInstalled, abPass, userName, protectPass, callingFromOtherModule=True): if not (isJAVAInstalled): CustomPrint('Can not detect JAVA on system.') # move whatsapp.ab from tmp to user specified folder. os.mkdir(extracted + userName) if not ( os.path.isdir(extracted + userName)) else CustomPrint('Folder ' + extracted + userName + ' exists.') os.rename(tmp + 'whatsapp.ab', extracted + userName + '/whatsapp.ab') CustomPrint( 'Moved whatsapp.ab to ' + extracted + userName + ' folder. Run view_extract.py after installing Java on system.') Exit() # Ask if already have whatsapp.ab file and continuing the process, if so then check in extracted folder first and continue. if (not callingFromOtherModule): if (CustomInput( 'Have you already made whatsapp.ab and just extracting it now ? : ' ).upper() == 'y'.upper()): if (os.path.isfile(extracted + userName + '/whatsapp.ab')): try: CustomPrint( 'Fluffing whatsapp.ab file, may take some time. Be patient.' ) os.system('java -jar ' + bin + 'abe.jar unpack ' + extracted + userName + '/whatsapp.ab ' + tmp + 'whatsapp.tar ' + str(abPass)) CustomPrint('Successfully \'fluffed\' ' + extracted + userName + '/whatsapp.ab ' + tmp + 'whatsapp.tar ') TakingOutMainFiles(userName, protectPass) except Exception as e: CustomPrint(e) else: CustomPrint('Could not find whatsapp.ab in ' + extracted + userName + ' folder, did you name your user properly?') CustomPrint('May be that \'whatsapp.ab\' file is still in ' + tmp + ' folder. Enter \'n\' next time.') Exit() if (os.path.isfile(tmp + 'whatsapp.ab')): CustomPrint('Found whatsapp.ab in tmp folder. Continuing') try: CustomPrint( 'Fluffing whatsapp.ab file, may take some time. Be patient.') os.system('java -jar ' + bin + 'abe.jar unpack ' + tmp + 'whatsapp.ab ' + tmp + 'whatsapp.tar ' + str(abPass)) CustomPrint('Successfully \'fluffed\' ' + tmp + 'whatsapp.ab to ' + tmp + 'whatsapp.tar ') TakingOutMainFiles(userName, protectPass) except Exception as e: CustomPrint(e)
def Compress(userFolder, protectPass): if (not os.path.isdir(extracted + userFolder)): CustomPrint('Could not find directory ' + extracted + userFolder) elif (len(os.listdir(extracted + userFolder)) == 0): CustomPrint('User folder is empty.') Exit() else: protectPass = '******' + protectPass os.system(sevenZip + ' a -t7z -mhe ' + extracted + userFolder + ' ' + extracted + userFolder + '/* ' + protectPass) CustomPrint( '\nIf you see \'Everything is OK\' in above line then it is recommended to delete user folder.' ) deleteUserFolder = CustomInput('Delete ' + userFolder + ' folder? (default y) : ') or 'y' # TODO : use -y flag to deleteuserfolder automatically. if (deleteUserFolder.upper() == 'Y'): DeleteUserFolder(userFolder) else: Exit()
def Decompress(userZip, protectPass): if (not str(userZip).endswith('7z')): userZip = userZip + '.7z' if (not os.path.isfile(extracted + userZip)): CustomPrint('Could not find ' + extracted + userZip) elif (os.path.getsize(extracted + userZip) <= 0): CustomPrint(extracted + userZip + ' is empty.') Exit() else: if (protectPass): protectPass = '******' + protectPass os.system(sevenZip + ' e -aot ' + extracted + userZip + ' -o' + extracted + userZip.replace('.7z', '') + protectPass) CustomPrint( '\nIf you see \'Everything is OK\' in above line then you can delete user zip file.' ) deleteUserZip = CustomInput('Delete ' + userZip + ' ? (default n) : ') or 'n' if (deleteUserZip.upper() == 'Y'): DeleteUserZip(userZip) else: Exit()
def Exit(): print('\n') CustomPrint('Exiting...') try: # Open in explorer. if (isWindows): os.startfile(os.path.realpath(extracted)) elif (isLinux): os.system('xdg-open ' + os.path.realpath(extracted)) else: os.system('open ' + os.path.realpath(extracted)) except: pass CustomInput('Hit \'Enter\' key to continue....', 'cyan') quit()
def main(): CustomPrint('This utility is for archiving your output folder with password to enchance it\'s security. Secure is a relative term. Choose longer password.') isCompressing = CustomInput('Are you (C)ompressing or (D)ecompressing? : ') while(True): if(isCompressing.upper() == 'C'): ListUserFolders() print('\n') userFolder = CustomInput( 'Enter a name of folder from above (case sensitive) : ') Compress(userFolder) break elif(isCompressing.upper() == 'D'): ListUserFiles() print('\n') userZip = CustomInput( 'Enter a name of file from above (case sensitive) : ') Uncompress(userZip) break else: isCompressing = CustomInput('Choose either \'c\' or \'d\' : ') continue
def ExtractAB(isJAVAInstalled, sdPath='', ADBSerialId='', callingFromOtherModule=True): if not (isJAVAInstalled): CustomPrint('Can not detect JAVA on system.') # move whatsapp.ab from tmp to user specified folder. userName = CustomInput('Enter a name for this user. : ') os.mkdir(extracted) if not (os.path.isdir(extracted)) else CustomPrint( 'Folder ' + extracted + 'already exists.', 'yellow') os.mkdir(extracted + userName) if not ( os.path.isdir(extracted + userName)) else CustomPrint('Folder ' + extracted + userName + ' exists.') os.rename(tmp + 'whatsapp.ab', extracted + userName + '/whatsapp.ab') CustomPrint('Moved whatsapp.ab to ' + extracted + userName + ' folder. Size : ' + str(os.path.getsize(extracted + userName + '/whatsapp.ab')) + ' bytes.') CustomPrint('Run view_extract.py after installing Java on system.') CleanTmp() Exit() if (not callingFromOtherModule): if (CustomInput( 'Have you already made whatsapp.ab and just extracting it now ? : ' ).upper() == 'Y'): ListUserFolders() print('\n') userName = CustomInput( 'Enter a name of folder from above (case sensitive) : ' ) or 'user' abPass = CustomInput( 'Enter same password which you entered on device when prompted earlier. : ' ) if (os.path.isfile(extracted + userName + '/whatsapp.ab')): try: CustomPrint('Found whatsapp.ab in ' + extracted + userName + ' folder. Size : ' + str( os.path.getsize(extracted + userName + '/whatsapp.ab')) + ' bytes.') os.mkdir(tmp) if not (os.path.isdir(tmp)) else CustomPrint( 'Folder ' + tmp + ' already exists.', 'yellow') os.system('java -jar ' + bin + 'abe.jar unpack ' + extracted + userName + '/whatsapp.ab ' + tmp + 'whatsapp.tar ' + str(abPass)) CustomPrint('Successfully unpacked ' + extracted + userName + '/whatsapp.ab to ' + tmp + 'whatsapp.tar. Size : ' + str(os.path.getsize(tmp + 'whatsapp.tar')) + ' bytes.') TakingOutMainFiles(userName, sdPath, ADBSerialId) except Exception as e: CustomPrint(e, 'red') else: CustomPrint('Could not find whatsapp.ab in ' + extracted + userName + ' folder, did you name your user properly?') Exit() if (os.path.isfile(tmp + 'whatsapp.ab')): CustomPrint('Found whatsapp.ab in tmp folder. Continuing... Size : ' + str(os.path.getsize(tmp + '/whatsapp.ab')) + ' bytes.') userName = CustomInput( 'Enter a reference name for this user. : ') or 'user' abPass = CustomInput( 'Enter same password which you entered on device when prompted earlier. : ' ) try: os.system('java -jar ' + bin + 'abe.jar unpack ' + tmp + 'whatsapp.ab ' + tmp + 'whatsapp.tar ' + str(abPass)) CustomPrint('Successfully unpacked ' + tmp + 'whatsapp.ab to ' + tmp + 'whatsapp.tar. Size : ' + str(os.path.getsize(tmp + 'whatsapp.tar')) + ' bytes.') TakingOutMainFiles(userName, sdPath, ADBSerialId) except Exception as e: CustomPrint(e, 'red')
def TakingOutMainFiles(userName, sdPath, ADBSerialId): os.mkdir(extracted) if not (os.path.isdir(extracted)) else CustomPrint( 'Folder ' + extracted + ' already exists.', 'yellow') os.mkdir(extracted + userName) if not (os.path.isdir(extracted + userName)) else CustomPrint( 'Folder ' + extracted + userName + ' already exists.', 'yellow') # If user folder already exists ask user to overwrite or skip. CustomPrint('Taking out main files in ' + tmp + ' folder temporaily.') try: bin = 'bin\\' if (isWindows) else '' os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/f/key') os.replace('tmp/apps/com.whatsapp/f/key', extracted + userName + '/key') os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/db/msgstore.db') os.replace('tmp/apps/com.whatsapp/db/msgstore.db', extracted + userName + '/msgstore.db') os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/db/wa.db') os.replace('tmp/apps/com.whatsapp/db/wa.db', extracted + userName + '/wa.db') os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/db/axolotl.db') os.replace('tmp/apps/com.whatsapp/db/axolotl.db', extracted + userName + '/axolotl.db') os.system(bin + tar + ' xvf ' + tmp + 'whatsapp.tar -C ' + tmp + ' apps/com.whatsapp/db/chatsettings.db') os.replace('tmp/apps/com.whatsapp/db/chatsettings.db', extracted + userName + '/chatsettings.db') CleanTmp() CustomPrint( 'You should not leave these extracted database and other files hanging in folder, it is very insecure.' ) createArchive = CustomInput( 'Would you like to create a password protected archive? (default y) : ' ) or 'y' if (createArchive.upper() == 'Y'): print('\n') CustomPrint( 'Now an archive will be created in extracted folder and original files will be deleted. To later \'un-archive\' and access these files you need to run \'python protect.py\' from root directory of this project.', 'yellow') protect.Compress(userName) else: print('\n') CustomPrint( '\aYour whatsapp database along with other files is in ' + os.path.realpath(extracted + userName) + ' folder.', 'yellow') print('\n') CustomInput('Hit Enter key to continue.') # TODO issue #13 : Ask user to save to sdcard. if (sdPath and ADBSerialId): copyTosdCard = CustomInput( 'Copy msgstore.db file to phone? (y/n) default \'n\' : ' ) or 'n' if (copyTosdCard.upper() == 'Y'): os.system(adb + ADBSerialId + ' push ' + extracted + userName + '/msgstore.db ' + sdPath + '/msgstore.db') CustomPrint('Done copying msgstore.db to phone.') try: # Open in explorer. if (isWindows): os.startfile(os.path.realpath(extracted + userName)) elif (isLinux): os.system('xdg-open ' + os.path.realpath(extracted + userName)) else: os.system('open ' + os.path.realpath(extracted + userName)) except: pass except Exception as e: CustomPrint(e, 'red') CleanTmp()