• Stars
    star
    123
  • Rank 290,145 (Top 6 %)
  • Language
    C++
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

RetDec plugin for Radare2

RetDec Radare2 plugin

retdec-r2plugin CI

RetDec plugin for Radare2.

The plugin integrates RetDec decompiler into Radare2 console. RetDec Radare2 plugin is shipped with a bundled RetDec version, but you can use your own version (specified below).

With the bundled version of RetDec you can decompile the following architectures:

  • 32-bit: Intel x86, ARM, MIPS, PIC32, and PowerPC.
  • 64-bit: x86-64, ARM64 (AArch64).

Installation and Use

The plugin was tested and should work on following operating systems: Linux, macOS and Windows.

R2PM Installation

radare2 comes with its own package manager named 'r2pm', you can install the plugin with the following line:

$ r2pm -i r2retdec

Dependencies

To compile retdec you need a relatively powerful machine with 2GB free disk and the following software installed:

On Ubuntu:

apt install autoconf libtool automake build-essential make git g++

Troubleshooting

If you are not able to compile the plugin please fill an issue in github after carefully reading the error messages in the console.

If the plugin is compiled and installed, but pdz doesn't show up, set the R2_DEBUG=1 env var to debug the plugin loading process in radare2.

Use in Radare2 Console

In r2 console you can type pdz? to print help:

Usage: pdz   # Native RetDec decompiler plugin.
| pdz      # Show decompilation result of current function.
| pdz*     # Show current decompiled function side by side with offsets.
| pdza[?]  # Run RetDec analysis.
| pdze     # Show environment variables.
| pdzj     # Dump current decompiled function as JSON.
| pdzo     # Show current decompiled function side by side with offsets.

The following environment variables may be used to dynamically customize the plugin's behavior:

$ export DEC_SAVE_DIR=<path> # custom path for output of decompilation to be saved to.

Build and Installation

This section describes a local build and installation of RetDec Radare2 plugin, you will need 26GB of ram and 1.5GB of disk to compile it.

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

Requirements

  • A compiler supporting c++17
  • CMake (version >= 3.6)
  • Existing Radare2 installation (version >= 4.5.0)

To build the bundled version of RetDec see RetDec requirements section.

Process

  • Clone the repository:
    • git clone https://github.com/avast/retdec-r2plugin
  • Linux and MacOS:
    • cd retdec-r2plugin
    • mkdir build && cd build
    • cmake .. -DCMAKE_INSTALL_PREFIX=<path>
    • make -jN (N is the number of processes to use for parallel build, typically number of cores + 1 gives fastest compilation time)
    • make install
  • Windows:
    • Open a command prompt (e.g. cmd.exe)
    • cd retdec-r2plugin
    • mkdir build && cd build
    • cmake .. -DCMAKE_INSTALL_PREFIX=<path>
    • cmake --build . --config Release -- -m
    • cmake --build . --config Release --target install

You have to pass the following parameters to cmake:

  • -DCMAKE_INSTALL_PREFIX=<path> to set the installation path to <path>. It is important to set the <path> to a location where Radare2 can load plugins from (for example ~/.local).

You can pass the following additional parameters to cmake:

  • -DBUILD_BUNDLED_RETDEC=ON to build bundled RetDec version with the plugin. The build of the bundled RetDec is by default turned on. RetDec will be installed to CMAKE_INSTALL_PREFIX. When turned OFF system is searched for RetDec installation.
  • -DR2PLUGIN_DOC=OFF optional parameter to build Doxygen documentation.

Note: retdec-r2plugin requires filesystem library to be linked with the plugin. CMake will try to find the library in the system but on GCC 7 it might not be able to do so automatically. In that case you must specify a path where this library is located in the system to the cmake by adding:

  • -DCMAKE_LIBRARY_PATH=${PATH_TO_FILESTSTEM_DIR}

On GCC 7 is stdc++fs located in:

  • -DCMAKE_LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/7/

License

Copyright (c) 2019 Avast Software, licensed under the MIT license. See the LICENSE file for more details.

RetDec Radare2 plugin uses third-party libraries or other resources listed, along with their licenses, in the LICENSE-THIRD-PARTY file.

Contributing

See RetDec contribution guidelines.

More Repositories

1

radare2

UNIX-like reverse engineering framework and command-line toolset
C
20,356
star
2

iaito

Official QT frontend of radare2
C++
1,047
star
3

radare2-book

The Official Radare2 Book
C
787
star
4

