An IDA Pro plugin for exporting disassemblies into Protocol Buffers and to BinNavi databases
Switch branches/tags
Nothing to show
Clone or download
cblichmann Fix binexport_reader_test linker error
Signed-off-by: Christian Blichmann <cblichmann@google.com>
Latest commit bfefa9c Oct 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cmake Sync with internal codebase Oct 18, 2018
doc Version 10 for IDA 7.0 (64-bit) Dec 14, 2017
ida Sync with internal codebase Oct 18, 2018
reader Sync with internal codebase Oct 18, 2018
stubs Sync with internal codebase Oct 18, 2018
third_party Sync with internal codebase Oct 18, 2018
tools Sync with internal codebase Oct 18, 2018
util Sync with internal codebase Oct 18, 2018
.gitignore Sync with internal codebase Oct 18, 2018
.travis.yml Version 10 for IDA 7.0 (64-bit) Dec 14, 2017
CMakeLists.txt Fix binexport_reader_test linker error Oct 19, 2018
CONTRIBUTING.md Initial code drop for open source BinExport. Mar 8, 2016
FindIdaSdk.cmake Sync with internal codebase Oct 18, 2018
LICENSE Initial code drop for open source BinExport. Mar 8, 2016
README.md Sync with internal codebase Oct 18, 2018
absl.cmake Sync with internal codebase Oct 18, 2018
address_references.cc Sync with internal codebase Oct 18, 2018
address_references.h Sync with internal codebase Oct 18, 2018
appveyor.yml Sync with internal codebase Mar 3, 2017
architectures.h Sync with internal codebase Oct 18, 2018
base_types.cc Sync with internal codebase Oct 18, 2018
base_types.h Sync with internal codebase Oct 18, 2018
basic_block.cc Sync with internal codebase Oct 18, 2018
basic_block.h Sync with internal codebase Oct 18, 2018
binexport.cc Sync with internal codebase Oct 18, 2018
binexport.h Sync with internal codebase Oct 18, 2018
binexport.idc Initial code drop for open source BinExport. Mar 8, 2016
binexport2.proto Sync with internal codebase Oct 18, 2018
binexport2_writer.cc Sync with internal codebase Oct 18, 2018
binexport2_writer.h Sync with internal codebase Oct 18, 2018
binexport_test.cc Sync with internal codebase Oct 18, 2018
call_graph.cc Sync with internal codebase Oct 18, 2018
call_graph.h Sync with internal codebase Oct 18, 2018
comment.cc Sync with internal codebase Oct 18, 2018
comment.h Sync with internal codebase Oct 18, 2018
copts.cmake Sync with internal codebase Oct 18, 2018
database_writer.cc Sync with internal codebase Oct 18, 2018
database_writer.h Sync with internal codebase Oct 18, 2018
dump_writer.cc Sync with internal codebase Oct 18, 2018
dump_writer.h Sync with internal codebase Oct 18, 2018
edge.cc Sync with internal codebase Oct 18, 2018
edge.h Sync with internal codebase Oct 18, 2018
entry_point.cc Sync with internal codebase Oct 18, 2018
entry_point.h Sync with internal codebase Oct 18, 2018
expression.cc Sync with internal codebase Oct 18, 2018
expression.h Sync with internal codebase Oct 18, 2018
flow_analyzer.cc Sync with internal codebase Oct 18, 2018
flow_analyzer.h Sync with internal codebase Oct 18, 2018
flow_graph.cc Sync with internal codebase Oct 18, 2018
flow_graph.h Sync with internal codebase Oct 18, 2018
function.cc Sync with internal codebase Oct 18, 2018
function.h Sync with internal codebase Oct 18, 2018
googletest.cmake Sync with internal codebase Oct 18, 2018
hash.cc Sync with internal codebase Oct 18, 2018
hash.h Sync with internal codebase Oct 18, 2018
initialize_constraints_postgresql_sql.h Sync with internal codebase Oct 18, 2018
initialize_indices_postgresql_sql.h Sync with internal codebase Oct 18, 2018
initialize_tables_postgresql_sql.h Sync with internal codebase Oct 18, 2018
instruction.cc Sync with internal codebase Oct 18, 2018
instruction.h Sync with internal codebase Oct 18, 2018
library_manager.cc Sync with internal codebase Oct 18, 2018
library_manager.h Sync with internal codebase Oct 18, 2018
maintenance_postgresql_sql.h Sync with internal codebase Oct 18, 2018
nested_iterator.h Sync with internal codebase Oct 18, 2018
operand.cc Sync with internal codebase Oct 18, 2018
operand.h Sync with internal codebase Oct 18, 2018
postgresql.cc Sync with internal codebase Oct 18, 2018
postgresql.h Sync with internal codebase Oct 18, 2018
query_builder.cc Sync with internal codebase Oct 18, 2018
query_builder.h Sync with internal codebase Oct 18, 2018
range.h Sync with internal codebase Oct 18, 2018
statistics_writer.cc Sync with internal codebase Oct 18, 2018
statistics_writer.h Sync with internal codebase Oct 18, 2018
type_system.cc Sync with internal codebase Oct 18, 2018
type_system.h Sync with internal codebase Oct 18, 2018
types.h Sync with internal codebase Oct 18, 2018
types_container.h Sync with internal codebase Oct 18, 2018
util.cmake Sync with internal codebase Oct 18, 2018
version.h.in Sync with internal codebase Oct 18, 2018
virtual_memory.cc Sync with internal codebase Oct 18, 2018
virtual_memory.h Sync with internal codebase Oct 18, 2018
virtual_memory_test.cc Sync with internal codebase Oct 18, 2018
writer.h Sync with internal codebase Oct 18, 2018
x86_nop.cc Sync with internal codebase Oct 18, 2018
x86_nop.h Sync with internal codebase Oct 18, 2018

