class-dump最新安装方法

当Mac升级了OSX 10.11后,配置class-dump的时候,会发现逆向书上推荐的class-dump存放目录/usr/bin,class-dump存放不进去,尝试过用sudo 还是不被允许。

  • 原因是 OSX10.11的一个新特性 Rootless,也叫System Integrity Protection(SIP)和SELinux差不多,都是限制root用户的权限。
    其实可以在RecoveryMode关闭这个特性,这样就直接可以读写/usr/bin了,不过不建议。
    (关闭方法:开机的时候按住option出现选择磁盘的界面按command + R进入RecoveryMode,选择实用工具终端,输入csrutil disable回车搞定)

查找网上的资料,目前我用的方法是改变 class-dump 的环境变量来使用。
class-dump下载地址:http://stevenygard.com/projects/class-dump/

  1. 首先打开Terminal,输入mkdir ~/bin,在当前用户根目录下创建一个bin目录。
  2. 把下载下来的 dmg 打开,复制文件里面的class-dump到创建的bin目录下。赋予其可执行权限:
    chmod +x ~/bin/class-dump
  3. 打开bash_profile文件配置环境变量:
    vim ~/.bash_profile
    **按下 i 键进入编辑状态,在最下方加一行 **
    export PATH=$HOME/bin/:$PATH
    按下esc键,再按shift+: 输入 wq进行保存退出编辑
  4. 在Terminal中执行source ~/.bash_profile
  5. 测试是否改变成功

测试结果为:

MelodydeMBP:~ melody$ class-dump 
class-dump 3.5 (64 bit)
Usage: class-dump [options] <mach-o-file>

  where options are:
        -a             show instance variable offsets
        -A             show implementation addresses
        --arch <arch>  choose a specific architecture from a universal binary (ppc, ppc64, i386, x86_64, armv6, armv7, armv7s, arm64)
        -C <regex>     only display classes matching regular expression
        -f <str>       find string in method name
        -H             generate header files in current directory, or directory specified with -o
        -I             sort classes, categories, and protocols by inheritance (overrides -s)
        -o <dir>       output directory used for -H
        -r             recursively expand frameworks and fixed VM shared libraries
        -s             sort classes and categories by name
        -S             sort methods by name
        -t             suppress header in output, for testing
        --list-arches  list the arches in the file, then exit
        --sdk-ios      specify iOS SDK version (will look in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS<version>.sdk
        --sdk-mac      specify Mac OS X version (will look in /Developer/SDKs/MacOSX<version>.sdk
        --sdk-root     specify the full SDK root path (or use --sdk-ios/--sdk-mac for a shortcut)
MelodydeMBP:~ melody$

到了这里 class-dump的安装基本完成了^ ^

感谢你们的阅读,欢迎来纠错与交流。

参考链接:
http://bbs.iosre.com/t/10-11-usr-bin-class-dump/1936/8
http://blog.csdn.net/majiakun1/article/details/52064435



作者:San心两yi_钟
链接:https://www.jianshu.com/p/025fa775f3a6
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

猜你喜欢

转载自my.oschina.net/huqiji/blog/1626921