Home

Awesome

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:

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

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

Process

You have to pass the following parameters to cmake:

You can pass the following additional parameters to cmake:

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:

On GCC 7 is stdc++fs located in:

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.