ubfx / BinDiffHelper

Ghidra Extension to integrate BinDiff for function matching
258 stars 23 forks source link
bindiff ghidra ghidra-extension reverse-engineering

BinDiffHelper

Ghidra extension that uses BinDiff on your Ghidra project to find matching functions and rename them automatically (BinDiff 6, 7, 8 supported). Check out the BinDiff manual to see how it works and how it matches functions / basic blocks. However, with this extension, BinDiff is automated from within Ghidra, so you don't have to diff your binaries yourself.

Please report bugs via the issue feature on github

What it does / Changelog

v0.6

v0.5

v0.4.3

v0.4.2

v0.4.1

v0.4.0

v0.3.2

v0.3.1

v0.3

v0.2

v0.1

Next releases

How to Install

Either download the .zip-File from the release, if it's compatible to your Ghidra version, otherwise see How to build below.

  1. Open Ghidra
  2. In the Main Window: Go to File->Install Extensions...
  3. Click the +-Button in the top right and select the BinDiffHelper zip file
  4. Close the plugin manager. Restart Ghidra to load the new plugin
  5. See Usage below

Recommended other tools

Without these, you will only be able to import .BinDiff files and not automatically export and diff from your Ghidra project

Usage

Make sure the plugin is loaded in the Code Explorer by opening a file in Ghidra and in the Code Explorer go to File->Configure

Click the small plug-icon in the top right:

Configure tool

and make sure the checkbox next to BinDiffHelperPlugin is checked.

Configure plugins

Import external .BinDiff

The corresponding .BinExport-Files need to be in the same Folder.

Open the file you want to import names into in the code Browser, then go to Window->BinDiffHelper Open BinDiffHelper

Use the Open from BinDiff button or menu item and select your .BinDiff file.

Example import

Select all the function names you want to import and click the Import function names button in the top right or the menu item.

Compare between files in Ghidra project

Go to Window->BinDiffHelper, make sure there are no warnings concerning BinExport or BinDiff, then click the Open from project button.

Select the other file from the tree and click OK.

Example project import

How to build

Requirements:

Clone the repository

Recursively clone the repository, as it depends on BinExport for the respective protocol buffer definition.

git clone --recurse-submodules https://github.com/ubfx/BinDiffHelper.git

Build it

You need to set the GHIDRA_INSTALL_DIR environment variable to the Ghidra installation dir. If you have different JDKs installed, make sure the environment variable JAVA_HOME points to the one your Ghidra installation uses.

The extension will be built for that Ghidra version specifically.

And then go the BinDiffHelper folder in your shell and do

gradle

This will build both BinExport in the respective submodule and BinDiffHelper in the parent directory. There should have been a .zip-File created in the dist directory. Use that .zip File to install according to the instructions above.

Development / Debugging setup

Sometimes it's useful to be able to debug the extension together with Ghidra, here are some notes on that:

  1. Clone and build Ghidra and let gradle create eclipse projects according to the DevGuide
  2. Import the projects into eclipse (make sure it has relevant plugins for extension development)
  3. Build and install GhidraDev
  4. Unpack the Ghidra build and link GhidraDev to it. Maybe have to set GHIDRA_INSTALL_DIR environment variable
  5. Run Ghidra from eclipse and install BinExport extension
  6. Create BinDiffHelper eclipse project with gradle build eclipse
  7. Import it into eclipse and use GhidraDev to link it to the Ghidra build
  8. Debug As->Ghidra

When debugging Ghidra with the extension out of eclipse, the extension is loaded into Ghidra automatically (don't go through the usual extension install). However, the plugin has to be enabled in the Code Explorer.

References

Icons from: Fatcow free icons