Closed HakonHarnes closed 1 year ago
The passes ENV variables doesn't accept spaces between ,
The passes ENV variables doesn't accept spaces between
,
I'll give it a try! We should probably update the README. It uses spaces between ,
.
Hmm, doesn't seem to resolve the issue for me. Here's what I've tried:
export LLVM_OBF_OPTIMIZERLASTEP_PASSES="flattening,bogus,substitution,split-basic-blocks"
clang -fno-legacy-pass-manager -fpass-plugin=/obfuscator-llvm/build/libLLVMObfuscator.so main.c -o obf
export LLVM_OBF_OPTIMIZERLASTEP_PASSES="flattening,bogus,substitution,split-basic-blocks"
clang -fpass-plugin=/obfuscator-llvm/build/libLLVMObfuscator.so main.c -o obf
export LLVM_OBF_OPTIMIZERLASTEP_PASSES="flattening"
clang -fno-legacy-pass-manager -fpass-plugin=/obfuscator-llvm/build/libLLVMObfuscator.so main.c -o obf
It does seem like the plugin is being invoked, since:
export LLVM_OBF_DEBUG_SEED="y"
clang -fpass-plugin=/obfuscator-llvm/build/libLLVMObfuscator.so main.c -o obf
Gives:
SEED = 0xEF0E14E9BFCD370DBB4396B84B7FD670
What could be the issue here?
Edit: Adding print statements to the addPassWithName
in Plugin.cpp
I can see that all of the obfuscations passes are being applied. However, there is still no difference in the between the original and obfuscated binaries.
Hi again,
I didn't noticed but you need to apply optimization options (at least -01
to trigger the passes with a pass plugin). When using clang, without any -O
the passes are not applied.
This is not the case with opt
command if I remember correctly.
# clang Install
PATH="./install-llvm/14/bin:$PATH" clang --version
custom clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /mnt/llvm/./install-llvm/14/bin
# Compiling with clang and without optimizations
PATH="./install-llvm/14/bin:$PATH" clang src-github-issues/issue-10.c -o /tmp/issue-10_original_no_opts
# Compiling with clang with -O1
PATH="./install-llvm/14/bin:$PATH" clang -O1 src-github-issues/issue-10.c -o /tmp/issue-10_original_opts
# Compiling with clang without optimizations and the plugin/passes
PATH="./install-llvm/14/bin:$PATH" LLVM_OBF_SCALAROPTIMIZERLATE_PASSES="flattening,bogus,substitution,split-basic-blocks" clang -fno-legacy-pass-manager -fpass-plugin=b
uild-ollvm/libLLVMObfuscator.so src-github-issues/issue-10.c -o /tmp/issue-10_obfuscated_no_opts
# Compiling with clang with -O1 and the plugin/passes
PATH="./install-llvm/14/bin:$PATH" LLVM_OBF_SCALAROPTIMIZERLATE_PASSES="flattening,bogus,substitution,split-basic-blocks" clang -O1 -fno-legacy-pass-manager -fpass-plugin=build-ollvm/libLLVMObfuscator.so src-github-issues/issue-10.c -o /tmp/issue-10_obfuscated_opts
Comparing the differences
ls /tmp/issue-10* -al
-rwxr-xr-x 1 test test 16512 Mar 21 14:37 /tmp/issue-10_obfuscated_no_opts
-rwxr-xr-x 1 test test 16568 Mar 21 14:37 /tmp/issue-10_obfuscated_opts
-rwxr-xr-x 1 test test 16512 Mar 21 14:36 /tmp/issue-10_original_no_opts
-rwxr-xr-x 1 test test 16520 Mar 21 14:36 /tmp/issue-10_original_opts
As you can see /tmp/issue-10_original_no_opts
and /tmp/issue-10_original_no_opts
are the same
diff -u /tmp/issue-10_original_no_opts /tmp/issue-10_obfuscated_no_opts
When compiling with clang
you need to enable optimizations to force use of the plugin.
Edit: ... and -O1
was missing in the README ... sorry
Thank you! It works now.
I'm successful in building LLVM and the obfuscation plugin, however I'm unable to apply the obfuscation passes. What am I missing here?
main.c
(https://github.com/heroims/obfuscator/wiki/Bogus-Control-Flow)
Compile without obfuscation
Compile with obfuscation
Compare binaries
Binaries are the same. I've also tried:
Still, obfuscation is not applied.
Dockerfile