Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IDA Plugin] UnicodeEncodeError + edited config should be validated #109

Open
DarkaMaul opened this issue Mar 23, 2020 · 3 comments
Open

Comments

@DarkaMaul
Copy link

Hello,

When launching an analysis/saving a config on a file which path contains non-ascii characters, the plugin crash with the following stacktrace:

Traceback (most recent call last):
  File "[...]/idabincat/gui.py", line 798, in launch_analysis
    self._save_config("(last used)")
  File "[...]/idabincat/gui.py", line 937, in _save_config
    self.s.configurations[config_name] = self.s.edit_config
  File "[...]/idabincat/analyzer_conf.py", line 882, in wrap
    f(self, *args, **kwargs)
  File "[...]/idabincat/analyzer_conf.py", line 929, in __setitem__
    self._configs[name] = str(config)
  File "[...]/idabincat/analyzer_conf.py", line 691, in __str__
    self._config.write(sio)
  File "/usr/lib/python2.7/ConfigParser.py", line 412, in write
    key = " = ".join((key, str(value).replace('\n', '\n\t')))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 15: ordinal not in range(128)

Steps to reproduce

  1. Launch IDA with a file in a directory with non ascii characters (e.g ~/Téléchargements/prog)
  2. Launch BinCat plugin
  3. Go to configuration panel and try to save the config

Using last stable version of the plugin (1.1)

@trou
Copy link
Collaborator

trou commented Mar 24, 2020

Hello,
thanks for the report. Which version of IDA are you using ? on which OS ?

@DarkaMaul
Copy link
Author

I'm using IDA 7.2 on Linux.
However, after more research I think the bug comes from ConfigParser in itself ( Python #11597 )

There is also another problem when the configuration is edited using the "Edit button" in the GUI. The result string is saved "as-if" in the AnalyzerConfig object, without passing any validations sets by the different setters for the fields.

I guess the following snippet explains it better:

    def validate_config(self, config):
        # A mapping of config fields => setter names
        translator = {'cut': 'stop_address', 
                      'analysis': 'analysis_method', 
                      'filepath': 'binary_filepath',
                      'headers': 'headers_files',
                      'analysis_ep': 'analysis_ep',
                      'in_marshalled_cfa_file': 'in_marshalled_cfa_file',
                      'format': 'format'}

        for section in config.sections():
            self._config.add_section(section)
            for item, value in config.items(section):
                if item in translator:
                    setattr(self, translator.get(item), value)
                else:
                    self._config.set(section, item, value)

Note : this does not solve this issue but would solve others (e.g if you change the start address in the config edit-panel to a non hex-represented value)

@trou
Copy link
Collaborator

trou commented Mar 26, 2020

Regarding the encoding problem, it seems I cannot trigger it with the current master.

i'll check the other issue later.

@trou trou changed the title [IDA Plugin] UnicodeEncodeError [IDA Plugin] UnicodeEncodeError + edited config should be validated Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants