When running capa against shellcode using the Binary Ninja backend, I encountered an error related to an unexpected file format. The analysis fails, preventing capa from assessing shellcode capabilities as expected.
Steps to Reproduce
Run capa on shellcode using Binary Ninja as a backend with the following command:
capa.exe -r C:\Tools\capa-rules -f sc64 sc.bin -b binja -d
Expected behavior:
capa should analyze the shellcode file and report any detected capabilities based on the specified rules.
Actual behavior:
The above command produces the following error:
File "C:\Users\<USER>\AppData\Local\Programs\Python\Python311\Lib\site-packages\capa\features\extractors\binja\file.py", line 174, in extract_file_format
raise NotImplementedError(f"unexpected file format: {view_type}")
NotImplementedError: unexpected file format: Mapped
Description
When running capa against shellcode using the Binary Ninja backend, I encountered an error related to an unexpected file format. The analysis fails, preventing capa from assessing shellcode capabilities as expected.
Steps to Reproduce
Run capa on shellcode using Binary Ninja as a backend with the following command:
capa.exe -r C:\Tools\capa-rules -f sc64 sc.bin -b binja -d
Expected behavior: capa should analyze the shellcode file and report any detected capabilities based on the specified rules.
Actual behavior: The above command produces the following error:
Versions
capa version: 7.3.0 Installed as: Python library Backend: Binary Ninja 4.1.5902
Potential solution:
To work around this issue, I modified the file file.py in the Binary Ninja extractor by changing the line:
elif view_type == "Raw":
toelif view_type == "Mapped":
within the
extract_file_format
function. After this change, capa ran successfully and produced the expected results.