README.md

BinExport Build Status Coverity Scan Build Status

Copyright 2011-2018 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 the BinNavi project as well as BinDiff. It is a plugin for the commercial IDA Pro disassembler and exports disassemblies into the PostgreSQL database format that BinNavi requires.

This repository contains the complete source code necessary to build the IDA Pro plugin for Linux, macOS and Windows.

Installation

Download the binaries from the release page and copy them into the IDA Pro plugins directory. These are the default paths:

OS Plugin path
Linux /opt/ida-7.0/plugins
macOS /Applications/IDA Pro 7.0/idabin/plugins
Windows %ProgramFiles(x86)%\IDA 7.0\plugins

To install just for the current user, copy the files into one of these directories instead:

OS Plugin path
Linux/macOS ~/.idapro/plugins
Windows %AppData%\Hex-Rays\IDA Pro\plugins

Usage

The main use case is via BinNavi. However, BinExport can also be used to export IDA Pro disassembly to files of various formats:

  • Protocol Buffer based full export
  • Statistics text file
  • Text format for debugging
  • BinNavi database export into a PostgreSQL database

Verifying the installation version

  1. In IDA, select Help|About programm...

  2. Click Addons...

  3. If installed correctly, the following dialog box appears:

    IDA addons dialog

Invocation

Via the UI

  1. Open an IDB

  2. Select Edit|Plugins|BinExport 10

  3. The following dialog box appears:

    BinExport plugin dialog

  4. Select the type of the file to be exported

Note: There is no UI for the database export.

IDC Scripting

