Added logging
This commit is contained in:
parent
dd895e8478
commit
19c36a3463
@ -23,6 +23,9 @@ def connect_device():
|
|||||||
def shell(device, command):
|
def shell(device, command):
|
||||||
return device.shell(command)
|
return device.shell(command)
|
||||||
|
|
||||||
|
def serialno():
|
||||||
|
return os.popen("adb get-serialno").read()
|
||||||
|
|
||||||
def pull(device, ipath, opath):
|
def pull(device, ipath, opath):
|
||||||
print(f"Pulling {ipath} to {opath}...")
|
print(f"Pulling {ipath} to {opath}...")
|
||||||
os.system(f'adb pull {ipath} {opath}')
|
os.system(f'adb pull {ipath} {opath}')
|
||||||
|
21
helpers/logger.py
Normal file
21
helpers/logger.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import datetime
|
||||||
|
def start_logger():
|
||||||
|
date = datetime.datetime.now()
|
||||||
|
filename = str(date) + '-log.txt'
|
||||||
|
with open(filename, 'a+') as f:
|
||||||
|
f.write("------------------ASMR Log--------------\n")
|
||||||
|
f.write("Log started at: "+str(date)+"\n")
|
||||||
|
f.close()
|
||||||
|
return filename
|
||||||
|
|
||||||
|
def add_log(filename, data):
|
||||||
|
with open(filename, 'a+') as f:
|
||||||
|
f.write(data+"\n")
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
def stop_logger(filename):
|
||||||
|
date = datetime.datetime.now()
|
||||||
|
with open(filename, "a+") as f:
|
||||||
|
f.write("Acquisition finished at: "+str(date)+"\n")
|
||||||
|
f.write("----------------------------------------")
|
||||||
|
f.close()
|
26
main.py
26
main.py
@ -1,6 +1,8 @@
|
|||||||
import helpers.adb.adb as adb, helpers.fastboot.fastboot as fastboot, install, time, os, requests, urllib.request, sys, helpers.unpackBackup as unpackBackup
|
import helpers.adb.adb as adb, helpers.fastboot.fastboot as fastboot, install, time, os, requests, urllib.request, sys, helpers.logger as logger
|
||||||
from lxml import html
|
from lxml import html
|
||||||
|
|
||||||
|
filename = ''
|
||||||
|
|
||||||
def download_twrp():
|
def download_twrp():
|
||||||
cpu = os.popen('adb shell getprop ro.product.board').read()
|
cpu = os.popen('adb shell getprop ro.product.board').read()
|
||||||
cpu = cpu.rstrip('\n')
|
cpu = cpu.rstrip('\n')
|
||||||
@ -28,6 +30,8 @@ def device_pull():
|
|||||||
except:
|
except:
|
||||||
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()
|
||||||
|
serialno = adb.serialno()
|
||||||
|
logger.add_log(filename, "Serial Number: "+str(serialno))
|
||||||
print("getting twrp...")
|
print("getting twrp...")
|
||||||
if os.path.isfile('./twrp.img'):
|
if os.path.isfile('./twrp.img'):
|
||||||
pass
|
pass
|
||||||
@ -52,11 +56,16 @@ def logicpull():
|
|||||||
device = adb.connect_device()
|
device = adb.connect_device()
|
||||||
except:
|
except:
|
||||||
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")
|
||||||
|
logger.add_log(filename, "Unable to connect to device. Ensure that Debug Mode is enabled and USB Debugging is allowed")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
serialno = adb.serialno()
|
||||||
|
logger.add_log(filename, "Serial Number: "+str(serialno))
|
||||||
print("pulling data...")
|
print("pulling data...")
|
||||||
adb.pull(device, "/sdcard", "./sdcard")
|
adb.pull(device, "/sdcard", "./sdcard")
|
||||||
os.system('zip -r logical.zip ./sdcard')
|
os.system('zip -r logical.zip ./sdcard')
|
||||||
os.system("rm -r ./sdcard")
|
os.system("rm -r ./sdcard")
|
||||||
|
hash = os.popen("md5sum logical.zip").read()
|
||||||
|
logger.add_log(filename, "MD5 Hash: "+str(hash))
|
||||||
|
|
||||||
def menu():
|
def menu():
|
||||||
print('Acquisition Script for Mobile Resources')
|
print('Acquisition Script for Mobile Resources')
|
||||||
@ -69,14 +78,27 @@ def menu():
|
|||||||
def main():
|
def main():
|
||||||
menu()
|
menu()
|
||||||
choice = int(input("Please select an option: "))
|
choice = int(input("Please select an option: "))
|
||||||
|
global filename
|
||||||
match choice:
|
match choice:
|
||||||
case 1:
|
case 1:
|
||||||
|
filename = logger.start_logger()
|
||||||
|
logger.add_log(filename, "Type: Physical Image")
|
||||||
device_pull()
|
device_pull()
|
||||||
|
logger.stop_logger(filename)
|
||||||
case 2:
|
case 2:
|
||||||
|
filename = logger.start_logger()
|
||||||
|
logger.add_log(filename, "Type: Logical Image")
|
||||||
logicpull()
|
logicpull()
|
||||||
case 3:
|
logger.stop_logger(filename)
|
||||||
|
case 3:
|
||||||
|
filename = logger.start_logger()
|
||||||
|
logger.add_log(filename, "Type: ADB Backup")
|
||||||
|
serialno = adb.serialno()
|
||||||
|
logger.add_log(filename, "Serial Number: " + str(serialno))
|
||||||
adb.backup()
|
adb.backup()
|
||||||
|
input("After confirming the backup operation, press enter to continue.")
|
||||||
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")
|
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")
|
||||||
|
logger.stop_logger(filename)
|
||||||
case 99:
|
case 99:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user