Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more
Integrate Ghidra's decompiler as an Ida plugin
C++ Yacc Other
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bins Merge branch 'master' of https://github.com/cseagle/blc Jan 16, 2020
.gitignore initial commit Nov 30, 2019
AUTHORS initial commit Nov 30, 2019
COPYING initial commit Nov 30, 2019
LICENSE initial commit Nov 30, 2019
Makefile include transform.cc Dec 30, 2019
README.md little of substance Dec 23, 2019
action.cc initial commit Nov 30, 2019
action.hh initial commit Nov 30, 2019
address.cc merge from ghidra master Dec 30, 2019
address.hh merge from ghidra master Dec 30, 2019
architecture.cc merge from ghidra master Dec 30, 2019
architecture.hh merge from ghidra master Dec 30, 2019
ast.cc progress towards re-typing interface. also new sleigh id strings for … Jan 9, 2020
ast.hh progress towards re-typing interface. also new sleigh id strings for … Jan 9, 2020
blc.sln Remove 32-bit targets Dec 2, 2019
blc.vcxproj progress towards re-typing interface. also new sleigh id strings for … Jan 9, 2020
blc.vcxproj.filters progress towards re-typing interface. also new sleigh id strings for … Jan 9, 2020
blc.vcxproj.user initial commit Nov 30, 2019
block.cc initial commit Nov 30, 2019
block.hh initial commit Nov 30, 2019
blockaction.cc initial commit Nov 30, 2019
blockaction.hh
callgraph.hh initial commit Nov 30, 2019
capability.cc initial commit Nov 30, 2019
capability.hh initial commit Nov 30, 2019
cast.cc initial commit Nov 30, 2019
cast.hh initial commit Nov 30, 2019
comment.cc initial commit Nov 30, 2019
comment.hh
condexe.cc initial commit Nov 30, 2019
condexe.hh initial commit Nov 30, 2019
context.cc initial commit Nov 30, 2019
context.hh initial commit Nov 30, 2019
coreaction.cc merge from ghidra master Dec 30, 2019
coreaction.hh merge from ghidra master Dec 30, 2019
cover.cc initial commit Nov 30, 2019
cover.hh initial commit Nov 30, 2019
cpool.cc initial commit Nov 30, 2019
cpool.hh initial commit Nov 30, 2019
crc32.cc initial commit Nov 30, 2019
crc32.hh initial commit Nov 30, 2019
database.cc merge from ghidra master Dec 30, 2019
database.hh merge from ghidra master Dec 30, 2019
double.cc initial commit Nov 30, 2019
double.hh initial commit Nov 30, 2019
dynamic.cc merge from ghidra master Dec 30, 2019
dynamic.hh initial commit Nov 30, 2019
emulate.cc initial commit Nov 30, 2019
emulate.hh initial commit Nov 30, 2019
emulateutil.cc initial commit Nov 30, 2019
emulateutil.hh initial commit Nov 30, 2019
error.hh initial commit Nov 30, 2019
filemanage.cc initial commit Nov 30, 2019
filemanage.hh initial commit Nov 30, 2019
float.cc initial commit Nov 30, 2019
float.hh initial commit Nov 30, 2019
flow.cc merge from ghidra master Dec 30, 2019
flow.hh initial commit Nov 30, 2019
fspec.cc merge from ghidra master Dec 30, 2019
fspec.hh initial commit Nov 30, 2019
funcdata.cc initial commit Nov 30, 2019
funcdata.hh merge from ghidra master Dec 30, 2019
funcdata_block.cc merge from ghidra master Dec 30, 2019
funcdata_op.cc merge from ghidra master Dec 30, 2019
funcdata_varnode.cc merge from ghidra master Dec 30, 2019
globalcontext.cc initial commit Nov 30, 2019
globalcontext.hh initial commit Nov 30, 2019
grammar.hh initial commit Nov 30, 2019
grammar.y initial commit Nov 30, 2019
graph.cc initial commit Nov 30, 2019
graph.hh initial commit Nov 30, 2019
heritage.cc initial commit Nov 30, 2019
heritage.hh merge from ghidra master Dec 30, 2019
ida_arch.cc initial commit Nov 30, 2019
ida_arch.hh initial commit Nov 30, 2019
ida_load_image.cc initial commit Nov 30, 2019
ida_load_image.hh initial commit Nov 30, 2019
ida_minimal.hh do a better job in buildVariableName Dec 29, 2019
ida_scope.cc do a better job in buildVariableName Dec 29, 2019
ida_scope.hh initial commit Nov 30, 2019
ifacedecomp.hh initial commit Nov 30, 2019
ifaceterm.hh initial commit Nov 30, 2019
inject_sleigh.cc initial commit Nov 30, 2019
inject_sleigh.hh initial commit Nov 30, 2019
interface.hh initial commit Nov 30, 2019
jumptable.cc initial commit Nov 30, 2019
jumptable.hh initial commit Nov 30, 2019
libdecomp.cc initial commit Nov 30, 2019
libdecomp.hh initial commit Nov 30, 2019
loadimage.cc initial commit Nov 30, 2019
loadimage.hh initial commit Nov 30, 2019
memstate.cc merge from ghidra master Dec 30, 2019
memstate.hh initial commit Nov 30, 2019
merge.cc initial commit Nov 30, 2019
merge.hh initial commit Nov 30, 2019
op.cc merge from ghidra master Dec 30, 2019
op.hh merge from ghidra master Dec 30, 2019
opbehavior.cc merge from ghidra master Dec 30, 2019
opbehavior.hh merge from ghidra master Dec 30, 2019
opcodes.cc merge from ghidra master Dec 30, 2019
opcodes.hh merge from ghidra master Dec 30, 2019
options.cc initial commit Nov 30, 2019
options.hh initial commit Nov 30, 2019
override.cc
override.hh initial commit Nov 30, 2019
paramid.cc initial commit Nov 30, 2019
paramid.hh initial commit Nov 30, 2019
partmap.hh initial commit Nov 30, 2019
pcodecompile.cc merge from ghidra master Dec 30, 2019
pcodecompile.hh merge from ghidra master Dec 30, 2019
pcodeinject.cc merge from ghidra master Dec 30, 2019
pcodeinject.hh merge from ghidra master Dec 30, 2019
pcodeparse.hh merge from ghidra master Dec 30, 2019
pcodeparse.tab.cc merge from ghidra master Dec 30, 2019
pcodeparse.y merge from ghidra master Dec 30, 2019
pcoderaw.cc merge from ghidra master Dec 30, 2019
pcoderaw.hh merge from ghidra master Dec 30, 2019
plugin.cc correct compiler spec for xbox/ppc Jan 16, 2020
plugin.hh some ast post processing until we can make ghidra do it for us Dec 27, 2019
prefersplit.cc initial commit Nov 30, 2019
prefersplit.hh initial commit Nov 30, 2019
prettyprint.cc initial commit Nov 30, 2019
prettyprint.hh initial commit Nov 30, 2019
printc.cc merge from ghidra master Dec 30, 2019
printc.hh merge from ghidra master Dec 30, 2019
printjava.cc initial commit Nov 30, 2019
printjava.hh initial commit Nov 30, 2019
printlanguage.cc merge from ghidra master Dec 30, 2019
printlanguage.hh merge from ghidra master Dec 30, 2019
rangemap.hh initial commit Nov 30, 2019
rangeutil.cc initial commit Nov 30, 2019
rangeutil.hh initial commit Nov 30, 2019
ruleaction.cc merge from ghidra master Dec 30, 2019
ruleaction.hh merge from ghidra master Dec 30, 2019
rulecompile.hh initial commit Nov 30, 2019
ruleparse.y initial commit Nov 30, 2019
run.cc progress towards re-typing interface. also new sleigh id strings for … Jan 9, 2020
semantics.cc initial commit Nov 30, 2019
semantics.hh
sleigh.cc initial commit Nov 30, 2019
sleigh.hh initial commit Nov 30, 2019
sleigh_arch.cc initial commit Nov 30, 2019
sleigh_arch.hh initial commit Nov 30, 2019
sleighbase.cc merge from ghidra master Dec 30, 2019
sleighbase.hh merge from ghidra master Dec 30, 2019
slghpatexpress.cc merge from ghidra master Dec 30, 2019
slghpatexpress.hh initial commit Nov 30, 2019
slghpattern.cc initial commit Nov 30, 2019
slghpattern.hh initial commit Nov 30, 2019
slghsymbol.cc merge from ghidra master Dec 30, 2019
slghsymbol.hh merge from ghidra master Dec 30, 2019
space.cc merge from ghidra master Dec 30, 2019
space.hh initial commit Nov 30, 2019
subflow.cc merge from ghidra master Dec 30, 2019
subflow.hh merge from ghidra master Dec 30, 2019
transform.cc merge from ghidra master Dec 30, 2019
transform.hh merge from ghidra master Dec 30, 2019
translate.cc merge from ghidra master Dec 30, 2019
translate.hh merge from ghidra master Dec 30, 2019
type.cc merge from ghidra master Dec 30, 2019
type.hh merge from ghidra master Dec 30, 2019
typeop.cc merge from ghidra master Dec 30, 2019
typeop.hh merge from ghidra master Dec 30, 2019
types.h initial commit Nov 30, 2019
unify.hh initial commit Nov 30, 2019
userop.cc
userop.hh initial commit Nov 30, 2019
variable.cc merge from ghidra master Dec 30, 2019
variable.hh merge from ghidra master Dec 30, 2019
varmap.cc merge from ghidra master Dec 30, 2019
varmap.hh merge from ghidra master Dec 30, 2019
varnode.cc initial commit Nov 30, 2019
varnode.hh merge from ghidra master Dec 30, 2019
xml.hh
xml.tab.cc initial commit Nov 30, 2019
xml.y initial commit Nov 30, 2019

