-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyzer.py
42 lines (35 loc) · 1.48 KB
/
analyzer.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
#!/usr/bin/env python2
## -*- coding: utf-8 -*-
import heapq
import pickle
import subprocess
class Seed:
def __init__(self, model = None, bound = 0):
self.model = model if model else {}
self.bound = bound
FILE_PATH = "/media/sf_SharedFolder/Generational-Search/"
SAMPLE_PATH = "/media/sf_SharedFolder/Generational-Search/example1.out "
workList = [[0, Seed({0: 'g', 1: 'o', 2: 'o', 3: 'd', 4: chr(0)}, 0)]]
def search():
global workList
with open(FILE_PATH + "worklist.pkl", "wb") as data:
pickle.dump(workList, data)
while len(workList) > 0:
seed = heapq.heappop(workList)[1]
subprocess.check_call("~/triton/pin-2.14-71313-gcc.4.4.7-linux/source/tools/Triton/build/triton /media/sf_SharedFolder/Generational-Search/concolic.py " + SAMPLE_PATH + ''.join(seed.model.values()[:-1]), shell = True)
with open(FILE_PATH + "childlist.pkl", "rb") as data:
childs = pickle.load(data)
while len(childs) > 0:
newSeed = childs.pop()
heapq.heappush(workList, [-score(newSeed), newSeed])
for i in workList:
print(i[0], i[1].model)
with open(FILE_PATH + "worklist.pkl", "wb") as data:
pickle.dump(workList, data)
def score(newSeed):
score = int(subprocess.check_output("~/triton/pin-2.14-71313-gcc.4.4.7-linux/source/tools/Triton/build/triton /media/sf_SharedFolder/Generational-Search/score.py " + SAMPLE_PATH + ''.join(newSeed.model.values()[:-1]), shell = True).strip())
return score
def main():
search()
if __name__ == "__main__":
main()