Question

I'm working with a pice of software written in python from US CERT to do some fuzzing. Included in the software is a minimizer.py tool which is designed to be ran against certain test cases that cause crashes in order to determine exactly which byte mutations are causing the crash.

However when attempting to run the tool it's spitting an error at me. Google searches for both the tool and the error are drawing a blank. Attempting to troubleshoot it myself with limited python experience is not helping either. Any ideas on whats causing the error so I can fix it and get the tool working?

command line options being used are: minimizer.py --stringmode

The error output is as follows:

Traceback (most recent call last):
File "C:\FOE2\tools\minimize.py", line 234, in <module>
main()
File "C:\FOE2\tools\minimize.py", line 183, in main
config = Config(cfg_file).config
File "C:\FOE2\certfuzz\campaign\config\__init__.py", line 76, in __init__
self._set_derived_options()
File "C:\FOE2\certfuzz\campaign\config\foe_config.py", line 93, in _set_derived_options
t = Template(self.config['target']['cmdline_template'])
TypeError: 'NoneType' object has no attribute '__getitem__'

Segments of code from both of the files in last two lines of error are:

__init__.py:

 def __init__(self, config_file):
    self.file = config_file
    self.config = None

    self.load()
    self._set_derived_options()

    self.validations = []
    self._add_validations()
    self.validate()

def _set_derived_options(self):
    pass

And then from foe_config_.py (added the preceding lines of code just in case they are relevant.):

class Config(ConfigBase):
  def _add_validations(self):
    self.validations.append(self._validate_debugger_timeout_exceeds_runner)

  def _set_derived_options(self):
    # interpolate program name
    # add quotes around $SEEDFILE
    t = Template(self.config['target']['cmdline_template'])
    #self.config['target']['cmdline_template'] = t.safe_substitute(PROGRAM=self.config['target']['program'])
    self.config['target']['cmdline_template'] = t.safe_substitute(PROGRAM=quoted(self.config['target']['program']), SEEDFILE=quoted('$SEEDFILE'))
Was it helpful?

Solution

It's hard to tell from the code you posted, but it looks like __init__ sets self.config to None. Then it calls _set_derived_options which uses self.config here:

t = Template(self.config['target']['cmdline_template'])

But self.config hasn't changed from being None. You wouldn't expect None['target'] to give you anything (other than an Exception), but I think that is essentially what you're doing here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top