README.md

WARNING: THIS CODE IS VERY RAW AND PROBABLY VERY BUGGY!

Introduction

This is the blc (Binary Lifting Contraption) plugin for IDA Pro. It is the Bastard love child of Ghidra's decompiler with Ida Pro.

The plugin integrates Ghidra's decompiler code into an Ida plugin an provides a basic decompiler capability for all platforms support by both Ida and Ghidra. It provides a basic source code display that attempts to mimic that of the Hex-Rays decompiler. It has only been written with Ida 7.x in mind.

BUILDING:

On all platforms you should clone blc into your IDA SDK's plugins sub-directory so that you end up with <sdkdir>/plugins/blc. This is because the build files all use relative paths to find necessary IDA header files and link libraries.

Build blc for Linux / OS X:

Use the include Makefile to build the plugin. You may need to adjust the paths that get searched to find your IDA installation (/Applications/IDA Pro N.NN is assumed on OSX and /opt/ida-N.NN is assumed on Linux, were N.NN is derived from the name of your IDA SDK directory eg idasdk73 associates with 7.3 and should match your IDA version number). This is required to successfully link the plugin.

$ cd <sdkdir>/plugins/blc
$ make

Compiled binaries will end up in <sdkdir>/plugins/blc/bin

LINUX
         -------------------------------------------
         |        ida        |        ida64        |
         -------------------------------------------
