-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_afl.py
41 lines (31 loc) · 1.1 KB
/
run_afl.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
import multiprocessing
import sys
import os
import config
import utils
if len(sys.argv) > 1 and sys.argv[1].endswith(".o"):
utils.compile_harness(sys.argv[1])
elif len(sys.argv) > 1:
os.system(f"cp {sys.argv[1]} ./harness")
else:
code_loc = "test.c"
utils.setup()
os.system(f"gcc -g -c {code_loc} -no-pie -o {code_loc}.o")
utils.compile_harness(f"{code_loc}.o")
processes = []
def run_async_cmd(cmd):
print(cmd)
p = multiprocessing.Process(target=lambda _: os.system(cmd), args=(-1,))
p.daemon = True
p.start()
processes.append(p)
run_async_cmd(f"DIGFUZZ_SHM=/{config.SHM_KEY} "
f"{config.AFL_FUZZ_PATH} -Q -i {config.AFL_IN_PATH} -o {config.AFL_OUT_PATH} -M {config.AFL_MASTER_NAME} "
f"-- {config.LOCAL_UNINSTRUMENTED_EXEC_PATH} fuzz")
for i in range(config.AFL_NUM_SLAVE):
run_async_cmd(
f"DIGFUZZ_SHM=/{config.SHM_KEY} "
f"{config.AFL_FUZZ_PATH} -Q -i {config.AFL_IN_PATH} -o {config.AFL_OUT_PATH} -S {config.AFL_SLAVE_NAME}_{i} "
f"-- {config.LOCAL_UNINSTRUMENTED_EXEC_PATH} fuzz")
for p in processes:
p.join()