BinExport is the exporter component of
BinDiff. It is a plugin/extension for
the the disassemblers IDA Pro, Binary Ninja and Ghidra that exports disassembly
data into the Protocol Buffer format that BinDiff requires.
An experimental version for the open source software reverse engineering suite
Ghidra is available in the java/BinExport directory.
This repository contains the complete source code necessary to build BinExport
plugin binaries for Linux, macOS and Windows.
Installation
IDA Pro
Download the binaries from the releases page and copy them into the IDA Pro
plugins directory. These are the default paths:
OS
Plugin path
Linux
/opt/idapro-8.2/plugins
macOS
/Applications/IDA Pro 8.2/idabin/plugins
Windows
%ProgramFiles%\IDA 8.2\plugins
To install just for the current user, copy the files into one of these
directories instead:
OS
Plugin
Linux/macOS
~/.idapro/plugins
Windows
%AppData%\Hex-Rays\IDA Pro\plugins
Verifying the installation version
In IDA, select Help|About programm...
Click Addons...
If installed correctly, the following dialog box appears:
Binary Ninja
Download the binaries from the releases page and copy them into the Binary Ninja
plugins directory. These are the default paths for the current user:
Note that this does provide any control over the output filename. BinExport
will always use the filename of the currently loaded database (without
extension) and append “.BinExport”.
IDAPython
The arguments are the same as for IDC (listed above).
Example invocation of one of the registered IDC functions:
BinExport defines the following plugin options, that can be specified on IDA’s
command line:
Option
Description
-OBinExportAutoAction:<ACTION>
Invoke a BinExport IDC function and exit
-OBinExportModule:<PARAM>
Argument for BinExportAutoAction
-OBinExportLogFile:<FILE>
Log messages to a file
-OBinExportAlsoLogToStdErr:TRUE
If specified, also log to standard error
-OBinExportX86NoReturnHeuristic:TRUE
Enable the X86-specific heuristic to identify non-returning functions
Note: These options must come before any files.
Binary Ninja
There is only minimal integration into the Binary Ninja UI at this time.
Open or create a new analysis database
Select Tools|Plugins|BinExport. This will start the export process.
The .BinExport file is placed next to the analysis database, in the same
directory.
Ghidra
Open or create a project. For new projects, import a file first using File|Import File...
Right-click a file in the current project list and select Export... from the context menu.
In the “Export” dialog, under “Format”, choose “Binary Export (v2) for BinDiff”.
Under “Output File”, enter the desired output file path. If the file extension is missing,
.BinExport will be appended automatically.
Optional: click “Options…” to set additional export options.
Click “OK”, then click “OK” again to dismiss the “Export Results Summary” dialog.
Scripting
The BinExport.java Ghidra script can be run in both headless and GUI mode. In GUI mode, it is available under the BinExport category in the Script Manager. For headless mode, a BinExport.properties file with the following content (or similar, depending on the options you want to use) can be used:
Choose export file Export = test.BinExport
Choose options IDA Pro Compatibility = "Subtract Imagebase;Remap mnemonics;Prepend Namespace to Function Names"
Alternatively, use command-line arguments instead of BinExport.properties:
$ ./analyzeHeadless <project_location> <project_name> -process <file> -preScript BinExport.java test.BinExport "Prepend Namespace to Function Names" -noanalysis
How to build
Below are build instructions for the native code plugins for IDA Pro and
Binary Ninja. To build the Java-based extension for Ghidra, please refer
to the BinExport for Ghidra instructions.
Preparing the build environment
There are quite a few dependencies to satisfy:
Boost 1.83.0 or higher (a partial copy of 1.83.0 ships in boost_parts)
Note: If you don’t want to use Ninja to perform the actual build, omit
the -G Ninja part.
To disable the IDA Pro build, set -DBINEXPORT_ENABLE_IDAPRO=OFF. Likewise, to
disable the Binary Ninja build, set -DBINEXPORT_ENABLE_BINARYNINJA=OFF.
This will download and build Abseil, GoogleTest, Protocol Buffers and the
Binary Ninja API. If all went well, the build_linux/binexport-prefix
directory should contain two the files binexport12_ida.so and
binexport12_ida64.so (for use with ida and ida64, respectively) as well
as binexport12_binaryninja.so (for Binary Ninja).
macOS
Prerequisites
The preferred build environment is macOS 13 “Ventura” using Xcode
15.1. Using macOS 12 “Monterey” should also work.
After installing the Developer Tools, make sure to install the command-line
tools as well:
sudo xcode-select --install
The following sections assume that your current working directory is at the root
of the cloned repository.
CMake
Download the latest stable version of CMake from the official site and mount its
disk image:
Note: This will use the standard CMake “Makefile Generator”. You can use XCode
or Ninja as generators as well.
To disable the IDA Pro build, set -DBINEXPORT_ENABLE_IDAPRO=OFF. Likewise, to
disable the Binary Ninja build, set -DBINEXPORT_ENABLE_BINARYNINJA=OFF.
This will download and build Abseil, GoogleTest, Protocol Buffers and the
Binary Ninja API. If all went well, the build_mac/binexport-prefix
directory should contain two the files binexport12_ida.dylib and
binexport12_ida64.dylib (for use with ida and ida64, respectively) as well
as binexport12_binaryninja.dylib (for Binary Ninja).
Windows
The preferred build environment is Windows 10 (64-bit Intel) using the Visual
Studio 2022 compiler and the Windows SDK for Windows
10.
CMake
Download and install the latest stable CMake (3.25.1 at the time of writing)
from its download page. Make sure to select
“Add CMake to the system PATH for all users”.
Git
Download and install Git from its download
page. Make sure to select the following
options: * The installation directory should be left at the default
%ProgramFiles%\Git\bin\git.exe * “Use Git from the Windows Command Prompt” -
have the setup utility add Git to your system path. * “Use Windows’ default
console window” - to be able to use Git from the regular command prompt.
Prepare
The following sections assume an open command prompt with the current working
directory located at the root of the cloned BinExport repository:
git clone https://github.com/google/binexport.git
cd binexport
IDA SDK
Unzip the contents of the IDA SDK into third_party/idasdk. Shown commands are
for IDA Pro 8.2, assuming that Git was installed into the default directory
first:
Note: This will use the CMake “Visual Studio” generator. You can use the Ninja
generator as well.
To disable the IDA Pro build, set -DBINEXPORT_ENABLE_IDAPRO=OFF. Likewise, to
disable the Binary Ninja build, set -DBINEXPORT_ENABLE_BINARYNINJA=OFF.
This will download and build Abseil, GoogleTest, Protocol Buffers and the
Binary Ninja API. If all went well, the build_msvc/binexport-prefix
directory should contain two the files binexport12_ida.dll and
binexport12_ida64.dll (for use with ida.exe and ida64.exe, respectively) as well
as binexport12_binaryninja.dll (for Binary Ninja).
BinExport
Copyright 2011-2024 Google LLC.
Disclaimer: This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.
Table of Contents
Introduction
BinExport is the exporter component of BinDiff. It is a plugin/extension for the the disassemblers IDA Pro, Binary Ninja and Ghidra that exports disassembly data into the Protocol Buffer format that BinDiff requires.
An experimental version for the open source software reverse engineering suite Ghidra is available in the
java/BinExportdirectory.This repository contains the complete source code necessary to build BinExport plugin binaries for Linux, macOS and Windows.
Installation
IDA Pro
Download the binaries from the releases page and copy them into the IDA Pro plugins directory. These are the default paths:
/opt/idapro-8.2/plugins/Applications/IDA Pro 8.2/idabin/plugins%ProgramFiles%\IDA 8.2\pluginsTo install just for the current user, copy the files into one of these directories instead:
~/.idapro/plugins%AppData%\Hex-Rays\IDA Pro\pluginsVerifying the installation version
In IDA, select
Help|About programm...Click
Addons...If installed correctly, the following dialog box appears:
Binary Ninja
Download the binaries from the releases page and copy them into the Binary Ninja plugins directory. These are the default paths for the current user:
~/.binaryninja/plugins~/Library/Application Support/Binary Ninja/plugins/%AppData%\Binary Ninja\pluginsVerifying the installation version
Lognative dock. If this is not visible, enable it viaView|Native Docks|Show Log.Ghidra
File|Install Extensions...ghidra_BinExport.zipyou downloaded in step 1 and clickOK.OKtwice to close both the “Install Extensions” dialog and the notice to restart Ghidra.Verifying the installation version
File|Install Extensions...Usage
The main use case is via BinDiff. However, BinExport can also be used to export disassembly into different formats:
IDA Pro
Open an IDA Pro database
Select
Edit|Plugins|BinExport 12The following dialog box appears:
Select the type of the file to be exported
IDC Scripting
The BinExport plugin registers the IDC functions below.
Alternatively, the plugin can be invoked from IDC by calling its main function directly:
Note that this does provide any control over the output filename. BinExport will always use the filename of the currently loaded database (without extension) and append “.BinExport”.
IDAPython
The arguments are the same as for IDC (listed above).
Example invocation of one of the registered IDC functions:
Plugin Options
BinExport defines the following plugin options, that can be specified on IDA’s command line:
-OBinExportAutoAction:<ACTION>-OBinExportModule:<PARAM>BinExportAutoAction-OBinExportLogFile:<FILE>-OBinExportAlsoLogToStdErr:TRUE-OBinExportX86NoReturnHeuristic:TRUENote: These options must come before any files.
Binary Ninja
There is only minimal integration into the Binary Ninja UI at this time.
Tools|Plugins|BinExport. This will start the export process.The
.BinExportfile is placed next to the analysis database, in the same directory.Ghidra
File|Import File...Export...from the context menu..BinExportwill be appended automatically.Scripting
The
BinExport.javaGhidra script can be run in both headless and GUI mode. In GUI mode, it is available under theBinExportcategory in the Script Manager. For headless mode, aBinExport.propertiesfile with the following content (or similar, depending on the options you want to use) can be used:Example usage in headless mode
Create a project, import and analyze a binary:
Run
BinExport.javawhich will generate the.BinExportfile specified inBinExport.properties:Alternatively, use command-line arguments instead of
BinExport.properties:How to build
Below are build instructions for the native code plugins for IDA Pro and Binary Ninja. To build the Java-based extension for Ghidra, please refer to the BinExport for Ghidra instructions.
Preparing the build environment
There are quite a few dependencies to satisfy:
boost_parts)third_party/idasdk)Linux
Prerequisites
The preferred build environment is Debian 11 (“Bullseye”).
This should install all the necessary packages:
Install the latest stable version of CMake:
The following sections assume that your current working directory is at the root of the cloned repository.
IDA SDK
Unzip the contents of the IDA SDK into
third_party/idasdk. Shown commands are for IDA Pro 8.2:Build BinExport
With all prerequisites in place, configure and build BinExport and run its tests:
Note: If you don’t want to use Ninja to perform the actual build, omit the
-G Ninjapart.To disable the IDA Pro build, set
-DBINEXPORT_ENABLE_IDAPRO=OFF. Likewise, to disable the Binary Ninja build, set-DBINEXPORT_ENABLE_BINARYNINJA=OFF.This will download and build Abseil, GoogleTest, Protocol Buffers and the Binary Ninja API. If all went well, the
build_linux/binexport-prefixdirectory should contain two the filesbinexport12_ida.soandbinexport12_ida64.so(for use withidaandida64, respectively) as well asbinexport12_binaryninja.so(for Binary Ninja).macOS
Prerequisites
The preferred build environment is macOS 13 “Ventura” using Xcode 15.1. Using macOS 12 “Monterey” should also work.
After installing the Developer Tools, make sure to install the command-line tools as well:
The following sections assume that your current working directory is at the root of the cloned repository.
CMake
Download the latest stable version of CMake from the official site and mount its disk image:
At this point you will need to review and accept CMake’s license agreement. Now install CMake:
The last command makes CMake available in the system path.
IDA SDK
Unzip the contents of the IDA SDK into
third_party/idasdk. Shown commands are for IDA Pro 8.2:Build BinExport
With all prerequisites in place, configure and build BinExport and run its tests:
Note: This will use the standard CMake “Makefile Generator”. You can use XCode or Ninja as generators as well.
To disable the IDA Pro build, set
-DBINEXPORT_ENABLE_IDAPRO=OFF. Likewise, to disable the Binary Ninja build, set-DBINEXPORT_ENABLE_BINARYNINJA=OFF.This will download and build Abseil, GoogleTest, Protocol Buffers and the Binary Ninja API. If all went well, the
build_mac/binexport-prefixdirectory should contain two the filesbinexport12_ida.dylibandbinexport12_ida64.dylib(for use withidaandida64, respectively) as well asbinexport12_binaryninja.dylib(for Binary Ninja).Windows
The preferred build environment is Windows 10 (64-bit Intel) using the Visual Studio 2022 compiler and the Windows SDK for Windows 10.
CMake
Download and install the latest stable CMake (3.25.1 at the time of writing) from its download page. Make sure to select “Add CMake to the system PATH for all users”.
Git
Download and install Git from its download page. Make sure to select the following options: * The installation directory should be left at the default
%ProgramFiles%\Git\bin\git.exe* “Use Git from the Windows Command Prompt” - have the setup utility add Git to your system path. * “Use Windows’ default console window” - to be able to use Git from the regular command prompt.Prepare
The following sections assume an open command prompt with the current working directory located at the root of the cloned BinExport repository:
IDA SDK
Unzip the contents of the IDA SDK into
third_party/idasdk. Shown commands are for IDA Pro 8.2, assuming that Git was installed into the default directory first:Build BinExport
With all prerequisites in place, configure and build BinExport:
Note: This will use the CMake “Visual Studio” generator. You can use the Ninja generator as well.
To disable the IDA Pro build, set
-DBINEXPORT_ENABLE_IDAPRO=OFF. Likewise, to disable the Binary Ninja build, set-DBINEXPORT_ENABLE_BINARYNINJA=OFF.This will download and build Abseil, GoogleTest, Protocol Buffers and the Binary Ninja API. If all went well, the
build_msvc/binexport-prefixdirectory should contain two the filesbinexport12_ida.dllandbinexport12_ida64.dll(for use withida.exeandida64.exe, respectively) as well asbinexport12_binaryninja.dll(for Binary Ninja).