Git Product home page Git Product logo

obfuscator-llvm's Introduction

Obfuscator-LLVM

Obfuscator-LLVM is a project initiated in June 2010 by the information security group of the University of Applied Sciences and Arts Western Switzerland of Yverdon-les-Bains (HEIG-VD). The aim of this project is to provide increased software security through code obfuscation and tamper-proofing. As the obfuscator currently mostly works at the Intermediate Representation (IR) level, the tool is compatible with all programming languages (Ada, C, C++, D, Delphi, Fortran, Haskell, Julia, Objective-C, Rust and Swift) and target platforms (x86, x86-64, PowerPC, PowerPC-64, ARM, RISC-V, Thumb, SPARC, Alpha, CellSPU, MIPS, MSP430, SystemZ, and XCore) currently supported by LLVM version 13. The initially published source code and research paper can be found here. This fork makes the obfuscator available as an extension to most available LLVM installations. It doesn't require any changes to existing LLVM installations, unlike the project published by the authors of Obfuscator-LLVM.

Features

Here is a list of the different features that are currently available:

Building

To build this project it's required to have Clang 3.3+, LLVM 3.3+ and CMake 3.4+ installed. On Ubuntu 18.04+ you can use sudo apt install clang-7 llvm-7-dev cmake to install the required softwre. To compile the obfuscator simply run ./build.sh or execute the following commands in this directory:

mkdir -p build
cd build
cmake ../
cmake --build .

To build for old PassManager add CMake flag -DLLVM_ENABLE_NEW_PASS_MANAGER=OFF.

Usage

Adding the obfuscator to existing projects which use an LLVM compiler is very easy. For the Make (or rather Makefile) buildsystem simply adjust the small example below to fit your needs:

OBFUSCATOR_FLAGS=-Xclang -load -Xclang /path/to/ObfuscatorLLVM.so

# ... your targets

tool: tool.c utils.c helper.c clangtool.so
    $(CC) $(CXXFLAGS) $(OBFUSCATOR_FLAGS) -O0 -o test test.c

You can also integrate the obfuscator to your existing CMake projects for any project that uses LLVM:

target_compile_options(<name> PRIVATE -Xclang -load -Xclang /path/to/ObfuscatorLLVM.so)

Testing

The Himeno benchmark is used to test the effectiveness of the obfuscation techniques. To execute the obfuscator test run ./test.sh. This will generate LLVM IR from ./test/test.c, apply obfuscations on it and run the obfuscated program. The obfuscated LLVM IR can be found in ./test/test_obfuscated.ll and the non-obfuscated LLVM IR in ./test/test.ll.

obfuscator-llvm's People

Contributors

maxxor avatar sr-tream avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

obfuscator-llvm's Issues

clang (LLVM option parsing): Unknown command line argument '-sub'. Try: 'clang (LLVM option parsing) --help'

Happens when I try to cross build openssl from linux to windows. Why is that? The test works fine.

/usr/bin/clang -Xclang -load -Xclang obfuscator-llvm/build/obfuscator-llvm/ObfuscatorLLVM.so -mllvm -sub  -mllvm -bcf -mllvm -fla -m64 -Wa,--noexecstack -Qunused-arguments -target x86_64-w64-windows-gnu -v -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/usr/local/lib64/engines-3\"" -DMODULESDIR="\"/usr/local/lib64/ossl-modules\"" -DUNICODE -D_UNICODE -DWIN32_LEAN_AND_MEAN -D_MT -DOPENSSL_BUILDING_OPENSSL -DNDEBUG -I/usr/x86_64-w64-mingw32/include -c -o crypto/aes/libcrypto-lib-aes-x86_64.obj crypto/aes/aes-x86_64.s
        "/usr/bin/clang-14" -cc1as -triple x86_64-w64-windows-gnu -filetype obj -main-file-name aes-x86_64.s -target-cpu x86-64 -I /usr/x86_64-w64-mingw32/include -fdebug-compilation-dir=openssl -dwarf-debug-producer "clang version 14.0.0 (/build/llvm-git/llvm-project 75b08cce47df0a405bfb052f51d70b8e8067d705)" -I /usr/x86_64-w64-mingw32/include -dwarf-version=4 -mrelocation-model pic --mrelax-relocations -mnoexecstack -mllvm -sub -mllvm -bcf -mllvm -fla -o crypto/aes/libcrypto-lib-aes-x86_64.obj crypto/aes/aes-x86_64.s
        clang (LLVM option parsing): Unknown command line argument '-sub'.  Try: 'clang (LLVM option parsing) --help'
        clang (LLVM option parsing): Did you mean '-W'?
        clang (LLVM option parsing): Unknown command line argument '-bcf'.  Try: 'clang (LLVM option parsing) --help'
        clang (LLVM option parsing): Did you mean '-W'?
        clang (LLVM option parsing): Unknown command line argument '-fla'.  Try: 'clang (LLVM option parsing) --help'
        clang (LLVM option parsing): Did you mean '-W'?
        make[1]: *** [Makefile:12857: crypto/aes/libcrypto-lib-aes-x86_64.obj] Error 1
        make[1]: Leaving directory 'openssl'
        make: *** [Makefile:3233: build_sw] Error 2

