1.採用LLVM進行Native層代碼混淆,先看一下混淆的效果
混淆之前的函數:
混淆之後的函數:
混淆後的函數體幾乎變得無法閱讀!
2.再看文件大小變化:
混淆前:
混淆後:
3.如何集成:
首先下載源碼並編譯,參考:https://github.com/obfuscator-llvm/obfuscator/wiki/Installation
下面是實際用到的命令:
$ git clone -b llvm-4.0 https://github.com/obfuscator-llvm/obfuscator.git
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_INCLUDE_TESTS=OFF ../obfuscator/
$ make -j4
4.上面編譯完成後,將build目錄下的所有文件複製到ndk的toolchains/llvm/prebuilt/linux-x86_64目錄中
編譯後的build目錄:
全部複製到toolchains/llvm/prebuilt/linux-x86_64目錄下(有相同文件則覆蓋):
5.在Android.mk中配置混淆選項
也就是加入下面這段:
LOCAL_CFLAGS += -mllvm -sub -mllvm -bcf -mllvm -fla
各個選項說明文檔:https://github.com/obfuscator-llvm/obfuscator/wiki/Features
中文版: https://www.cnblogs.com/20143605--pcx/p/10314863.html
6.操作完成,編譯項目工程即可。