iOS 静态库代码混淆方案

基于开源 Obfuscator-LLVM方案

下载安装最新版本 Obfuscator-LLVM,目前3.6.1

$ git clone -b llvm-3.6.1 https://github.com/obfuscator-llvm/obfuscator.git

$ mkdir build

$ cd build

$ cmake -DCMAKE_BUILD_TYPE:String=Release ../obfuscator/

$ make -j5

将build/bin加入环境变量

$vim ~/.bash_profile

export PATH=/Users/dream/ollvm/build/bin:$PATH

$source ~/.bash_profile

配置Xcode,当前版本 7.1

基于现有插件修改如下:

$ cd /Applications/Xcode-beta.app/Contents/PlugIns/Xcode3Core.ideplugin/Contents/SharedSupport/Developer/Library/Xcode/Plug-ins/

$ sudo cp -r Clang\ LLVM\ 1.0.xcplugin/ Obfuscator.xcplugin

$ cd Obfuscator.xcplugin/Contents/

$ sudo plutil -convert xml1 Info.plist

$ sudo vim Info.plist

修改文件内容(修改前->修改后)

<string>com.apple.compilers.clang</string> -> <string>com.apple.compilers.obfuscator</string>

<string>Clang LLVM 1.0 Compiler Xcode Plug-in</string> -> <string>Obfuscator Xcode Plug-in</string>

接下来修改Info.plist

$ sudo plutil -convert binary1 Info.plist

$ cd Resources/

$ sudo mv Clang\ LLVM\ 1.0.xcspec Obfuscator.xcspec

$ sudo vim Obfuscator.xcspec

修改为:

Identifier = "com.apple.compilers.llvm.clang.1_0"; -> Identifier = "com.apple.compilers.llvm.obfuscator.3_6_1";

Name = "Apple LLVM 7.0"; -> Name = "Obfuscator 3.6.1";

Description = "Apple LLVM 7.0 compiler"; -> Description = "Obfuscator 3.6.1";

Vendor = Apple; -> Vendor = HEIG-VD;

Version = "7.0"; -> Version = "3.6.1";

ExecPath = "clang"; -> ExecPath = "/Users/dream/ollvm/build/bin/clang";

接下来修改显示:

$ cd English.lproj/

$ sudo mv Apple\ LLVM\ 7.0.strings "Obfuscator 3.6.1.strings"

$ sudo vim Obfuscator\ 3.6.1.strings

修改为:

"Name" = "Apple LLVM 7.0"; -> "Name" = "Obfuscator 3.6.1";

"Description" = "Apple LLVM 7.0 Compiler"; -> "Description" = "Obfuscator 3.6.1";

"Version" = "7.0"; -> "Version" = "3.6.1";

"Vendor" = "Apple"; -> "Vendor" = "HEIG-VD";

重启Xcode,Build Options里面,可以设置Compiler for C/C++/Objective-C为Obfuscator 3.6.1, 在CustomFlags中自行添加 flag:

-mllvm -sub -mllvm -fla -mllvm -bcf

解决几个问题

编译时出错,提示信息如下:

clang-3.6: error: unknown argument: '-gmodules'

clang-3.6: error: unknown argument: '-fembed-bitcode-marker'

Command /Users/dream/ollvm/build/bin/clang failed with exit code 1

在 Build Settings中搜索并修改:

-gmodules: Obfuscator 3.6.1 - Code Generation: Generate Debug Symbols: 原来yes,改成no

-fembed-bitcode-marker: Build Option: Enable Bitcode: 原来yes,改成no

转载于:https://my.oschina.net/superkv/blog/733305

展开阅读全文
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
©️2020 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值