-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathafl-j
executable file
·66 lines (61 loc) · 1.59 KB
/
afl-j
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Helper script to run afl parallelly.
import os
import sys
import subprocess
import argparse
import shutil
def main():
parser = argparse.ArgumentParser(description='Run afl parallelly')
parser.add_argument('-e',
help='Path to afl',
default=shutil.which('afl-fuzz'))
parser.add_argument('-j', type=int, default=1)
parser.add_argument('-t', help='Target binary to fuzz', required=True)
parser.add_argument('-i', required=True)
parser.add_argument('-o', required=True)
config = parser.parse_args()
config.j = min(config.j, os.cpu_count())
# Launch source process first.
source_cmd = [
config.e,
'-b',
'0',
'-i',
config.i,
'-o',
config.o,
'-M',
'fuzzer0',
'--',
config.t,
]
source = subprocess.Popen(source_cmd)
replicas = []
for i in range(1, config.j):
replica_cmd = [
config.e,
'-b',
'%d' % i,
'-i',
config.i,
'-o',
config.o,
'-S',
'fuzzer%d' % i,
'--',
config.t,
]
replicas.append(
subprocess.Popen(replica_cmd,
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL))
try:
source.wait()
except (Exception, KeyboardInterrupt):
source.terminate()
for p in replicas:
p.terminate()
if __name__ == '__main__':
sys.exit(main())