iOS 逆向class-dump获取app头文件

先附上class-dump的下载地址http://stevenygard.com/projects/class-dump/

class-dump是用来dump目标文件的类信息的工具。它利用Objective-C语言的runtime的特性,将存储在mach-O文件中的@interface和@protocol信息提取出来,并生成对应的.h文件。

从这一段介绍中可以看出来,class-dump只支持纯粹的OC项目,只要是Swift和OC的混编项目,这个工具是没有任何作用的。所以只能直接用 IDA 看了(IDA 打开 Mach-O 文件,左边函数显示栏结合搜索功能,也可以大概查看类里面的方法)

下面介绍一下使用方法:
打开下载好的dmg文件,将class-dump的可执行文件复制到/usr/local/bin/目录下
在终端输入

class-dump 显示如下:

YoussefdeMacBook-Pro:~ youssef$ 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)

下面是一个例子,将桌面上的Video.app文件的头文件取出后放到桌面的headers文件夹里。参数的使用说明请仔细看上面的介绍。

class-dump --arch armv7 -S -s -H /Users/youssef/Desktop/Video.app -o /Users/youssef/Desktop/headers

首先说明一点,因为class-dump的作用对象必须是未经加密的可执行文件,而App Store中下载的App都是经过签名加密的,所以我们需要先进行砸壳,或者从pp助手下载越狱版本的app。

如果出现

class-dump[4053:282734] Error: Cannot find offset for address 0x8000000001029ea9 in stringAtAddress:

这样的错误,说明项目是Swift-OC混编的。

猜你喜欢

转载自blog.csdn.net/youshaoduo/article/details/81080648