Android Obfuscator NDK 23 for Windows
Fully tested
- Origin NDK : 23c (23.2.8568313)
- Clang : 12.0.9
- LLVM : 12.0.9
Add CMAKE_C_FLAGS in CmakeLists.txt file
This will apply the obfuscation, module by module.
set(CMAKE_C_FLAGS "-mllvm -fla -mllvm -bcf -mllvm -sub -mllvm -sobf")
Or, in case of using Android.mk
:
LOCAL_CFLAGS := -Wall -D__MODULE__=\"$(LOCAL_MODULE)\" -fcommon -mllvm -fla -mllvm -bcf -mllvm -sub -mllvm -sobf
Currently available options
Option | Description |
---|---|
-mllvm -sub | substitution |
-mllvm -fla | flattening |
-mllvm -bcf | bogus |
-mllvm -sobf | string obf |
Env | Desc |
---|---|
Built on | Ubuntu 16.04 (VM) |
Host | windows |
Avoid using ubuntu 20.04 -> might have sym-link problem
- Check for exact NDK version and branch
Check AndroidVersion.txt from
{NDK_PATH}}\toolchains\llvm\prebuilt\windows-x86_64
12.0.9
based on r416183c2
- Download repo bin for clone from google source repository
curl https://storage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo
chmod a+x /usr/bin/repo
Upgrade to python 3.9 if lower
##### Download required packages sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \ libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev ##### Download cd /opt sudo wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz sudo tar xzf Python-3.9.1.tgz cd Python-3.9.1 sudo ./configure --enable-optimizations sudo make altinstall sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.9 1
- Download essential packages to build ndk toolchain
##### CMAKE and bison for toolchain build
apt install cmake bison
- Check for manifest file in original ndk
##### Search for "manifest" in original ndk directory
-> Result : manifest_8481493.xml
- Clone the repo
mkdir llvm-toolchain && cd llvm-toolchain
repo init -u https://android.googlesource.com/platform/manifest -b llvm-toolchain
## >>> [COPY {NDK_PATH}/~~/manifest_8181493.xml to llvm-toolchain/.repo/manifests]
repo init -m manifest_8481493.xml
repo sync -c
- Build with
--no-build linux
option
python toolchain/llvm_android/build.py --no-build linux
- Cherry pick the source from ollvm 12.x
# Changing Targets :
cp -r {TARGET}/llvm/lib/Transforms/Obfuscation {SOURCE}/llvm/lib/Transforms/Obfuscation
cp -r {TARGET}/llvm/include/Transforms/Obfuscation {SOURCE}/llvm/include/Transforms/Obfuscation
# add Obfuscation to
-> lib/Transforms/IPO/CMakeList.txt
-> lib/Transforms/CMakeList.txt
#Cherry pick the sources from lib/Transforms/IPO/PassManagerBuilder.cpp
- Build again
python toolchain/llvm_android/build.py --no-build linux
out/install/windows-x86/clang-dev
from result corresponds to toolchains/llvm/prebuilt/windows-x86-64
so, copy and paste the output(clang-dev) to original ndk directory
don't forget to manually substitute symbolic-linked binaries in bin/
(usually 1KB files in output are symbolic linked, except lldb.cmd)
NONE
NDK documentation, guides, and API reference are available on our website.
NDK code samples are available on GitHub.
Information about Android Studio can be found on the Android Studio website.
NDK bugs should be filed on GitHub.
Android Studio and Gradle bugs should be filed in the Android Studio Bug Tracker. For the fastest response, make sure you follow their guide on Filing Bugs.