-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathsp_stream.py
72 lines (56 loc) · 2.03 KB
/
sp_stream.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
/*
* Android media framework fuzzer
* Copyright (c) 2015, Intel Corporation.
* Author: Alexandru Blanda (ioan-alexandru.blanda@intel.com)
*
* 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.
*/
"""
from os import listdir
import sys
import subprocess
import re
import time
from utils import *
if sys.argv[1] == '-h':
print 'Usage:\n'
print 'python sp_stream.py <path_seed_files> <seed_number> <device_id>'
print 'path_seed_files - path to directory containing the seed files'
print 'seed_number - number of the seed file to start from'
print 'device_id - device id\n'
sys.exit()
seed_files = listdir(sys.argv[1])
length = len(seed_files)
start = int(sys.argv[2])
device_id = sys.argv[3]
# flush logcat buffer if a new campaign is started
if start == 0:
flush_log(device_id)
for x in range(start, length):
print '***** Sending file: ' + str(x) + ' - ' + seed_files[x]
# push the file to the device
cmd = 'adb -s ' + sys.argv[3] + ' push ' + "'" + sys.argv[1] + '/' \
+ seed_files[x] + "'" + " '/data/Music/" + seed_files[x] + "'"
run_subproc(cmd)
# log the file being sent to the device
cmd = 'adb -s ' + sys.argv[3] \
+ " shell log -p F -t Stagefright - sp_stream '*** " + str(x) \
+ " - Filename:'" + seed_files[x]
run_subproc(cmd)
# try to decode audio file
cmd = 'timeout 15 adb -s ' + sys.argv[3] \
+ " shell stream '/data/Music/" + seed_files[x] + "'"
run_subproc(cmd)
# remove the file from the device
cmd = 'adb -s ' + sys.argv[3] + ' shell rm /data/Music/*'
run_subproc(cmd)