From 06bb0cc446f454bf1ff628626f14dcfead05ac09 Mon Sep 17 00:00:00 2001 From: David Manouchehri Date: Tue, 12 Dec 2017 16:05:03 -0500 Subject: [PATCH 1/3] Added Dockerfile. --- Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..e449ce74 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:bionic +LABEL maintainer="David Manouchehri" + +RUN useradd -m retdec +WORKDIR /home/retdec +ENV HOME /home/retdec + +RUN apt-get -y update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git bc graphviz upx cmake python zlib1g-dev flex bison libtinfo-dev autoconf pkg-config m4 libtool wget + +USER retdec +RUN git clone --recursive https://github.com/avast-tl/retdec && \ + cd retdec && \ + mkdir build && \ + cd build && \ + cmake .. -DCMAKE_INSTALL_PREFIX=/home/retdec/retdec-install && \ + make && \ + make install + +ENV PATH /home/retdec/retdec-install/bin:$PATH + +CMD ["/bin/bash"] From 68ec007aa52098f98164076716503f64eaebf9f7 Mon Sep 17 00:00:00 2001 From: David Manouchehri Date: Wed, 13 Dec 2017 12:28:45 -0500 Subject: [PATCH 2/3] Removed maintainer name. --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e449ce74..88237437 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,4 @@ FROM ubuntu:bionic -LABEL maintainer="David Manouchehri" RUN useradd -m retdec WORKDIR /home/retdec From 6c443249f23a6030420a196b9dbecd6dbfc76189 Mon Sep 17 00:00:00 2001 From: HugoKlepsch Date: Wed, 20 Dec 2017 13:39:44 -0500 Subject: [PATCH 3/3] Add development Dockerfile * Development dockerfile builds from the current source directory * Add instructions to build and use docker container --- Dockerfile | 31 ++++++++++++++++++----- Dockerfile.dev | 45 +++++++++++++++++++++++++++++++++ README.md | 67 ++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 135 insertions(+), 8 deletions(-) create mode 100644 Dockerfile.dev diff --git a/Dockerfile b/Dockerfile index 88237437..ccdff64b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,17 +5,36 @@ WORKDIR /home/retdec ENV HOME /home/retdec RUN apt-get -y update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential git bc graphviz upx cmake python zlib1g-dev flex bison libtinfo-dev autoconf pkg-config m4 libtool wget + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential \ + cmake \ + git \ + perl \ + python3 \ + bash \ + coreutils \ + wget \ + bc \ + doxygen \ + graphviz \ + upx \ + flex \ + bison \ + zlib1g-dev \ + libtinfo-dev \ + autoconf \ + automake \ + pkg-config \ + m4 \ + libtool USER retdec RUN git clone --recursive https://github.com/avast-tl/retdec && \ cd retdec && \ mkdir build && \ cd build && \ - cmake .. -DCMAKE_INSTALL_PREFIX=/home/retdec/retdec-install && \ - make && \ + cmake .. -DCMAKE_INSTALL_PREFIX=/home/retdec/install && \ + make -j$(nproc) && \ make install -ENV PATH /home/retdec/retdec-install/bin:$PATH - -CMD ["/bin/bash"] +ENV PATH /home/retdec/install/bin:$PATH diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 00000000..fbf436fe --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,45 @@ +FROM ubuntu:bionic + +RUN useradd -m retdec +WORKDIR /home/retdec +ENV HOME /home/retdec + +RUN apt-get -y update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential \ + cmake \ + git \ + perl \ + python3 \ + bash \ + coreutils \ + wget \ + bc \ + doxygen \ + graphviz \ + upx \ + flex \ + bison \ + zlib1g-dev \ + libtinfo-dev \ + autoconf \ + automake \ + pkg-config \ + m4 \ + libtool + +# New versions of docker (>v17.09.0-ce) support the --chown flag given to COPY +# Once this version is more wide spread, consider updating this repository's Dockerfiles +# to use the new directive. +COPY . retdec +RUN chown -R retdec:retdec retdec + +USER retdec +RUN cd retdec && \ + mkdir build && \ + cd build && \ + cmake .. -DCMAKE_INSTALL_PREFIX=/home/retdec/install && \ + make -j$(nproc) && \ + make install + +ENV PATH /home/retdec/install/bin:$PATH diff --git a/README.md b/README.md index 22373823..0eace778 100644 --- a/README.md +++ b/README.md @@ -93,9 +93,72 @@ Currently, we support only Windows (7 or later), Linux, and unofficially macOS. ## Build and Installation +### Build in Docker + +#### Build image + +Building in Docker doesn't 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 +``` + +#### Run container + +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 +like /home/retdec/. + +``` +docker cp 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 +``` + +### Build and install locally + This section describes a manual build and installation of RetDec. -### Requirements +#### Requirements #### Linux @@ -142,7 +205,7 @@ sudo dnf install git cmake make gcc gcc-c++ perl python3 bash zlib-devel flex bi * [wget](https://www.gnu.org/software/wget/) * [Python](https://www.python.org/) (version >= 3.4, macOS has 2.7) -### Process +#### Process **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=` to a directory that will be used just by RetDec. For more details, see [#12](https://github.com/avast-tl/retdec/issues/12).**