google / binexport

Export disassemblies into Protocol Buffers
Apache License 2.0
1.05k stars 204 forks source link

BinExport for Ghidra, null pointer exception during export #62

Closed morsisko closed 3 years ago

morsisko commented 4 years ago

Hello, I encounter a bug during testing the BinExport addon for Ghidra. For now it only happens for one particular file.

Steps to reproduce:

  1. Go into Ghidra CodeBrowser
  2. File -> Export program...
  3. Set Format to Binary BinExport (v2) for BinDiff
  4. Press OK

Snip from logs

ERROR | (ExporterDialog) Exception exporting java.lang.NullPointerException
-- | --
  | at com.google.security.binexport.BinExport2Builder.buildFlowGraphs(BinExport2Builder.java:284)
  | at com.google.security.binexport.BinExport2Builder.build(BinExport2Builder.java:512)
  | at com.google.security.binexport.BinExportExporter.export(BinExportExporter.java:93)
  | at ghidra.app.plugin.core.exporter.ExporterDialog.tryExport(ExporterDialog.java:470)
  | at ghidra.app.plugin.core.exporter.ExporterDialog.lambda$doExport$8(ExporterDialog.java:445)
  | at ghidra.util.task.TaskLauncher$2.run(TaskLauncher.java:119)
  | at ghidra.util.task.Task.monitoredRun(Task.java:126)
  | at ghidra.util.task.TaskRunner.lambda$startTaskThread$1(TaskRunner.java:94)
  | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
  | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
  | at java.base/java.lang.Thread.run(Thread.java:834)

This happens for the newest version in the repository. I built it Aug 20 directly from source.

cblichmann commented 4 years ago

Hey there,

Thank you for your report. Is it possible to share the binary for which this happens?

Looking at the code, a NullPointerException at that line can only happen if basicBlockIndices is null. Given how buildFlowGraphs() is called, this should never happen, as basicBlockIndices is constructed right before. Were there any changes in your working copy?

morsisko commented 4 years ago

I didn't change anything in the source, and the line BinExport2Bulder.java:284 is exactly the same in my \Ghidra\Extensions\BinExport\lib\BinExport-src.zip\ directory.

The executable that caused the exception was Wireshark (https://www.wireshark.org/) binary from my Ubuntu. This is the file: https://mega.nz/file/9ZVWiayT#k0QIV4gIC_Td2skL1C5SHVu9ljWsgsOBHZ26pgaAghw

cblichmann commented 3 years ago

As of Ghidra 9.2.3 and b5a4231a0fdb10a19d65a49d8f773d0ab5a4eedd, the export works as intended: originalWIRE.BinExport.zip