• Stars
    star
    783
  • Rank 55,788 (Top 2 %)
  • Language
    C++
  • License
    GNU Lesser Genera...
  • Created almost 5 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Deep ghidra decompiler and sleigh disassembler integration for rizin

rz-ghidra logo

rz-ghidra

This is an integration of the Ghidra decompiler and Sleigh Disassembler for rizin. It is solely based on the decompiler part of Ghidra, which is written entirely in C++, so Ghidra itself is not required at all and the plugin can be built self-contained. This project was presented, initially for radare2, at r2con 2019 as part of the Cutter talk: https://youtu.be/eHtMiezr7l8?t=950

Usage

Usage: pdg   # Native Ghidra decompiler plugin
| pdg           # Decompile current function with the Ghidra decompiler
| pdgd          # Dump the debug XML Dump
| pdgx          # Dump the XML of the current decompiled function
| pdgj          # Dump the current decompiled function as JSON
| pdgo          # Decompile current function side by side with offsets
| pdgs          # Display loaded Sleigh Languages
| pdg*          # Decompiled code is returned to rizin as comment

The following config vars (for the e command) can be used to adjust rz-ghidra's behavior:

    ghidra.cmt.cpp: C++ comment style
 ghidra.cmt.indent: Comment indent
     ghidra.indent: Indent increment
       ghidra.lang: Custom Sleigh ID to override auto-detection (e.g. x86:LE:32:default)
    ghidra.linelen: Max line length
   ghidra.nl.brace: Newline before opening '{'
    ghidra.nl.else: Newline before else
 ghidra.sleighhome: SLEIGHHOME

Here, ghidra.sleighhome must point to a directory containing the *.sla, *.lspec, ... files for the architectures that should supported by the decompiler. This is however set up automatically when using the rz-pm package or installing as shown below.

Building

First, make sure the submodule contained within this repository is fetched and up to date:

git submodule init
git submodule update

Then, the rizin plugin can be built and installed as follows:

mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
make
make install

Here, set the CMAKE_INSTALL_PREFIX to a location where rizin can load the plugin from. The install step is necessary for the plugin to work because it includes installing the necessary Sleigh files.

To also build the Cutter plugin, you must have Cutter installed from source under some prefix, which can be optionally specified with -DCMAKE_PREFIX_PATH=<path>, then pass -DBUILD_CUTTER_PLUGIN=ON to cmake to enable the plugin:

/my/path/rz-ghidra> mkdir build && cd build
/my/path/rz-ghidra/build> cmake -DBUILD_CUTTER_PLUGIN=ON -DCMAKE_PREFIX_PATH=/path/to/cutter/prefix -DCMAKE_INSTALL_PREFIX=~/.local ..
/my/path/rz-ghidra/build> make && make install

By default, the Cutter plugin is installed in an automatically chosen path in the current user's home directory. This path can be overriden with -DCUTTER_INSTALL_PLUGDIR.

Versioning and Rizin Compatibility

Rizin has a quickly evolving C API so it is necessary to be explicit about which versions of rz-ghidra are compatible with which versions of Rizin:

When using Rizin and rz-ghidra from git:

  • rz-ghidra branch dev follows along Rizin branch dev.
  • rz-ghidra branch stable follows along Rizin branch stable.

Regarding releases, rz-ghidra is generally released simultaneously with Rizin and often uses the same version numbers (but not guaranteed, do not depend on these numbers!). Also, along with every Rizin release a tag like rz-0.1.2 is created on rz-ghidra, which exactly points to an rz-ghidra release and indicates that this release is compatible with the specified Rizin version. These tags can be used by distribution maintainers to look up how to set up dependencies.

License

Please note that this plugin is available under the LGPLv3, which is more strict than Ghidra's license!

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/.

More Repositories

1

cutter

Free and Open Source Reverse Engineering Platform powered by rizin
C++
14,872
star
2

rizin

UNIX-like reverse engineering framework and command-line toolset.
C
2,332
star
3

cutter-plugins

A curated list of Community Plugins and Scripts written for Cutter
245
star
4

book

An official book about Rizin
CSS
61
star
5

CutterDRcov

DynamoRIO coverage visualization for cutter
Python
57
star
6

jsdec

Simple decompiler for Rizin
C
40
star
7

rz-libmc7

Library to disassemble MC7 bytecode for Siemens PLC SIMATIC S7-300 and S7-400
C
36
star
8

rz-pipe

Access rizin via pipe from any programming language!
Python
28
star
9

sigdb

Rizin FLIRT Signature Database
Meson
26
star
10

cutter-jupyter

Jupyter Plugin for Cutter
Python
24
star
11

rz-retdec

RetDec Decompiler Plugin for Rizin
C++
23
star
12

rz-pm

An official Rizin package manager
Go
15
star
13

rz-hexagon

Hexagon disassembler code generator for Rizin from the official instruction manual.
Python
11
star
14

sigdb-source

Rizin Signature Database (Source)
11
star
15

rz-libyara

Rizin libyara wrapper & core plugin for creating, parsing and applying YARA rules.
C
9
star
16

rizin-extras

Community plugins for Rizin
C
8
star
17

rz-tracetest

Testing of RzIL against real traces
C++
8
star
18

rz-silhouette

Rizin client plugin for the Rizin Silhouette Server
C
7
star
19

sdb

Simple string-based Key/Value database
C
7
star
20

rz-silhouette-server

Rizin Silhouette Symbol Server
Go
7
star
21

rz-bindgen

Python
6
star
22

rz-lang

RzLang extensions for implementing Rizin plugins in other languages
C
6
star
23

rz-libdemangle

Rizin Library to demangle symbols
C
5
star
24

cutter-deps

Makefile
5
star
25

website

This repository holds the raw sources and content of Rizin's website: https://rizin.re
HTML
5
star
26

rizin-testbins

Max
5
star
27

rz-pm-db

4
star
28

rz-asm-llvm

LLVM-based assembler plugin for Rizin
C++
4
star
29

rz-rzilcompiler

C to RZIL Compiler to extend the Rizin Hexagon plugin.
C
4
star
30

ideas

Features that would be nice to have but they are not in the roadmap
3
star
31

sigdb-tools

Rizin Signature Database Tools
Python
2
star
32

rizin-notebook

A notebook where to writes notes while using rizin!
Go
2
star
33

cutter.re

The Cutter website
SCSS
2
star
34

test-pdb-repository

PDB repository for the testsuite to lower the number of fails due windows symbol server not being available.
1
star
35

rz-libswift

Swift Demangling library
C++
1
star
36

vice

VICE Emulator emitting bap-frames traces
C
1
star
37

rizin-pm

Shell
1
star