The BinExport plugin registers the IDC functions below. The function names are versioned in order to support side-by-side installation of different versions (i.e. BinDiff's BinExport 8).

IDC Function name Exports to Arguments
BinExportSql PostgreSQL database host, port, database, schema, user, password
BinExportDiff Protocol Buffer filename
BinExportText Text file dump filename
BinExportStatistics Statistics text file filename

BinExport also supports exporting to a database via the RunPlugin() IDC function:

static main() {
  Batch(0);
  Wait();
  RunPlugin("binexport10", 1);
  Exit(0);
}

Use the plugin options listed below to setup the database connection in that case. See also the CBinExportImporter class in BinNavi.

IDAPython

The option flags are the same as IDC (listed above).

import idaapi
idc_lang = idaapi.find_extlang_by_name("idc")
idaapi.run_statements(
    'BinExportSql("{}", {}, "{}", "{}", "{}", "{}")'.format(
        "host", 5432, "database", "public", "user", "pass"), idc_lang)

Plugin Options

BinExport defines the following plugin options, that can be specified on IDA's command line:

Option Description
-OBinExportHost:<HOST> Database server to connect to
-OBinExportPort:<PORT> Port to connect to. PostgreSQL default is 5432.
-OBinExportUser:<USER> User name
-OBinExportPassword:<PASS> Password
-OBinExportDatabase:<DB> Database to use
-OBinExportSchema:<SCHEMA> Database schema. BinNavi only uses "public".
-OBinExportLogFile:<FILE> Log messages to a file
-OBinExportAlsoLogToStdErr:TRUE If specified, also log to standard error

Note that these options must come before any files.

How to build

Preparing the build environment

As we support exporting into PostgreSQL databases as well as a Protocol Buffer based format, there are quite a few dependencies to satisfy:

  • Boost 1.61.0 or higher (a partial copy of 1.61.0 ships in third_party/boost_parts)
  • CMake 3.7.2 or higher
  • GCC 4.8 or a recent version of Clang on Linux/macOS. On Windows, use the Visual Studio 2017 compiler and the Windows SDK for Windows 10. Earlier Visual Studio 2015 and Windows 8.1 SDK will also work.
  • Git 1.8 or higher
  • IDA SDK 7.0 (unpack into third_party/idasdk)
  • OpenSSL 1.0.2 or higher
  • Perl 5.6 or higher (needed for OpenSSL and PostgreSQL)
  • PostgreSQL client libraries 9.3 or higher
  • Protocol Buffers 3.0.0 or higher

Linux

Prerequisites

The preferred build environment is Ubuntu 14.04 LTS (64-bit Intel). Debian Testing (version 10, "Buster") is also supported.

This should install all the necessary packages:

sudo apt update -qq
sudo apt install -qq --no-install-recommends build-essential 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 7.0:

unzip PATH/TO/idasdk70.zip -d third_party/idasdk
mv third_party/idasdk/idasdk70/* third_party/idasdk
rmdir third_party/idasdk/idasdk70

Build BinExport

With all prerequisites in place, configure and build BinExport:

mkdir -p build_linux && cd build_linux
cmake ../cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_RULE_MESSAGES=OFF \
    -DIdaSdk_ROOT_DIR=$PWD/../third_party/idasdk
cmake --build .

This will download and build OpenSSL, Protocol Buffers and the PostgreSQL client libraries. If all went well, the build_linux/binexport-prefix directory should contain two IDA plugin binaries binexport10.so and binexport1064.so for use with ida and ida64, respectively.

macOS

Prerequisites

The preferred build environment is Mac OS X 10.12 "Sierra" (64-bit Intel) using Xcode 8.1. Using macOS 10.13 "High Sierra" should also work.

After installing the Developer Tools, make sure to install the command-line tools:

sudo xcode-select --install

Recent versions of the Developer Tools no longer include GNU Autotools, which is required by the PostgreSQL dependency. You can install Autotools via Homebrew (recommended) or via MacPorts. Follow the installation instructions on the respective websites.

For Homebrew:

brew install autoconf automake libtool

For MacPorts:

sudo /opt/local/bin/port install autoconf automake libtool

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:

curl -L https://cmake.org/files/v3.7/cmake-3.7.2-Darwin-x86_64.dmg \
    -o $HOME/Downloads/cmake-osx.dmg
hdiutil attach $HOME/Downloads/cmake-osx.dmg

At this point you will need to review and accept CMake's license agreement. Now install CMake:

sudo cp -Rf /Volumes/cmake-3.7.2-Darwin-x86_64/CMake.app /Applications/
hdiutil detach /Volumes/cmake-3.7.2-Darwin-x86_64
sudo /Applications/CMake.app/Contents/bin/cmake-gui --install

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 7.0:

unzip PATH/TO/idasdk70.zip -d third_party/idasdk
mv third_party/idasdk/idasdk70/* third_party/idasdk
rmdir third_party/idasdk/idasdk70

Build BinExport

With all prerequisites in place, configure and build BinExport:

mkdir -p build_mac && cd build_mac
cmake ../cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_RULE_MESSAGES=OFF \
    -DIdaSdk_ROOT_DIR=$PWD/../third_party/idasdk
cmake --build .

This will download and build OpenSSL, Protocol Buffers and the PostgreSQL client libraries. If all went well, the build_mac/binexport-prefix directory should contain two IDA plugin binaries binexport10.dylib and binexport1064.dylib for use with ida and ida64, respectively.

Windows

The preferred build environment is Windows 10 (64-bit Intel) using the Visual Studio 2017 compiler and the Windows SDK for Windows 10. The previous Visual Studio 2015 and earlier versions of Windows also work.

CMake

Download and install CMake 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.

Perl

Download and install ActiveState Perl from its download page. This should add Perl to the system path.

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 7.0, assuming that Git was installed into the default directory first:

"%ProgramFiles%\Git\usr\bin\unzip" PATH\TO\idasdk70.zip -d third_party
rename third_party\idasdk70 idasdk

Build BinExport

With all prerequisites in place, configure and build BinExport:

if not exist build_msvc mkdir build_msvc
cd build_msvc
cmake ../cmake -DIdaSdk_ROOT_DIR=%cd%\..\third_party\idasdk ^
    -G "Visual Studio 15 2017 Win64"
cmake --build . --config Release --install -- /clp:NoSummary;ForceNoAlign /v:minimal

For Visual Studio 2015 replace the -G argument with "Visual Studio 14 2015 Win64".

This will download and build OpenSSL, Protocol Buffers and the PostgreSQL client libraries. If all went well, the build_msvc\binexport-prefix directory should contain two IDA plugin binaries binexport10.dll and binexport1064.dll for use with ida.exe and ida64.exe, respectively.