All backup methods implimented

This commit is contained in:
Kass Rode 2024-08-17 16:39:26 -04:00
parent d3706c129c
commit d97d3b9113
6 changed files with 41 additions and 14 deletions

5
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.pyc *.pyc
twrp.img *.img
*.ab *.ab
*.tar.gz *.tar
*.zip

9
README.md Normal file
View File

@ -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

View File

@ -23,6 +23,10 @@ def connect_device():
def shell(device, command): def shell(device, command):
return device.shell(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(): def reboot_bootloader():
print("Rebooting to Bootloader...") print("Rebooting to Bootloader...")
os.system('adb reboot-bootloader') os.system('adb reboot-bootloader')

27
main.py
View File

@ -29,6 +29,9 @@ def device_pull():
print("Unable to connect to device. Ensure that Debug Mode is enabled and USB Debugging is allowed") print("Unable to connect to device. Ensure that Debug Mode is enabled and USB Debugging is allowed")
sys.exit() sys.exit()
print("getting twrp...") print("getting twrp...")
if os.path.isfile('./twrp.img'):
pass
else:
download_twrp() download_twrp()
adb.reboot_bootloader() adb.reboot_bootloader()
fastboot.devices() fastboot.devices()
@ -40,14 +43,26 @@ def device_pull():
except: except:
time.sleep(10) time.sleep(10)
device = adb.connect_device() device = adb.connect_device()
command = adb.shell(device, "whoami") adb.pull(device, "/dev/block/sda", "./sda.img")
print(command)
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(): def menu():
print('Acquisition Script for Mobile Resources') print('Acquisition Script for Mobile Resources')
print("---------------------------------------") print("---------------------------------------")
print("[1] Device Pull") print("[1] Physical Image")
print("[2] Application Pull") print("[2] Logical Image")
print("[3] ADB Backup") print("[3] ADB Backup")
print("[99] Exit") print("[99] Exit")
@ -58,10 +73,10 @@ def main():
case 1: case 1:
device_pull() device_pull()
case 2: case 2:
pass logicpull()
case 3: case 3:
adb.backup() 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: case 99:
sys.exit() sys.exit()

3
requirements.txt Normal file
View File

@ -0,0 +1,3 @@
lxml==4.8.0
pure_python_adb==0.3.0.dev0
Requests==2.32.3

View File

@ -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)