ivision-research / binjawa

A Binary Ninja plugin for WebAssembly.
MIT License
11 stars 2 forks source link

Failed to initialize: list index out of range #1

Open CoffeeFlux opened 3 years ago

CoffeeFlux commented 3 years ago

First, thanks for making the plugin! This would be a great addition to binja.

Attempting to load a wasm file results in the stack trace below:

Traceback (most recent call last):
  File "/Applications/Binary Ninja.app/Contents/MacOS/plugins/../../Resources/python/binaryninja/binaryview.py", line 2164, in _init
    return self.init()
  File "/Users/ryan/Library/Application Support/Binary Ninja/plugins/binjawa/binaryview.py", line 34, in init
    wasm_module = from_bytes(wasm_bytes)
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/wasamole/io/__init__.py", line 9, in from_bytes
    return BinaryReader.from_bytes(the_bytes).read()
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/wasamole/io/reader/binary_format.py", line 56, in read
    self._read_section()
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/wasamole/io/reader/binary_format.py", line 83, in _read_section
    type_read_map[section_type](section_size)
  File "/usr/local/Cellar/python@3.9/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/wasamole/io/reader/binary_format.py", line 96, in _read_custom
    self.module.functions[name_i].set_name(function_name)
IndexError: list index out of range
BinaryView of type 'WASM' failed to initialize!

I can't seem to upload the file itself to the Github issue, but if you give me an email I can send it your way.

meadori-cs commented 3 years ago

Thank you for the report @CoffeeFlux ! I will be happy to take a look.

Did you try to attach the binary or text for of WASM? if binary, then maybe try converting it to text form with a .txt extension?

CoffeeFlux commented 3 years ago

Unfortunately, it's around 40MB in text form. It also seems that disassembling and reassembling actually results in the file not producing the same error, though it still seems to run into issues.

This link should hopefully work, though I'm not sure how long it will stay alive: https://pomf.lain.la/f/3krt3xg2.wasm