From d97d3b9113d4c2eda2298ac780642e9e770be724 Mon Sep 17 00:00:00 2001 From: kass Date: Sat, 17 Aug 2024 16:39:26 -0400 Subject: [PATCH] All backup methods implimented --- .gitignore | 5 +++-- README.md | 9 +++++++++ helpers/adb/adb.py | 4 ++++ main.py | 29 ++++++++++++++++++++++------- requirements.txt | 3 +++ test.py | 5 ----- 6 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 README.md create mode 100644 requirements.txt delete mode 100644 test.py diff --git a/.gitignore b/.gitignore index 6985b0c..d86d363 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc -twrp.img +*.img *.ab -*.tar.gz \ No newline at end of file +*.tar +*.zip \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..648055a --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Acquisition Script for Mobile Resources +## Written by Kassiopia Rode +This script is designed to ease the aquisition of Android devices. It has options for a Physical extraction (requires bootloader to be unlocked), logical extraction, and adb backups +### Requirements +This script was built using Python 3.10.12 but any version 3.10+ should work. \ +Required libraries can be installed with `pip install requirements.txt` \ +All device extraction methods require USB Debugging to be enabled and the user to have the device passcode. +### Running the script +Run `python3 main.py` and select the relevant menu item \ No newline at end of file diff --git a/helpers/adb/adb.py b/helpers/adb/adb.py index b336cbd..b21acd3 100644 --- a/helpers/adb/adb.py +++ b/helpers/adb/adb.py @@ -23,6 +23,10 @@ def connect_device(): def shell(device, command): return device.shell(command) +def pull(device, ipath, opath): + print(f"Pulling {ipath} to {opath}...") + os.system(f'adb pull {ipath} {opath}') + def reboot_bootloader(): print("Rebooting to Bootloader...") os.system('adb reboot-bootloader') diff --git a/main.py b/main.py index 0b3ccb9..53ee94e 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,10 @@ def device_pull(): print("Unable to connect to device. Ensure that Debug Mode is enabled and USB Debugging is allowed") sys.exit() print("getting twrp...") - download_twrp() + if os.path.isfile('./twrp.img'): + pass + else: + download_twrp() adb.reboot_bootloader() fastboot.devices() fastboot.unlock() @@ -40,14 +43,26 @@ def device_pull(): except: time.sleep(10) device = adb.connect_device() - command = adb.shell(device, "whoami") - print(command) + adb.pull(device, "/dev/block/sda", "./sda.img") + +def logicpull(): + install.main() + print("Connecting Device...") + try: + device = adb.connect_device() + except: + print("Unable to connect to device. Ensure that Debug Mode is enabled and USB Debugging is allowed") + sys.exit() + print("pulling data...") + adb.pull(device, "/sdcard", "./sdcard") + os.system('zip -r logical.zip ./sdcard') + os.system("rm -r ./sdcard") def menu(): print('Acquisition Script for Mobile Resources') print("---------------------------------------") - print("[1] Device Pull") - print("[2] Application Pull") + print("[1] Physical Image") + print("[2] Logical Image") print("[3] ADB Backup") print("[99] Exit") @@ -58,10 +73,10 @@ def main(): case 1: device_pull() case 2: - pass + logicpull() case 3: adb.backup() - os.system("python helpers/unpackBackup.py -i ./backup.ab") + os.system("dd if=backup.ab bs=1 skip=24 | python3 -c 'import zlib,sys;sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))' > backup.tar") case 99: sys.exit() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f1c2ef2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +lxml==4.8.0 +pure_python_adb==0.3.0.dev0 +Requests==2.32.3 diff --git a/test.py b/test.py deleted file mode 100644 index 6516e2c..0000000 --- a/test.py +++ /dev/null @@ -1,5 +0,0 @@ -import os, subprocess -unlock = os.popen('fastboot getvar unlocked 2>&1').read() -print(unlock) -#if "yes" not in unlock: -# print(True) \ No newline at end of file