RetDec is a retargetable machine-code decompiler based on LLVM .
The decompiler is not limited to any particular target architecture, operating system, or executable file format:
For more information, check out our
Currently, we support only Windows (7 or later), Linux, and unofficially macOS.
Warning: Decompilations of larger binaries (1 MB or more) may require a lot of RAM. When running decompilations, we advise you to limit the maximal virtual memory for processes before decompiling to prevent potential swapping and unresponsiveness. On Linux, you can run e.g. ulimit -Sv 9863168 in your shell to limit the maximal virtual memory to 8 GB.
ulimit -Sv 9863168
Either download and unpack a pre-built package from the following list, or build and install the decompiler by yourself (the process is described below):
Install Microsoft Visual C++ Redistributable for Visual Studio 2015 .
Install MSYS2 and other needed applications by following RetDec's Windows environment setup guide .
Now, you are all set to run the decompiler. To decompile a binary file named test.exe, run
bash $RETDEC_INSTALL_DIR/bin/decompile.sh test.exe
For more information, run decompile.sh with --help.
There are currently no pre-built packages for Linux. You will have to build and install the decompiler by yourself. The process is described below.
After you have built the decompiler, you will need to install the following packages via your distribution's package manager:
Warning: macOS build was added based on community feedback and is not directly supported by the RetDec team. We do not guarantee you that these instructions will work for you. If you encounter any problem with your build, submit an issue so the macOS community can help you out.
There are currently no pre-built packages for macOS. You will have to build and install the decompiler by yourself. The process is described below.
After you have built the decompiler, you will need to install the following packages:
# /usr/local/bin/bash if installed via Homebrew
/path/to/gnu/bash $RETDEC_INSTALL_DIR/bin/decompile.sh test.exe
This section describes a local build and installation of RetDec. Instructions for Docker are given in the next section.
On Debian-based distributions (e.g. Ubuntu), the required packages can be installed with apt-get:
sudo apt-get install build-essential cmake git perl python3 bash bison flex autoconf automake libtool pkg-config m4 coreutils zlib1g-dev libtinfo-dev wget bc upx doxygen graphviz
On RPM-based distributions (e.g. Fedora), the required packages can be installed with dnf:
sudo dnf install gcc gcc-c++ cmake make git perl python3 bash bison flex autoconf automake libtool pkg-config m4 coreutils zlib-devel ncurses-devel wget bc upx doxygen graphviz
On Arch Linux, the required packages can be installed with pacman:
sudo pacman -S base-devel cmake git perl python3 bash bison flex autoconf automake libtool pkg-config m4 coreutils zlib ncurses wget bc upx doxygen graphviz
Packages should be preferably installed via Homebrew .
$(brew --prefix coreutils)/libexec/gnubin
Warning: Currently, RetDec has to be installed into a clean, dedicated directory. Do NOT install it into /usr, /usr/local, etc. because our build system is not yet ready for system-wide installations. So, when running cmake, always set -DCMAKE_INSTALL_PREFIX=<path> to a directory that will be used just by RetDec. For more details, see #12 .
git clone --recursive https://github.com/avast-tl/retdec
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=<path>
make && make install
cmake .. -DCMAKE_INSTALL_PREFIX=<path> -G<generator>
msbuild /m /p:Configuration=Release retdec.sln
msbuild /m /p:Configuration=Release INSTALL.vcxproj
# Apple ships old Flex & Bison, so Homebrew versions should be used.export CMAKE_INCLUDE_PATH="/usr/local/opt/flex/include"export CMAKE_LIBRARY_PATH="/usr/local/opt/flex/lib;/usr/local/opt/bison/lib"export PATH="/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH"
You have to pass the following parameters to cmake:
-G"Visual Studio 14 2015"
-G"Visual Studio 14 2015 Win64"
You can pass the following additional parameters to cmake:
Docker support is maintained by community. If something does not work for you or if you have suggestions for improvements, open an issue or PR.
Building in Docker does not require installation of required libraries locally. This is a good option for trying out RetDec without setting up the whole build toolchain.
To build the RetDec docker image, run
docker build -t retdec .
This builds the container from the master branch of this repository.
To build the container using the local copy of the repository, fully clone the repository:
git submodule update --init --recursive
Then, build the container using the development Dockerfile, Dockerfile.dev:
docker build -t retdec:dev . -f Dockerfile.dev
To decompile a binary, create a container to upload the binary to:
docker create --name retdec_init retdec
Upload the binary (note the destination directory should be a directory with read/write permissions, such as /home/retdec/):
docker cp <file> retdec_init:/destination/path/of/binary
Commit the copied files into the container image:
docker commit retdec_init retdec:initialized
Run the decompiler:
docker run --name retdec retdec:initialized decompile.sh /destination/path/of/binary
Copy output back to host:
docker cp retdec:/destination/path/of/binary.c /path/to/save/file
This repository contains the following libraries:
This repository contains the following tools:
This repository contains the following scripts:
Copyright (c) 2017 Avast Software, licensed under the MIT license. See the LICENSE file for more details.
RetDec uses third-party libraries or other resources listed, along with their licenses, in the LICENSE-THIRD-PARTY file.
See RetDec contribution guidelines .
This software was supported by the research funding TACR (Technology Agency of the Czech Republic), ALFA Programme No. TA01010667.