M1 Errors

Compiling this project works fine with some tweaks to it, the problem is compiling the obfuscated IL to maschine code.

➜  test git:(master) ✗ sudo /opt/homebrew/opt/llvm/bin/clang -fuse-ld=lld -flto=full -O3 -Wl,-strip-all -o test test_obfuscated.ll

ld64.lld: error: unknown argument '-strip-all'
ld64.lld: error: cannot create /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/cc-932168.o/0.arm64.lto.o: Not a directory
LLVM ERROR: IO failure on output stream: Bad file descriptor
PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/homebrew/opt/llvm/bin/ld64.lld -demangle -object_path_lto /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/cc-932168.o -dynamic -arch arm64 -platform_version macos 12.0.0 12.0.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -o test -strip-all /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/test_obfuscated-324828.o -lSystem /opt/homebrew/Cellar/llvm/13.0.1/lib/clang/13.0.1/lib/darwin/libclang_rt.osx.a
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM.dylib            0x0000000107235774 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  libLLVM.dylib            0x0000000107235d48 SignalHandler(int) + 324
2  libsystem_platform.dylib 0x00000001867d44e4 _sigtramp + 56
3  libsystem_pthread.dylib  0x00000001867bceb0 pthread_kill + 288
4  libsystem_c.dylib        0x00000001866fa314 abort + 164
5  libLLVM.dylib            0x000000010718f624 llvm::report_fatal_error(llvm::Twine const&, bool) + 256
6  libLLVM.dylib            0x00000001099c0e7c llvm::report_fatal_error(llvm::StringRef, bool) + 0
7  libLLVM.dylib            0x0000000107218ff0 llvm::raw_fd_ostream::~raw_fd_ostream() + 232
8  lld                      0x000000010079be30 lld::saveBuffer(llvm::StringRef, llvm::Twine const&) + 500
9  lld                      0x0000000100a3809c lld::macho::BitcodeCompiler::compile() + 1240
10 lld                      0x0000000100a12a58 lld::macho::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) + 16984
11 lld                      0x000000010078a9b8 lldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&, bool) + 1128
12 lld                      0x000000010078a3e4 main + 212
13 dyld                     0x00000001011250f4 start + 520
clang-13: error: unable to execute command: Abort trap: 6
clang-13: error: linker command failed due to signal (use -v to see invocation)

Compilation Error - Ubuntu 18

Installed the Pre-Requisites using command - sudo apt install clang-7 llvm-7-dev cmake

sysadmin@sysadmin-VirtualBox:~/Desktop/Obfuscator-LLVM/obfuscator-llvm$ ./build.sh
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test C_SUPPORTS_FPIC
-- Performing Test C_SUPPORTS_FPIC - Success
-- Performing Test CXX_SUPPORTS_FPIC
-- Performing Test CXX_SUPPORTS_FPIC - Success
-- Building with -fPIC
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME
-- Performing Test C_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME
-- Performing Test CXX_SUPPORTS_WERROR_DATE_TIME - Success
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Failed
-- Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
-- Performing Test CXX_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Failed
-- Performing Test CXX_SUPPORTS_CXX11
-- Performing Test CXX_SUPPORTS_CXX11 - Success
-- Performing Test C_SUPPORTS_FNO_FUNCTION_SECTIONS
-- Performing Test C_SUPPORTS_FNO_FUNCTION_SECTIONS - Success
-- Performing Test C_SUPPORTS_FFUNCTION_SECTIONS
-- Performing Test C_SUPPORTS_FFUNCTION_SECTIONS - Success
-- Performing Test CXX_SUPPORTS_FFUNCTION_SECTIONS
-- Performing Test CXX_SUPPORTS_FFUNCTION_SECTIONS - Success
-- Performing Test C_SUPPORTS_FDATA_SECTIONS
-- Performing Test C_SUPPORTS_FDATA_SECTIONS - Success
-- Performing Test CXX_SUPPORTS_FDATA_SECTIONS
-- Performing Test CXX_SUPPORTS_FDATA_SECTIONS - Success
-- Linker detection: GNU ld
CMake Error at obfuscator-llvm/CMakeLists.txt:4 (add_llvm_pass_plugin):
Unknown CMake command "add_llvm_pass_plugin".

-- Configuring incomplete, errors occurred!
See also "/home/sysadmin/Desktop/Obfuscator-LLVM/obfuscator-llvm/build/CMakeFiles/CMakeOutput.log".
See also "/home/sysadmin/Desktop/Obfuscator-LLVM/obfuscator-llvm/build/CMakeFiles/CMakeError.log".
make: *** No targets specified and no makefile found. Stop.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.