def do_screencap(self, args): import time cmd = 'screencap -p /sdcard/{}.png'.format(time.time()) if not self.adb: self.adb = pyadb3.ADB() self.adb.run_shell_cmd(cmd)
def hashmd5(self, window): time.sleep(5) fDirect = self.outputfolder nDirect = "/_Ext" + self.txtFileName.get() + ".dd" alldirect = fDirect + nDirect block_size = 2**20 md5a = hashlib.md5() if (os.path.exists(alldirect)): with open(alldirect, 'rb') as fileCloning: while True: readCloning = fileCloning.read(block_size) if not readCloning: break md5a.update(readCloning) self.hasilCloning = md5a.hexdigest() adbHash = pyadb3.ADB() coHash = adbHash.run_shell_cmd("su -c md5sum /dev/block/{}".format( self.choosenDir)) splitHash = "{coHash}".format(coHash=coHash) self.hasilHash = splitHash[2:34] self.isHashMatched = "" if self.hasilHash == self.hasilCloning: self.isHashMatched = "MD5 Hash Matched" else: self.isHashMatched = "MD5 Hash Not Matched"
def do_topactivity(self, args): if not self.adb: self.adb = pyadb3.ADB() self.adb.run_shell_cmd( "dumpsys activity activities | grep mFocusedActivity") print(self.adb.get_output().decode( 'utf-8', errors='ignore').split()[-2])
def do_adb(self, arg): ''' 执行adb命令 ''' if not self.adb: self.adb = pyadb3.ADB() self.adb.run_cmd(arg) print(self.adb.get_output().decode('utf-8', errors='ignore'))
def do_monkey(self, args): if not self.adb: self.adb = pyadb3.ADB() cmd = "monkey -p {} ".format(self.get_package()) if args.verbose: cmd += '-v ' cmd += str(args.count) self.adb.run_shell_cmd(cmd) print(self.adb.get_output().decode())
def do_adb_ready(self, args): ''' 连接设备/模拟器,准备adb命令。 ''' serial = None if args.serial: serial = args.serial self.adb = pyadb3.ADB(device=serial) if len(self.adb.get_output().decode()) > 10: print('ADB ready.') else: print("unable to connect to device.")
def outputDumpShell(self, window): padb = pyadb3.ADB() partitionList = padb.run_shell_cmd( "cat /proc/partitions | grep {}".format(self.choosenDir)) partitionResult = 0 if len(partitionList) > 0: partitionSplit = partitionList.split()[2] partitionSize = "{partitionSplit}".format( partitionSplit=partitionSplit).replace("b", "").replace("'", "") partitionResult = int(partitionSize) / (1024 * 1024) print("{} GB".format(partitionResult)) return partitionResult
def do_details(self, args): if not self.adb: self.adb = pyadb3.ADB() self.adb.run_shell_cmd("dumpsys package {}".format(self.get_package())) print(self.adb.get_output().decode('utf-8', errors='ignore'))