quarkslab / python-binexport

Python interface for Binexport, the Bindiff export format
Apache License 2.0
14 stars 2 forks source link

Export From Ghidra #21

Open spatti33 opened 1 month ago

spatti33 commented 1 month ago

Currently, I am manually analyzing and exporting every program as a .BinExport to then use in my python script. Is there a way to automatically generate these .BinExport files without doing it manually?

patacca commented 1 month ago

Unfortunately as of right now the python-binexport CLI supports only IDA. In future we might add support for ghidra as well.

Your best solution right now would be to write your own script that does the exporting and launch it with ghidra headless mode.

for example: /path/to/ghidra/support/analyzeHeadless /path/to/project/ project-name -import /path/to/file.exe -scriptPath /path/to/script/ -postscript your_script.py

and in your_script.py you do the exporting:

from com.google.security.binexport import BinExportExporter
from java.io import File

exporter = BinExportExporter() #Binary BinExport (v2) for BinDiff
exporter.export(File(currentProgram.getName() + ".BinExport"), currentProgram, currentProgram.getMemory(), monitor)
RobinDavid commented 1 month ago

To complete @patacca anwser. We plan to add it to python-binexport but never had the time to do so.

spatti33 commented 1 month ago

Thank you for the help!

Unfortunately, I am not familiar with the com.google.security package and cant seem to use it. Could you briefly explain how to get that please?

patacca commented 1 month ago

I guess the problem is that you didn't install the BinExport ghidra plugin. You can download it here https://github.com/google/binexport/releases

Then just run the script in the headless mode like shown above and it should work.