def start(): onlyfiles = [ f for f in listdir(fuzzerConfig.path_for_crash_samples) if isfile(join(fuzzerConfig.path_for_crash_samples, f)) ] for x in range(len(onlyfiles)): #clean tombstones adb_android.shell("rm /data/tombstones/*") #push file to device adb_android.push(fuzzerConfig.path_for_crash_samples + onlyfiles[x], "/data/local/tmp") #run the file adb_android.shell(fuzzerConfig.target_android_executable + ' /data/local/tmp/' + onlyfiles[x]) #collect the crash result = adb_android.shell( "ls -l /data/tombstones/ | grep tombstone_00") if (len(result) < 2): pass #No Tombstones generated , its a false positive else: adb_android.pull( '/data/tombstones/tombstone_00', fuzzerConfig.path_for_confirmed_samples + "tombstone_" + onlyfiles[x])
def start(): onlyfiles = [f for f in listdir(fuzzerConfig.path_for_crash_samples) if isfile(join(fuzzerConfig.path_for_crash_samples, f))] for x in range(len(onlyfiles)): #clean tombstones adb_android.shell("rm /data/tombstones/*") #push file to device adb_android.push(fuzzerConfig.path_for_crash_samples+onlyfiles[x],"/data/local/tmp") #run the file adb_android.shell(fuzzerConfig.target_android_executable+' /data/local/tmp/' + onlyfiles[x]) #collect the crash result = adb_android.shell("ls -l /data/tombstones/ | grep tombstone_00") if(len(result)<2): pass #No Tombstones generated , its a false positive else: adb_android.pull('/data/tombstones/tombstone_00',fuzzerConfig.path_for_confirmed_samples+"tombstone_"+onlyfiles[x])
def _shell_command(command): host_status_code, output = adb_android.shell('%s; echo $?' % command) if host_status_code != 0: raise HostException output = output.splitlines() device_status_code = int(output[-1]) if device_status_code != 0: raise DeviceException return output[:-1]
def run_on_android_emulator(): onlyfiles = [f for f in listdir(fuzzerConfig.path_to_mutated_dex) if isfile(join(fuzzerConfig.path_to_mutated_dex, f))] for x in range(len(onlyfiles)): print fuzzerConfig.path_to_mutated_dex+onlyfiles[x] #adb logcat -c to clear logs from logcat adb_android.push(fuzzerConfig.path_to_mutated_dex+onlyfiles[x], '/data/local/tmp/') adb_android.shell('log -p F -t CRASH_LOGGER SIGSEGV : '+onlyfiles[x]) adb_android.shell(fuzzerConfig.target_android_executable+' /data/local/tmp/'+onlyfiles[x]) adb_android.shell("rm /data/local/tmp/"+onlyfiles[x]) save_logs()
def run_on_android_emulator(): onlyfiles = [ f for f in listdir(fuzzerConfig.path_to_mutated_dex) if isfile(join(fuzzerConfig.path_to_mutated_dex, f)) ] for x in range(len(onlyfiles)): print fuzzerConfig.path_to_mutated_dex + onlyfiles[x] #adb logcat -c to clear logs from logcat adb_android.push(fuzzerConfig.path_to_mutated_dex + onlyfiles[x], '/data/local/tmp/') adb_android.shell('log -p F -t CRASH_LOGGER SIGSEGV : ' + onlyfiles[x]) adb_android.shell(fuzzerConfig.target_android_executable + ' /data/local/tmp/' + onlyfiles[x]) adb_android.shell("rm /data/local/tmp/" + onlyfiles[x]) save_logs()
def start_gdb_server_in_device(): out = adb_android.shell( "/data/local/tmp/gdbserver :5039 /system/xbin/dexdump /data/local/tmp/crash.dex" ) print out
# coding=utf-8 import os import re from adb_android import adb_android # Имя папки для бэкапа dir_backup = "backup_tmp" # Бекапить большие разделы? (userdata, system_a, system_b etc) big_partition = False adb_android.wait_for_device() # Ждем устройство # Получаем список разделов с именами partition_list_table = adb_android.shell( "ls -l /dev/block/platform/soc/c0c4000.sdhci/by-name/") # Разбивем список по строкам. partition_list_clean = partition_list_table[1].split("\n") # Чистим список от первого и последнего элемента. Там мусор. partition_list_clean.pop() partition_list_clean.pop(0) # Список имен list_name_partition = [] # Список путей до разделов list_block_path = [] # Собираем регуляркой из построчного списка пути до разбелов и их имена.
from audioshift import run_test offset = 0 def do_test(): sleep(5) #Actually test here for i in range(5): res = run_test(5) print("Test {} {}:{}ms".format(i, offset, res[0][1]), flush=True) #Initial control do_test() #Test positive offsets for i in range(7): adb_android.shell("input tap " + str(0x22d) + " " + str(0x570)) sleep(1) adb_android.shell("input keyevent 22") #Get focus adb_android.shell("input keyevent 22") #Get focus adb_android.shell("input keyevent 22") sleep(1) adb_android.shell("input tap " + str(0xae) + " " + str(0x49a)) offset += 1 do_test() #Reset offset adb_android.shell("input tap " + str(0x22d) + " " + str(0x570)) sleep(1) adb_android.shell("input keyevent 22") #Get focus adb_android.shell("input keyevent 22") #Get focus for i in range(7):
def save_logs(): adb_android.shell("logcat -d > /data/local/tmp/logcat.txt")
def clear_logcat(): adb_android.shell("logcat -c")
import sys from adb_android import adb_android def my_except_hook(exctype, value, traceback): if exctype == KeyboardInterrupt: print "Handler code goes here" m = 0 while m <= i: adb_android.pull("/sdcard/demo{0}.mp4".format(m), ".") m = m + 1 print m else: sys.__excepthook__(exctype, value, traceback) sys.excepthook = my_except_hook adb_android.get_state() adb_android.wait_for_device() i = 0 while i < 100000000: adb_android.wait_for_device() adb_android.shell( "screenrecord --time-limit 180 /sdcard/demo{0}.mp4".format(i)) print i i = i + 1 pass
from adb_android import adb_android from time import sleep from audioshift import run_test offset = 0 def do_test(): sleep(5) #Actually test here for i in range(5): res = run_test(5) print("Test {} {}:{}ms".format(i, offset, res[0][1]), flush=True) #Initial control do_test() #Test positive offsets for i in range(5): sleep(1) adb_android.shell("input tap " + str(0x1af) + " " + str(0x6a9)) sleep(10) offset += 1 do_test()
from adb_android import adb_android from time import sleep from audioshift import run_test time = 0 def do_test(): sleep(5) #Actually test here for i in range(5): res = run_test(5) print("Test {} {}:{}ms".format(i, time, res[0][1]), flush=True) #Initial control for i in range(5): adb_android.shell("input tap " + str(0x37d) + " " + str(0x79)) sleep(1) time = i do_test()
from adb_android import adb_android from time import sleep from audioshift import run_test time = 0 def do_test(): sleep(5) #Actually test here for i in range(5): res = run_test(5) print("Test {} {}:{}ms".format(i, time, res[0][1]), flush=True) #Initial control for i in range(5): #Next adb_android.shell("input tap " + str(0x3fb) + " " + str(0x8ea)) #Play/Pause adb_android.shell("input tap " + str(0x2c2) + " " + str(0x8f4)) sleep(5) #Prev adb_android.shell("input tap " + str(0x1aa) + " " + str(0x8f9)) #Prev adb_android.shell("input tap " + str(0x1aa) + " " + str(0x8f9)) #Play/Pause adb_android.shell("input tap " + str(0x2c2) + " " + str(0x8f4)) sleep(10) time = i do_test()
def start_gdb_server_in_device(): out = adb_android.shell("/data/local/tmp/gdbserver :5039 /system/xbin/dexdump /data/local/tmp/crash.dex") print out