IDA 7.x  |                   |                     |
 plugin  |     blc.so        |      blc64.so       |
         -------------------------------------------

OS/X
         -------------------------------------------
         |        ida        |        ida64        |
         -------------------------------------------
IDA 7.x  |                   |  |                  |
 plugin  |     blc.dylib     |      blc64.dylib    |
         -------------------------------------------

Copy the plugin(s) into your <IDADIR>/plugins directory and blc should be listed as an available plugin for all architectures supported both Ida and Ghidra.

Build blc for Windows

Build with Visual Studio C++ 2017 or later using the included solution (.sln) file (blc.sln). Two build targets are available depending on which version of IDA you are using:

         -----------------------------------------
         |        ida        |        ida64      |
         -----------------------------------------
IDA 7.x  |    Release/x64    |   Release64/x64   |
 plugin  |       blc.dll     |       blc64.dll   |
         -----------------------------------------

Copy the plugin(s) into your <IDADIR>/plugins directory and blc should be listed as an available plugin for all architectures supported by both Ida and Ghidra.

INSTALLATION

Assuming you have installed IDA to <idadir>, install the plugin by copying the compiled binaries from <sdkdir>/plugins/blc/bin to <idadir>/plugins (Linux/Windows) or <idadir>/idabin/plugins (OS X).

The plugin is dependent on Ghira processor specifications which you will need to copy over from your own Ghidra installation. Installing Ghidra is a simple matter of unzipping the latest Ghidra release, for example: https://ghidra-sre.org/ghidra_9.1_PUBLIC_20191023.zip Within the extracted Ghidra folder, you will find a Ghidra subdirectory which, in turn, contains a Processors subdirectory. The decompiler needs access to files contained under Ghidra/Processors. By default the plugin looks for the environment variable $GHIDRA_DIR which it expects to point at your Ghidra installation folder such that $GHIDRA_DIR/Ghidra/Processors exists. If $GHIDRA_DIR is not set, then the plugin expects to find <idadir>/plugins/Ghidra/Processors which you may create with a symlink or by copying the approprate directories from your Ghidra installation.

Pre-built binaries:

As an alternative to building the plugin yourself, pre-built binaries for IDA 7.x (Windows, Linux, OS X) are available in the blc/bins directory.

USING THE PLUGIN

With the plugin installed, open a binary of interest in IDA. In order for the plugin to be become available, the binary's architecture must be supported by both Ida and Ghidra.

With the cursor placed inside the body of an Ida function, select Edit/Plugins/Ghidra Decompiler. A successful decompilation (which may take a bit of time, will open a new window containing the C source generated by Ghidra's decompiler. Within the source window, you may double click on a function name to decompile tht function. Double clicking on a global data name will navigate you to that symbol in the Ida disassembly view. The ESC key will navigate back to a previous function, or close the source viewer if there is no previous function.

The N hot key may be used to rename any symbol in the source view. When a symbol in the source view corresponds to a symbol in the Ida disassembly, the symbol will also be renamed in the disassembly.

POTENTIAL FUTURE WORK

  • Allow user to set data types for symbols in the source view
  • Provide IDA derived type information to the decompiler so that it can do a better job with things like structures and pointer dereferencing
  • Better (at least some) support for string literals
  • Investigate what settings/info are necessary to get this standalone decompiler to yield results identical to Ghidra's. Is this symbol information? Type information? arch/platform/compiler settings?
You can’t perform that action at this time.