-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbolic_slave.py
116 lines (85 loc) · 2.66 KB
/
symbolic_slave.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import sys
import queue
import re
import signal
import subprocess
import time
import gc
import daemon
import ntpath
from multiprocessing.managers import BaseManager
import analyzer_maat
import compiler
import os.path
from os import path
from anytree import Node, RenderTree
import symbolic_master
def scanned(file):
if not path.os.path.exists(os.path.join(root, "maatrunning.log")):
return False
f = open(os.path.join(root, "maatrunning.log"), "r")
for line in f:
if file in line:
print("Scanned:"+file)
return True
return False
def handler(signum, stack):
raise Exception
index = 0
resultlist = []
root="./Bins/"
#levels = ["-O3","-Os","-Og","-O2","-O1","-O0"]
# ,"-O2","-O3","-Os","-Og"
def is_timeout(file):
if not path.os.path.exists(os.path.join(root, "timeout.log")):
return False
f = open(os.path.join(root, "timeout.log"), "r")
for line in f:
if file in line:
print("timeout:"+file)
return True
return False
def main_body():
print("Flag Slave")
class QueueManager(BaseManager):
pass
QueueManager.register("get_task_queue")
QueueManager.register("get_result_queue")
server_addr = '127.0.0.1'
print('Connect to server %s...' % server_addr)
m = QueueManager(address=(server_addr, 5000), authkey=b'abc')
m.connect()
task = m.get_task_queue()
result = m.get_result_queue()
while True:
try:
cfile=task.get(timeout=60*60*2)
print(cfile)
for r, d, f in os.walk(cfile):
for file in f:
if not file.endswith(".bin"):
continue
if "-fno-" in file:
continue
if scanned(file):
continue
try:
print(os.path.join(r, file))
signal.signal(signal.SIGALRM, handler)
signal.alarm(60*10)
gc.collect()
analyzer_maat.explore_one_pair(os.path.join(r, file), analyzer_maat.EXPLORATION)
analyzer_maat.explore_one_pair(os.path.join(r, file), analyzer_maat.TRACEING)
except Exception as e:
print(e)
continue
result.put("name="+cfile)
except BrokenPipeError:
print("finished")
break
except Exception as e:
print(e)
continue
if __name__ == "__main__":
with daemon.DaemonContext():
main_body()