@@ -17,7 +17,7 @@ def kill_all(process):
17
17
parent .kill ()
18
18
19
19
20
- def ATKrun (target , src_dirs , func_name = 'logic_bomb' , default_stdin_len = 10 , maxtime = 60 ):
20
+ def ATKrun (target , func_name = 'logic_bomb' , default_stdin_len = 10 , maxtime = 60 , source = None , skip = False ):
21
21
def params_list_parser (params ):
22
22
if len (params .strip ()) == 0 :
23
23
return []
@@ -36,12 +36,12 @@ def params_list_parser(params):
36
36
res .append ((var_type , var_name ))
37
37
return res
38
38
39
- cmds_tp , tp_path , prefix = target
39
+ cmds_tp , tp_path , prefix , src_dirs = target
40
40
if not os .path .exists (prefix ):
41
41
os .mkdir (prefix )
42
42
43
- if not os .path .exists ('tmp' ):
44
- os .mkdir ('tmp' )
43
+ if source and not os .path .exists (source ):
44
+ os .mkdir (source )
45
45
46
46
ERROR = 0
47
47
CORRECT = 1
@@ -93,8 +93,11 @@ def params_list_parser(params):
93
93
print (res )
94
94
res = '\n ' .join ([content , res ])
95
95
outname = file if len (file .split ('.' )) == 1 else file .split ('.' )[0 ]
96
- with open ('tmp/' + file , 'w' ) as f :
96
+ if source :
97
+ with open (os .path .join (source , file ), 'w' ) as f :
97
98
f .write (res )
99
+ if skip :
100
+ continue
98
101
if prefix == 'angr' :
99
102
cmds .append (cmds_tp [0 ] % outname )
100
103
cmds .append (cmds_tp [1 ] % (default_stdin_len , outname ))
@@ -176,17 +179,24 @@ def params_list_parser(params):
176
179
177
180
178
181
if __name__ == '__main__' :
179
- from config .test_settings import src_dirs , switches , FUNC_NAME
182
+ from config .test_settings import switches , FUNC_NAME
180
183
from collections import OrderedDict
181
184
import argparse
182
185
183
186
parser = argparse .ArgumentParser ()
184
187
parser .add_argument ("-e" , "--engine" , required = True , type = str , help = "Symbolic execution engine" )
185
- parser .add_argument ("-t" , "--maxtime" , required = True , type = int , help = "Max running time for a program" )
188
+ parser .add_argument ("-t" , "--maxtime" , required = False , default = 60 , type = int , help = "Max running time for a program" )
189
+ parser .add_argument ("-s" , "--source" , required = False , type = str , help = "Output source code into a directory" )
190
+ parser .add_argument ("-n" , "--no_test" , action = "store_true" , help = "Don't do the test" )
186
191
args = parser .parse_args ()
192
+
193
+ if args .source :
194
+ print ("Saving output results in " , args .source )
187
195
188
196
try :
189
- res = ATKrun (switches [args .engine ], src_dirs , func_name = FUNC_NAME , maxtime = args .maxtime )
197
+ res = ATKrun (switches [args .engine ], func_name = FUNC_NAME , maxtime = args .maxtime , source = args .source , skip = args .no_test )
198
+ if args .source and args .no_test :
199
+ exit (0 )
190
200
except KeyError :
191
201
print ('Invalid symbolic engine!' )
192
202
exit (1 )
0 commit comments