-
Notifications
You must be signed in to change notification settings - Fork 1
/
recorder.py
32 lines (27 loc) · 1.08 KB
/
recorder.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
# -*- codeing = utf-8 -*-
# @Time : 2023/5/7 16:34
# @Author : Lowry
# @File : recoder
# @Software : PyCharm
import os
AFL_SHOWMAP_BINARY_PATH = './afl-showmap'
def record_edge(testcase_dir, binary_file_path, base_cmd, save_path):
open(save_path, "w")
edge = set()
for root, dirs, files in os.walk(testcase_dir):
if root[-5:] == 'queue':
for file in files:
testcase_path = os.path.join(root, file)
cmd = f"{AFL_SHOWMAP_BINARY_PATH} -q -e -o /dev/stdout -m 512 -t 500 {binary_file_path} {base_cmd} {testcase_path}"
out = os.popen(cmd).readlines()
for o in out:
edge_item = o.split(':')[0]
edge.add(edge_item)
with open(save_path, "a") as save_file:
save_file.write(f"edge: {len(edge)}\n")
# for e in edge:
# save_file.write(f"{e}\n")
# record_edge('/home/lowry/Documents/myFuzz/MLFuzz/programs/objdump/out/',
# '/home/lowry/Documents/afl-program/objdump/objdump',
# '-D',
# './edge_cov_readelf')