You can build ROPfuscator either manually or by using docker.
ROPfuscator supports docker build with Dockerfile.
After cloning this project (and updating submodules), you can just run:
sh docker/build.sh
It will define the following tags:
ropfuscator:prebuild-llvm-9
: just before building ropfuscatorropfuscator:build-llvm-9
: after building ropfuscatorropfuscator:llvm-9
: ropfuscator binary (without build files)
You can use ropfuscator:llvm-9
to obfuscate programs.
ninja
pkg-config
cmake
, version>= 3.00
- external libraries (
libfmt==5.2.1
,tinytoml==0.4
) included inthirdparty/
- C++ compiler (clang or g++)
On Ubuntu/Debian distribution, use the following command to install build dependencies:
sudo apt-get install cmake ninja-build pkg-config
Make sure to be able to clone this repository (and third party repositories in thirdparty/
directory) first and then run:
wget http://releases.llvm.org/9.0.0/llvm-9.0.0.src.tar.xz
tar -xf llvm-9.0.0.src.tar.xz && rm llvm-9.0.0.src.tar.xz
cd llvm-9.0.0.src
pushd tools
wget https://releases.llvm.org/9.0.0/cfe-9.0.0.src.tar.xz
tar -xf cfe-9.0.0.src.tar.xz && rm cfe-9.0.0.src.tar.xz
popd
pushd lib/Target/X86
git clone --recursive git@bitbucket.org:s2lab/ropfuscator.git
patch < ropfuscator/patch/llvm-9.patch
popd
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD=X86 -DBUILD_SHARED_LIBS=ON -GNinja ..
ninja llc
There are a couple of flags that are worth to be mentioned when configuring the build:
-DCMAKE_BUILD_TYPE=Debug
: to obtain a debug build (more flexible)-DLLVM_TARGETS_TO_BUILD=X86
: we are interested only in the X86 platform, so we do not want to lose time compiling the backend also for all the other platforms, such as ARM, MIPS, SPARC, etc. This speeds up the compilation process and make us save up to 4 GB of disk space.-DBUILD_SHARED_LIBS=ON
: shared code is moved in.so
libraries that can be linked at runtime, thus speeding up the compilation process even more.-GNinja
: specifies to useninja
as build generator. By usingninja
the overall compile time can decrease by more than 50% (it seems that it has better multithreading support), but most importantly, we can invoke a specific command to compile onlyllc
.
Once the project is compiled, we can create a symbolic link to our custom version of llc
, in order to call it in a simpler way, ropf-llc
:
sudo ln -s [BUILD-DIR]/bin/llc $(HOME)/.local/bin/ropf-llc
Make sure that $(HOME)/.local/bin/
is set in your PATH
environment variable.
Since ROPfuscator is a MachineFunctionPass
, we have to recompile llc
(LLVM system compiler) each time we modify the pass.
Luckily we are using ninja-build
, so we do not have to recompile the whole backend; doing this is just a matter of seconds by running:
ninja llc