diff --git a/README.md b/README.md index 912e573..feb428b 100644 --- a/README.md +++ b/README.md @@ -15,10 +15,15 @@ A compiled version is available in the releases tab + Add options to extract all data on the phone ## Changelog +v1.1 + + App extraction added + + Downloading twrp now happens without user interaction + + Root checking option added + v1.0.1 + Updated zip with correct files for rooting + Spelling fixes - + v1.0 + Initial version + Root any twrp compatible device diff --git a/amt.py b/amt.py index ad4c4e8..bd57cf7 100644 --- a/amt.py +++ b/amt.py @@ -6,21 +6,24 @@ Last Updated Sep 28 2019 """ import sys from helpers import root +from helpers import extract def menu(): while True: - print("[1] Root Device (WIP)\n[2] Extract Data (Coming Soon)\n[99] Quit") + print("[1] Root Device\n[2] Check root\n[3] Extract Data (WIP)\n[99] Quit") choice = input("Please select a number: ") if int(choice) == 1: root.root_device() elif int(choice) == 2: - print("Data extraction is coming soon.") - time.sleep(2) + root.root_check() + elif int(choice) == 3: + extract.extract_menu() elif int(choice) == 99: print("Goodbye!") sys.exit() - + else: + print("Unknown input") def show_help(): print("Android Mobile Toolkit v1.1") @@ -33,6 +36,8 @@ def show_help(): print(" -i : alias for --interactive") print(" --root : root a connected Android device") print(" -r : alias for --root") + print(" --check-root : checks if the device is rooted") + print(" -Ae : Extract data in app extract mode. Add -o to specify an output directory") print(" --help : print this message") print(" -h : alias for --help") @@ -45,6 +50,15 @@ def main(): root.root_device() elif "--help" in sys.argv[1:] or "-h" in sys.argv[1:]: show_help() + elif "--check-root" in sys.argv[1:]: + root.root_check() + elif "-Ae" in sys.argv[1:]: + if "-o" in sys.argv[1:]: + output_index = sys.argv.index("-o") + output = sys.argv[output_index+1] + extract.app_extract(output) + else: + extract.app_extract() else: show_help() diff --git a/helpers/__pycache__/extract.cpython-37.pyc b/helpers/__pycache__/extract.cpython-37.pyc new file mode 100644 index 0000000..fc1936a Binary files /dev/null and b/helpers/__pycache__/extract.cpython-37.pyc differ diff --git a/helpers/__pycache__/root.cpython-37.pyc b/helpers/__pycache__/root.cpython-37.pyc index 28235f1..324c94d 100644 Binary files a/helpers/__pycache__/root.cpython-37.pyc and b/helpers/__pycache__/root.cpython-37.pyc differ diff --git a/helpers/extract.py b/helpers/extract.py new file mode 100644 index 0000000..fc25fb2 --- /dev/null +++ b/helpers/extract.py @@ -0,0 +1,69 @@ +import adbutils +from helpers import root +import os +import sys + + +def recovery_boot(): + adb = "platform-tools\\adb.exe" + adbcheck = os.popen(adb+" devices").read() + if "recovery" in adbcheck: + pass + else: + device = root.adb_connect() + root.twrp_download(device) + root.push_files(device) + root.reboot_bootloader() + adb = "platform-tools\\adb.exe" + fastboot = "platform-tools\\fastboot.exe" + files = os.listdir(os.curdir) + for file in files: + if "twrp" in file: + twrp = file + os.system(fastboot + " boot "+twrp) + input("Press Enter when TWRP has booted") + + +def list_apps(): + adb = "platform-tools\\adb.exe" + apps = os.popen(adb+" shell (ls /data/data)").read() + app_array = apps.split("\n") + for i in app_array: + print(i) + + +def download_app(o=None): + app = input("Please enter the name of the app you would like to download: ") + adb = "platform-tools\\adb.exe" + os.system(adb+" shell (cp -R /data/data/"+app+" /sdcard/"+app+")") + if o == None: + output = input("Please enter the output directory for the app files. Leave blank to download to current directory: ") + if output != None: + os.makedirs(output) + os.system(adb+" pull /sdcard/"+app+" "+output) + else: + os.system(adb+" pull /sdcard/"+app) + else: + os.makedirs(o) + os.system(adb+" pull /sdcard/"+app+" "+o) + + +def app_extract(output=None): + recovery_boot() + list_apps() + download_app(output) + + +def extract_menu(): + while True: + print("How would you like to extract data") + print("[1] App extraction\n[2] Whole Phone Extraction (via Android Backup)(COMING SOON)\n[3] Whole Phone Extraction (via adb shell)(COMING SOON)\n[99] Main Menu") + choice = input() + if int(choice) == 1: + app_extract() + elif int(choice) == 2: + print() + elif int(choice) == 3: + print() + elif int(choice) == 99: + break diff --git a/helpers/root.py b/helpers/root.py index d882179..5ea3f4a 100644 --- a/helpers/root.py +++ b/helpers/root.py @@ -40,9 +40,11 @@ def twrp_download(d): downloads.append(i) url_to_download = "https://dl.twrp.me"+downloads[0] url_to_download = url_to_download.replace('.html', '') - print("Use this link to download twrp for your connected device: "+url_to_download) - print("Ensure that the downloaded file is moved to the same folder as the script before continuing") - input("Press Enter to continue...") + s = requests.Session() + s.headers.update({'referer':url_to_download}) + img = s.get(url_to_download) + with open("twrp.img",'wb') as f: + f.write(img.content) files = os.listdir(os.curdir) for file in files: if "twrp" in file: @@ -95,3 +97,12 @@ def root_device(): print("Follow the onscreen directions to install Magisk (Located at the bottom of the install window)") print("After Magisk installs click [Reboot] then [Do Not Install]") input("Press Enter when the device has rebooted") + + +def root_check(): + device = adb_connect() + rootcheck = device.shell("ls /sbin | grep su") + if rootcheck != None: + print("Device is rooted") + else: + print("Device is not rooted")