zoukankan      html  css  js  c++  java
  • 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

    补充

    ---

    2016年10月28日18:56:14

    目前该方法兼容最新版xcode:8.0

  • 相关阅读:
    Java中符号位扩展
    BZOJ2754: [SCOI2012]喵星球上的点名(AC自动机)
    BZOJ1030: [JSOI2007]文本生成器(AC自动机)
    BZOJ2434: [Noi2011]阿狸的打字机(AC自动机 树状数组)
    BZOJ1432: [ZJOI2009]Function(找规律)
    BZOJ2659: [Beijing wc2012]算不出的算式(数学)
    洛谷P3796 【模板】AC自动机(加强版)
    洛谷P3966 [TJOI2013]单词(AC自动机)
    BZOJ2580: [Usaco2012 Jan]Video Game(AC自动机)
    后缀自动机经典操作
  • 原文地址:https://www.cnblogs.com/gm-201705/p/9864071.html
Copyright © 2011-2022 走看看