rust-native-obf
advanced native obfuscation library for rust
features
compile time obfuscation
- string encryption with pcg keystream
- byte array obfuscation
- wide string (utf-16) obfuscation
- compile time random number generation
- compile time hashing (xxhash32, sdbm)
- constant value encoding with mba
runtime obfuscation
- control flow obfuscation
- opaque predicates
- hidden function calls
- obfuscated conditionals
- cascade encryption
- stack trashing
advanced techniques
- static reference obfuscation
- pointer mangling
- obfuscated value storage
- anti-debugging checks
- tamper detection
- noise generation
usage
[]
= "0.1.0"
string obfuscation
use *;
let secret = obf_str!;
let bytes = obf_bytes!;
let wide = obf_wide!;
compile time features
let hash = ct_xxhash!;
let random = ct_rand!;
let encoded = obf_const!;
control flow
let result = hidden_call!;
obf_if!;
advanced obfuscation
static DATA: = ;
let obf_ref = obf_static_ref!;
let obf_val = new;
let original = obf_val.get;
let encrypted = cascade_encrypt;
anti-analysis
debug_trap!;
if !anti_debug
examples
how it works
string obfuscation - uses pcg random number generator for keystream generation, encrypts at compile time, decrypts with volatile reads to prevent constant folding
control flow - generates unique keys for each code block based on statement content, executes in randomized order
value encoding - uses mixed boolean arithmetic (mba) with rotation and multiplication for reversible encoding
pointer obfuscation - mangles static references using xxhash-based transformation with black_box to prevent llvm optimization
compile time rng - combines file location, line number, column with xxhash mixing and siphash for deterministic randomness
anti-debug - checks for debugger presence on windows, can be extended for other platforms
technical details
- no_std compatible core modules
- volatile memory operations
- black_box for compiler barrier
- const fn for compile time execution
- zero runtime overhead for constants
notes
this is obfuscation, not cryptography. designed to make reverse engineering harder, not impossible. do not use for hiding actual secrets in client binaries.
license
MIT