forked from fuzzing/MFFA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriage.py
86 lines (72 loc) · 2.35 KB
/
triage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
/*
* Android media framework fuzzer
* Copyright (c) 2015, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/
Author: Alexandru Blanda ([email protected])
"""
import sys
import subprocess
import re
import time
from utils import *
if (sys.argv[1] == "-h"):
print 'Usage:\n '
print 'python triage.py <signal_type> <file_type>'
print "signal_type - {SIGSEGV, SIGABRT, SIGILL} (type of signal to catch)"
print "file_type - {video, audio} \n"
sys.exit()
signal_type = sys.argv[1]
file_type = sys.argv[2]
#get device list
cmd = "adb devices > devices.txt"
run_subproc(cmd)
f1 = open("devices.txt", "rw")
devices = f1.readlines()
count_devices = len(devices) - 2
dev = [None] * count_devices
c = 0
for i in range(1, len(devices)-1):
reg_device = re.compile('\S*\s')
dev[c] = (str)((reg_device.findall(devices[i]))[0])
dev[c] = dev[c].rstrip()
c = c + 1
count_devices = len(dev)
#get log list
f2 = open("logs.txt", "rw")
logs = f2.readlines()
for i in range(0, len(logs)):
logs[i] = logs[i].rstrip()
count_logs = len(logs)
if (count_logs == 0):
print 'No logs to run'
print 'Edit the logs.txt file!'
sys.exit()
if count_logs < count_devices:
print 'More devices than logs to analyze...'
print '...quit now to use all available devices'
time.sleep(5)
print 'continuing...'
retcode = [None] * count_devices
#each device must get a log to analyze
if (count_devices == count_logs):
for i in range(0, count_devices):
cmd = "python get_uniquecrash.py" + " " + logs[i] + " " + \
dev[i] + " " + file_type + " " + signal_type
retcode[i] = subprocess.Popen([cmd], shell=True)
#wait for each device to finish their logs
for i in range(0, count_devices-1):
retcode[i].wait()
else:
print "Check number of logs and number of devices..."