@@ -66,23 +66,27 @@ def _to_showmap_options(args, trace_name = '-'):
6666 if args .static_instr :
6767 r .append ('-Y' )
6868 else :
69- r .extend (['-D' , args .dynamorio_dir ])
70- r .append ('--' )
71- r .extend (['-target_module' , args .target_module ])
69+ if args .tinyinst_instr :
70+ r .append ('-y' )
71+ r .append ('--' )
72+ for mod in args .instrument_modules :
73+ r .extend (['-instrument_module' , mod ])
74+ else :
75+ r .extend (['-D' , args .dynamorio_dir ])
76+ r .append ('--' )
77+ for mod in args .coverage_modules :
78+ r .extend (['-coverage_module' , mod ])
7279
80+ r .extend (['-target_module' , args .target_module ])
7381 if args .target_method is None :
7482 r .extend (['-target_offset' , '0x%x' % args .target_offset ])
7583 else :
7684 r .extend (['-target_method' , args .target_method ])
77-
7885 r .extend (['-nargs' , '%d' % args .nargs ])
7986 r .extend (['-covtype' , args .covtype ])
8087 if args .call_convention is not None :
8188 r .extend (['-call_convention' , args .call_convention ])
8289
83- for mod in args .coverage_modules :
84- r .extend (['-coverage_module' , mod ])
85-
8690 r .append ('--' )
8791 r .extend (args .target_cmdline )
8892 return r
@@ -179,6 +183,9 @@ def setup_argparse():
179183
180184 * Typical use with static instrumentation
181185 winafl-cmin.py -Y -t 100000 -i in -o minset -- test.instr.exe @@
186+
187+ * Typical use with TinyInst mode instrumentation
188+ winafl-cmin.py -y -t 100000 -i in -o minset -instrument_module m.dll -target_module test.exe -target_method fuzz -nargs 2 -- test.exe @@
182189 '''
183190 ), 100 , replace_whitespace = False ))
184191 )
@@ -227,6 +234,26 @@ def setup_argparse():
227234 metavar = 'dir' , help = 'directory containing DynamoRIO binaries (drrun, drconfig)'
228235 )
229236
237+ instr_type .add_argument (
238+ '-y' , '--tinyinst_instr' , action = 'store_true' ,
239+ help = 'use the TinyInst instrumentation mode'
240+ )
241+
242+
243+ instr_module = group .add_mutually_exclusive_group (required = True )
244+ instr_module .add_argument (
245+ '-coverage_module' , dest = 'coverage_modules' , default = None ,
246+ action = 'append' , metavar = 'module' , help = 'module for which to record coverage.'
247+ ' Multiple module flags are supported'
248+ )
249+
250+ instr_module .add_argument (
251+ '-instrument_module' , dest = 'instrument_modules' , default = None ,
252+ action = 'append' , metavar = 'module' , help = 'module for which to record coverage.'
253+ ' Multiple module flags are supported'
254+ )
255+
256+
230257 group .add_argument (
231258 '-covtype' , choices = ('edge' , 'bb' ), default = 'bb' ,
232259 help = 'the type of coverage being recorded (defaults to bb)'
@@ -235,15 +262,12 @@ def setup_argparse():
235262 '-call_convention' , choices = ('stdcall' , 'fastcall' , 'thiscall' , 'ms64' ),
236263 default = 'stdcall' , help = 'the calling convention of the target_method'
237264 )
238- group .add_argument (
239- '-coverage_module' , dest = 'coverage_modules' , default = None ,
240- action = 'append' , metavar = 'module' , help = 'module for which to record coverage.'
241- ' Multiple module flags are supported'
242- )
265+
243266 group .add_argument (
244267 '-target_module' , default = None , metavar = 'module' ,
245268 help = 'module which contains the target function to be fuzzed'
246269 )
270+
247271 group .add_argument (
248272 '-nargs' , type = int , default = None , metavar = 'nargs' ,
249273 help = 'number of arguments the fuzzed method takes. This is used to save/restore'
@@ -261,6 +285,7 @@ def setup_argparse():
261285 help = 'offset of the method to fuzz from the start of the module'
262286 )
263287
288+
264289 group = parser .add_argument_group ('execution control settings' )
265290 group .add_argument (
266291 '-t' , '--time-limit' , type = int , default = 0 ,
@@ -370,35 +395,44 @@ def validate_args(args):
370395 return False
371396
372397 if not args .static_instr :
373- # Make sure we have all the arguments we need
374- if len (args .coverage_modules ) == 0 :
375- logging .error (
376- '[!] -coverage_module is a required option to use'
377- 'the dynamic instrumentation'
378- )
379- return False
380-
381398 if None in [args .target_module , args .nargs ]:
382- logging .error (
383- '[!] , -target_module and -nargs are required'
384- ' options to use the dynamic instrumentation mode.'
385- )
386- return False
387-
399+ logging .error (
400+ '[!] , -target_module and -nargs are required'
401+ ' options to use the dynamic instrumentation mode.'
402+ )
403+ return False
404+
388405 if args .target_method is None and args .target_offset is None :
389406 logging .error (
390407 '[!] -target_method or -target_offset is required to use the'
391408 ' dynamic instrumentation mode'
392409 )
393410 return False
411+
412+ if not args .tinyinst_instr :
413+ # Make sure we have all the arguments we need
414+ if len (args .coverage_modules ) == 0 :
415+ logging .error (
416+ '[!] -coverage_module is a required option to use'
417+ 'the dynamic instrumentation'
418+ )
419+ return False
394420
395- # If we are using DRIO, one of the thing we need is the DRIO client
396- winafl_path = os .path .join (args .working_dir , 'winafl.dll' )
397- if not os .path .isfile (winafl_path ):
398- logging .error (
399- '[!] winafl.dll needs to be in %s.' , args .working_dir
400- )
401- return False
421+ # If we are using DRIO, one of the thing we need is the DRIO client
422+ winafl_path = os .path .join (args .working_dir , 'winafl.dll' )
423+ if not os .path .isfile (winafl_path ):
424+ logging .error (
425+ '[!] winafl.dll needs to be in %s.' , args .working_dir
426+ )
427+ return False
428+ else :
429+ # Make sure we have all the arguments we need
430+ if len (args .instrument_modules ) == 0 :
431+ logging .error (
432+ '[!] -instrument_module is a required option to use'
433+ 'the dynamic instrumentation'
434+ )
435+ return False
402436
403437 if args .file_read is not None and '@@' not in args .file_read :
404438 # When a particular input file is specified, first
0 commit comments