Using LLVM Pass to obfuscate programs.
Write up (in Chinese):
Feature | Enable Flag |
---|---|
Obfuscate constant string | -obfstr |
Add bogus control flow | -boguscf |
Instruction Substitution | -subobf |
Call graph flattening | -flattening |
llvm-9 and llvm-9-dev
cmake >= 3.10
gcc / clang
mkdir build && cd build
# You should modify the DLLVM_DIR option to fit your environment
cmake .. -DLLVM_DIR=/usr/lib/llvm-9/lib/cmake/llvm/
cmake --build . -- -j$(nproc)
# You should assign ${fullname} and ${basename} as your program's name
# Example: fullname=test.c; basename=test
# Compile origin program
clang-9 -emit-llvm -S ${fullname} -o ${basename}.ll
# Load obfuscator to obfuscate program
# You can change -obfstr option to other options
opt-9 -load /part/to/libObfuscator.so \
-obfstr ${basename}.ll \
-o ${basename}_obfuscated.bc
# If you are using ObfuscateString Pass, you should link encrypt.c with your program
# Compile to target platform
clang-9 ${basename}_obfuscated.bc -o ${basename}
The project has "borrow" some code from these projects:
MIT License