Konran is a Clang plugin that automatically wraps every string literal in your C++ code with the OBF() macro at compile time. No source files are modified. No manual wrapping is required.
When paired with obfusheader.h, strings are XOR-encrypted during compilation and decrypted at runtime. Plaintext strings never appear in the binary.
source: key["mode"] = "encrypt";
|
v (Konran rewrites the compiler buffer)
|
memory: key[OBF("mode")] = OBF("encrypt");
|
v (obfusheader.h encrypts at compile time)
|
binary: XOR-garbage bytes instead of plaintext
|
v (runtime: obfuscator::decrypt() XORs back)
|
runtime: original strings restored
- Clang / LLVM (matching the version used by your NDK or system compiler)
- CMake 3.20+
- C++20
Konran supports:
- MODULE builds (Clang plugin)
- SHARED builds
- STATIC builds
cmake -B build \
-DBUILD_MODULE=ON \
-DBUILD_SHARED=ON \
-DBUILD_STATIC=ONDisable targets you do not want:
cmake -B build \
-DBUILD_MODULE=ON \
-DBUILD_SHARED=OFF \
-DBUILD_STATIC=OFFcmake --build build -j$(nproc)Use:
- Visual Studio toolchain
- MSVC
- Ninja or Visual Studio generator
Do not use MinGW with official LLVM binaries.
cmake -B build -G Ninja
cmake --build buildSome LLVM Windows releases export broken DIA SDK paths in generated CMake files. If linking fails with:
diaguids.lib
patch the generated LLVM CMake export from:
C:/Program Files/Microsoft Visual Studio/2022/Enterprise/...
to either:
diaguids.lib
or your installed Visual Studio edition path.
Artifacts are placed automatically into:
artifacts/<os>/<arch>/
Examples:
artifacts/windows/AMD64/Konran.dll
artifacts/windows/AMD64/Konran.lib
artifacts/windows/AMD64/KonranStatic.lib
artifacts/linux/x86_64/Konran.so
artifacts/macos/arm64/Konran.dylib
clang++ -c file.cpp -o file.o \
-Xclang -load \
-Xclang ./artifacts/linux/x86_64/Konran.so \
-Xclang -plugin \
-Xclang konran \
-Xclang -plugin-arg-konran \
-Xclang ./include/obfusheader.h \
source.cppclang++ -c file.cpp -o file.o \
-Xclang -load \
-Xclang ./artifacts/macos/arm64/Konran.dylib \
-Xclang -plugin \
-Xclang konran \
-Xclang -plugin-arg-konran \
-Xclang ./include/obfusheader.h \
source.cppclang++ -c file.cpp -o file.obj ^
-Xclang -load ^
-Xclang artifacts/windows/AMD64/Konran.dll ^
-Xclang -plugin ^
-Xclang konran ^
-Xclang -plugin-arg-konran ^
-Xclang include/obfusheader.h ^
source.cppEach -Xclang prefix passes the immediately following argument to the
Clang frontend. Write each frontend argument as a separate pair.
target_compile_options(your_target PRIVATE
-Xclang -load
-Xclang ${CMAKE_SOURCE_DIR}/artifacts/android/arm64-v8a/Konran.so
-Xclang -plugin
-Xclang konran
-Xclang -plugin-arg-konran
-Xclang ${CMAKE_SOURCE_DIR}/include/obfusheader.h
-fno-merge-constants
-fno-merge-all-constants
)Use // konran:off and // konran:on comment markers:
// konran:off
void debug_log(const char *msg) {
printf("DEBUG: %s\n", msg);
}
// konran:on
const char *secret = "this gets encrypted";Or on a single line:
const char *visible = "debug string"; // konran:offStrings on whitelisted lines are left untouched. Everything else is wrapped in OBF() automatically.
| String type | Konran behavior |
|---|---|
"hello" |
Wrapped in OBF() |
"line1" "line2" |
Wrapped as single OBF("line1" "line2") |
OBF("already") |
Left untouched (detects existing OBF() calls) |
R"(raw)" |
Left untouched |
'x' |
Left untouched |
#include "file" |
Left untouched |
"debug" // konran:off |
Left untouched |
Konran must be built against the same LLVM major version as the compiler that loads it. A plugin built for LLVM 18 will not load in Clang 19.
| NDK version | LLVM version |
|---|---|
| r25 | 16 |
| r26 | 17 |
| r27 | 18 |
| r28 | 20 |
- Konran hooks into Clang's compilation pipeline via PluginASTAction.
- Before the parser reads the source file, Konran reads it, transforms
every string literal
"..."intoOBF("..."), and provides the transformed source to the compiler via buffer remapping. - The obfusheader.h is force-included to make OBF() available.
- obfusheader.h's
obfuscatortemplate XORs each byte at compile time using a key derived from TIME and COUNTER. - At runtime,
decrypt()re-XORs the bytes to restore the original string. - The compiler proceeds normally with the transformed source.
- EmitObjAction handles codegen, producing the final object file with no plaintext strings.
CMakeLists.txt
src/Konran.cpp
include/obfusheader.h
Konran is released under the BSD 3-Clause license. obfusheader.h is licensed separately by its authors.
obfusheader.h by https://github.com/ac3ss0r/obfusheader.h