Giter Site home page Giter Site logo

0xlane / ollvm-rust Goto Github PK

View Code? Open in Web Editor NEW
34.0 1.0 11.0 206 KB

out-of-tree llvm obfuscation pass plugin (dynamically loadable by rustc). || rust toolchain with obfuscation llvm pass.

CMake 1.39% C++ 98.61%
llvm llvm-pass obfuscation ollvm ollvm-obfuscation rust

ollvm-rust's Introduction

ollvm-pass

Out-of-tree llvm obfuscation pass,可在编译时对二进制进行混淆,通过 rustc/opt 动态加载使用,无需重新编译 llvm 和 rustc,支持以下混淆方式:

  • 间接跳转,并加密跳转目标(-irobf-indbr)
  • 间接函数调用,并加密目标函数地址(-irobf-icall)
  • 间接全局变量引用,并加密变量地址(-irobf-indgv)
  • 字符串(c string)加密功能(-irobf-cse) (rust 中不生效,已知问题)
  • 过程相关控制流平坦混淆(-irobf-cff)
  • 全部 (-irobf-indbr -irobf-icall -irobf-indgv -irobf-cse -irobf-cff)

混淆插件提取自 Arkari 项目。

注意:该项目当前仅在 windows x86 下测试,其他平台未测试

effect.png

rust 动态加载

动态加载 llvm pass 插件需切换到 nightly 通道(Allow loading of LLVM plugins [when dynamically built rust]):

rustup toolchain install nightly

生成一个示例项目,通过 -Zllvm-plugins 参数加载 pass 插件,并通过 -Cpasses 参数指定混淆开关:

cargo new helloworld --bin
cd helloworld
cargo +nightly rustc --target x86_64-pc-windows-msvc --release -- -Zllvm-plugins="/path/to/LLVMObfuscationx.dll" -Cpasses="irobf(irobf-indbr,irobf-icall,irobf-indgv,irobf-cff,irobf-cse)"

opt 动态加载

# 使用 clang 编译源代码并生成 IR
clang -emit-llvm -c input.c -o input.bc

# 使用 opt 工具加载和运行自定义 Pass
opt -load-pass-plugin="/path/to/LLVMObfuscationx.dll" --passes="irobf(irobf-indbr,irobf-icall,irobf-indgv,irobf-cff,irobf-cse)" input.bc -o output.bc

# 将 IR 文件编译为目标文件
llc -filetype=obj output.bc -o output.o

# 链接目标文件生成可执行文件
clang output.o -o output.exe

x86 msvc pass 编译方法

环境

  • Windows 11 (10.0.22631.3737)
  • Visual Studio 2022 (17.10.3)
    • 使用 C++ 的桌面开发
  • LLVM 18.1.5

编译

需在 x64 Native Tools Command Prompt for VS 2022 环境中执行,从开始菜单或者执行 cmd.exe /k "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -startdir=none -arch=x64 -host_arch=x64 进入:

git clone --branch ollvm-pass https://github.com/0xlane/ollvm-rust.git
cd ollvm-rust
cmake -G "Ninja" -S .\ollvm-pass -B .\build -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLT_LLVM_INSTALL_DIR=D:\dev\rust_ollvm\llvm-build\llvm_x64
cmake --build .\build\ -j12 # change 12 to yourself nproc

LT_LLVM_INSTALL_DIR 需指定为自己的 LLVM 安装路径

参考

感谢

ollvm-rust's People

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

Watchers

 avatar

ollvm-rust's Issues

How to compile the plugin?

Thank you for doing great work!
I'm new to LLVM and don't know how to setup an environment to build the plugin. Please put an step-by-step of how to compile the plugin.
Thank you very much!

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.