awesome-radare2

A curated list of awesome projects, articles and the other materials powered by Radare2
696
star
5

radeco

radare2-based decompiler and symbol executor
Rust
372
star
6

radare2-r2pipe

Access radare2 via pipe from any programming language!
JavaScript
370
star
7

r2ghidra

Native Ghidra Decompiler for r2
C++
334
star
8

radare2-extras

Source graveyard and random candy for radare2
C
239
star
9

sdb

Simple and fast string based key-value database with support for arrays and json
C
216
star
10

r2con

Radare Congress Stuff
202
star
11

esilsolve

A python symbolic execution framework using radare2's ESIL (Evaluable String Intermediate Language)
Python
159
star
12

r2con2019

r2con2019 - slides and materials
Python
135
star
13

radare2-pm

Package Manager for Radare2
Shell
131
star
14

radare2-bindings

Bindings of the r2 api for Valabind and friends
Python
130
star
15

r2con2017

r2con 2017 September 6-9
Python
97
star
16

radare2-webui

webui repository for radare2
JavaScript
93
star
17

r2con2018

HTML
92
star
18

r2ai

local language model for radare2
Python
78
star
19

r2wars

Corewars but within r2
C#
56
star
20

r2pipe.rs

Rust crate for r2pipe
Rust
44
star
21

ghidra-r2web

Ghidra plugin to start an r2 webserver to let r2 interact with it
Java
43
star
22

libdemangle

A simple library focusing on demangling symbols for different programing languages
C
39
star
23

r2con2020

Python
35
star
24

radare

advanced unix-like hexadecimal editor and debugger
C
35
star
25

r2jp

Japanese Community of radare2
34
star
26

r2pm

Radare2 cross platform package manager
Go
33
star
27

radare2-r2papi

High Level API on top of the R2Pipe interface
TypeScript
33
star
28

acr

autoconf replacement
Shell
33
star
29

r2pipe-go

Go API to interact with radare2
Go
31
star
30

ghidra-native

C++
29
star
31

r2con2021

28
star
32

r2env

Install multiple versions of r2 and its plugins via Pip on any system!
Python
25
star
33

r2yara

yara and radare2, better together
C
17
star
34

radare2-rlang

Writing Radare2 plugins in various languages
C
15
star
35

radare2-testbins

Rebol
15
star
36

radare2-rust

Playground for Rust and Radare2
Rust
14
star
37

radare.org

http://www.radare.org/
CSS
14
star
38

r2hexagon

Hexagon disassembler code generator from the official instruction manual.
C
11
star
39

r2con2016

r2con2016 repository
C
10
star
40

esil-rs

Radare2's ESIL in Rust
Rust
10
star
41

r2diaphora

Binary Diffing tool ported to radare2
Python
9
star
42

radare2-gsoc-windows

Various Brainstorming/scripts/ideas/etc. for the GSOC-Windows Task
C
9
star
43

ragui

Vala
8
star
44

radare2-release

Releasing is hard
Shell
7
star
45

r2app

Electron Desktop App for Radare2
JavaScript
6
star
46

blog

The radare2 blog, available on radare.today
Shell
6
star
47

r2pipe-codeshare

A place to share your radare2 scripts
Python
6
star
48

radare2-win-installer

Windows installer scripts for radare2
Inno Setup
5
star
49

r2r-go

Go
5
star
50

radareorg

New amazing website for radare.org
Python
4
star
51

radare2-cheatsheets

TeX
4
star
52

radare2-fuzz

Python
4
star
53

ideas

4
star
54

radare2-skel

Sample radare2 project templates
Python
4
star
55

node-r2r

radare2 regressions testsuite in nodejs
JavaScript
3
star
56

iaito-translations

Makefile
3
star
57

.github

Radare Organization Templates
3
star
58

r2shell

C
2
star
59

infrastructure

Terraform, Nomad, Consul and Vault configuration of radare infrastructure
Dockerfile
2
star
60

r2pm-db

Radare2 package manager database
2
star
61

radare2-snap

Radare2 snap and docker repository
Makefile
2
star
62

radare2-fuzztargets

Makefile
1
star
63

r2r-v

R2 regressions testsuite written in V
V
1
star
64

radeco-regressions

Regresion tests for radeco
Rust
1
star
65

radare2-sigs

Zignature masm32 repository
Python
1
star
66

r2sarif

Load, manage and create SARIF documents with radare2
TypeScript
1
star