From 2d8f137cb6ce11e730c9650227a2f9053ec3aaf8 Mon Sep 17 00:00:00 2001 From: Kevin Rode Date: Sun, 29 Sep 2019 15:38:41 -0400 Subject: [PATCH] Updated with module support --- amt.py | 108 +----------------------- helpers/__pycache__/root.cpython-37.pyc | Bin 0 -> 3212 bytes helpers/root.py | 97 +++++++++++++++++++++ 3 files changed, 101 insertions(+), 104 deletions(-) create mode 100644 helpers/__pycache__/root.cpython-37.pyc create mode 100644 helpers/root.py diff --git a/amt.py b/amt.py index 60829f5..ad4c4e8 100644 --- a/amt.py +++ b/amt.py @@ -4,100 +4,8 @@ Code to interact with an android device using ADB Written by Kevin Rode Last Updated Sep 28 2019 """ -import adbutils -import os import sys -import re -import time -import requests -from lxml import html - - -def adb_start(): - if "platform-tools" in os.environ['PATH']: - print("ADB found in PATH") - else: - os.environ['PATH'] += ';'+os.getcwd()+'\\platform-tools' - - -def adb_connect(): - adb = adbutils.AdbClient(host="127.0.0.1", port=5037) - d = adb.device() - if d != None: - print("Device connected.") - return d - - -def twrp_download(d): - found = 0 - files = os.listdir(os.curdir) - for file in files: - if "twrp" in file: - found = 1 - if found != 1: - cpu = d.shell('cat /proc/cpuinfo | grep Hardware') - cpu = cpu.replace(" ", "") - cpu = re.sub(r'(.+:)', '', cpu) - r = requests.get('https://dl.twrp.me/'+cpu) - tree = html.fromstring(r.text) - urls = tree.xpath('//a/@href') - downloads = [] - for i in urls: - if "img" in i: - 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...") - files = os.listdir(os.curdir) - for file in files: - if "twrp" in file: - found = 1 - while found != 1: - print("File not found. Please confirm it has been moved to the correct directory") - input("Press Enter to continue...") - files = os.listdir(os.curdir) - for file in files: - if "twrp" in file: - found = 1 - else: - print("twrp already downloaded") - - -def push_files(d): - initcheck_magisk = d.shell("cd /sdcard && ls | grep Magisk") - if initcheck_magisk == None and initcheck_twrp == None: - d.sync.push("Magisk-v19.3.zip", "/sdcard/Magisk.zip") - check_magisk = d.shell("cd /sdcard && ls | grep Magisk") - if check != None: - print("File copied successfully.") - else: - print("Something went wrong. Please try again.") - else: - print("Magisk already copied") - - -def reboot_bootloader(): - adb = "platform-tools\\adb.exe" - fastboot = "platform-tools\\fastboot.exe" - os.system(adb+" reboot bootloader") - input("Press Enter when the device has rebooted") - os.system(fastboot+" devices") - - -def root_device(): - 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") - 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") +from helpers import root def menu(): @@ -105,11 +13,7 @@ def menu(): print("[1] Root Device (WIP)\n[2] Extract Data (Coming Soon)\n[99] Quit") choice = input("Please select a number: ") if int(choice) == 1: - device = adb_connect() - twrp_download(device) - push_files(device) - reboot_bootloader() - root_device() + root.root_device() elif int(choice) == 2: print("Data extraction is coming soon.") time.sleep(2) @@ -135,14 +39,10 @@ def show_help(): def main(): if "--interactive" in sys.argv[1:] or "-i" in sys.argv[1:]: - adb_start() + root.adb_start() menu() elif "--root" in sys.argv[1:] or "-r" in sys.argv[1:]: - device = adb_connect() - twrp_download(device) - push_files(device) - reboot_bootloader() - root_device() + root.root_device() elif "--help" in sys.argv[1:] or "-h" in sys.argv[1:]: show_help() else: diff --git a/helpers/__pycache__/root.cpython-37.pyc b/helpers/__pycache__/root.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..28235f1c91cf02cd3731939b687b2bf2726c0b4a GIT binary patch literal 3212 zcmbVPTW=f36`s9vN!^u3iqgWJqKzZAH5s=+f~rOl*|K2+ji5Si1+3)?)XtDxYq?9! z3@vG~1PZvwTY>Z+P>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