-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_afl_vec
executable file
·47 lines (43 loc) · 1.08 KB
/
get_afl_vec
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
#!/usr/bin/env python2.7
import tempfile
import numpy as np
import subprocess
import argparse
import json
import sys
import os
AFL_COMMAND = 'afl-showmap -q -t 2000000 -m 15032123396 -o %s -- %s < %s'
class GetMap(object):
def __init__(self, p):
self.p = p
def __call__(self, x):
f = tempfile.NamedTemporaryFile(delete=False)
nm = f.name
f.close()
rv = subprocess.call(AFL_COMMAND % (nm, self.p, x), shell=True)
u = open(nm, 'r')
buf = u.read()
u.close()
os.remove(nm)
return (x,buf,rv)
def main(args):
infile,m,rv = GetMap(args.program)(args.file)
maps_as_dicts = []
dmap = {}
for l in m.split("\n"):
lu = l.strip().rstrip()
if len(lu) > 0:
a,b = lu.split(":")
dmap[str(a)] = int(b)
dmap['xxxxx'] = rv
umap = {}
umap['file'] = args.file
umap['tuples'] = dmap
print json.dumps(umap)
return 0
if __name__ == '__main__':
parser = argparse.ArgumentParser("getstacks")
parser.add_argument("program", type=str)
parser.add_argument("file", type=str, help="input file")
args = parser.parse_args()
sys.exit(main(args))