Securityv0.2.0

ensia

The next-generation LLVM obfuscator

AGPL-3.0-onlyC++ · LLVM IRLLVM 21 · 22 · 23+
15
Obfuscation passes
interleaved, not stacked
12
Pipeline stages
cascading
5.6–103.6×
Binary size expansion
by domain
2³²
CSM state space
Q32 fixed point

Overview

Ensia (OLLVM-Next) is an LLVM-based obfuscation framework that continues the Hikari lineage with a transformation engine rebuilt for LLVM 21 and later. It targets Linux, Windows (MSVC, clang-cl, MinGW), macOS, iOS and Android, with first-class support for x86_64, AArch64 and i386.

The design rejects the virtualizer's single point of failure. There is no central interpreter to devirtualise; fifteen passes are interleaved across a twelve-stage cascade, so the output of each pass is the input of the next and an analyst has to survive the composition rather than defeat one mechanism.

Support is tiered rather than claimed uniformly: Linux and Windows on x86_64 and AArch64 are release blockers, macOS and FreeBSD follow, and the rest — OpenBSD, iOS, Android, RISC-V, i386 — is best-effort with issue response only.

Capabilities

what it does

No single point of failure

Ensia rejects the virtualizer's central interpreter. Fifteen passes are composed so that removing one does not reveal the rest.

Chaos state machine

Control flow is replaced by a logistic-map dynamical system in Q32 fixed point, with a 2³² state space and cellular-automaton attractors.

Hardware opaque predicates

CPUID feature bits, RDTSC parity and CNTPCT_EL0 make branch conditions impossible to fold without executing them.

String and constant encryption

Vernam OTP over a Rijndael GF(2⁸) layer, decrypted by inlined stubs that zeroize on return; constants use MBA shares or Feistel mixing.

Import elimination

Function-call obfuscation resolves calls at runtime through dlopen/dlsym or GetProcAddress, so the import table stops describing the binary.

Metadata elimination

DWARF, COMDATs, llvm.ident and internal symbols are stripped or scrambled, and every function is stamped noinline optnone to survive LTO.

How it works

design notes
01

Cascade order, not a pass list

Anti-hook and anti-class-dump run first, then wrappers and call obfuscation, then the per-function loop, then a second constant-encryption phase and branch encryption. Each stage assumes the previous one already ran.

02

Per-function loop

Inside the loop the order is fixed: substitution, MBA, block splitting, bogus control flow, then either the chaos state machine or classic flattening, then vector lifting. Splitting before flattening is what forces MBA expressions across block boundaries.

03

Two-phase constant encryption

Programmer literals are encrypted before the CFG is rewritten, and the state constants produced by BCF, CSM and CFF are encrypted afterwards, so the keys themselves are not left in the clear.

04

Cleanup and symbol scrambling

Temporary sentinels are erased, DWARF and COMDATs are stripped, the translation-unit path is anonymised, and internal symbols are rewritten to hashed names.

05

Policy engine

Ordered rules match module paths and function symbols with regular expressions; the first match wins, so a hot function can be excluded while the rest of the binary is treated at full strength.

06

Toolchain integration

The pass plugin loads through clang's -fpass-plugin or rustc's -Z llvm-plugins. Configuration is discovered from ensia.toml, ENSIA_CONFIG or -mllvm, and presets run from low to max.

Measured expansion

project benchmarks
Mean binary code footprint expansion under the maximum profile, by cryptographic domain, across eight domains. Individual binaries range from 5.57× (ML-KEM-768) to 139.19× (RSA-2048).
DomainMean expansionNote
Post-quantum (PQC)5.6×smallest footprint
Lightweight / AEAD39.0×—
Block cipher48.2×—
Hash / digest48.5×—
Stream cipher50.2×—
MAC / authenticator55.6×—
KDF / password64.1×—
Asymmetric / PKC103.6×largest footprint
Horizontal bar chart of binary code size expansion per cryptographic domain, from 5.6x for post-quantum to 103.6x for asymmetric cryptography.
Mean binary footprint expansion by domain, with the minimum and maximum of each domain marked.

Install

cargo
shell — clang
# build the pass plugin, then load it
clang -fpass-plugin=/path/to/libEnsia.so \
      -O2 main.c -o main

# pick a preset instead of a full config
ENSIA_PRESET=mid clang -fpass-plugin=/path/to/libEnsia.so \
      -O2 main.c -o main

Presets run from low to max. Configuration is discovered from ./ensia.toml, ENSIA_CONFIG, or -mllvm -ensia-config. A Rust frontend plugin is available for cargo builds. Read ETHICS.md before use: this is dual-use tooling.