예제 #1
0
파일: triage.py 프로젝트: zym-wade/droid-ff
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])
예제 #2
0
파일: triage.py 프로젝트: 13061121/droid-ff
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])
예제 #3
0
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]
예제 #4
0
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]
예제 #5
0
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()
예제 #6
0
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()
예제 #7
0
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
예제 #8
0
# 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 = []

# Собираем регуляркой из построчного списка пути до разбелов и их имена.
예제 #9
0
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):
예제 #10
0
def save_logs():
    adb_android.shell("logcat -d > /data/local/tmp/logcat.txt")
예제 #11
0
def save_logs():
    adb_android.shell("logcat -d > /data/local/tmp/logcat.txt")
예제 #12
0
def clear_logcat():
    adb_android.shell("logcat -c")
예제 #13
0
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
예제 #14
0
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()
예제 #15
0
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()

예제 #16
0
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()

예제 #17
0
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
예제 #18
0
def clear_logcat():
    adb_android.shell("logcat -c")