Giter Site home page Giter Site logo

retdec-r2plugin's Introduction

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

The r2pm package is available for Radare2 version 4.5.0 and newer. To install the plugin using r2pm use:

$ r2pm -i retdec-r2plugin

This will, however, install only the plugin for r2 console. To use the Cutter plugin you must build this plugin manually. See the Build and Installation section.

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.

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.
  • -DBUILD_CUTTER_PLUGIN=OFF setting to ON will build the Cutter plugin. Cutter must be built with support for plugin loading, see Cutter 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.

retdec-r2plugin's People

Contributors

s3rvac avatar petermatula avatar thestr4ng3r avatar nirmalmanoj avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.