class-dump:用來dump目標(biāo)文件的class信息的工具。它利用Objective-C語言的runtime的特性沟启,將存儲在mach-O文件中的@interface和@protocol信息提取出來型型,并生成對應(yīng)的.h文件段审。
1、下載地址:
http://stevenygard.com/projects/class-dump/
2闹蒜、打開終端輸入
wifi:~ clf$ open /usr/local/bin
3寺枉、把dmg文件中的class-dump文件復(fù)制到/usr/local/bin
4、賦予其執(zhí)行權(quán)限權(quán)限:終端輸入
wifi:~ clf$ sudo chmod 777 /usr/local/bin/class-dump
5嫂用、運(yùn)行class-dump型凳,可以看到它的一些基本參數(shù)
wifi:~ clf$ 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)
class-dump的對象是Mach-O格式的二進(jìn)制文件
class-dump使用
class-dump -S -s -H 可執(zhí)行文件路徑 -o 獲取到頭文件存放路徑
wifi:Documents clf$ class-dump -S -s -H /Users/ppd/Documents/TargetApp.decrypted -o /Users/ppd/Documents/TargetApp
錯(cuò)誤集:
wifi:~ clf$ class-dump -S -s -H /Users/clf/Desktop/breakApp/TargetApp.decrypted -o /Users/clf/Desktop/breakApp/headers
2018-01-24 14:41:03.632 class-dump[1206:394495] Error: Cannot find offset for address 0x1800000001003c7a in stringAtAddress:
原因:經(jīng)檢驗(yàn)和查看該項(xiàng)目是用OC和Swift混編。class-dump是利用Object-C語言的runtime特性嘱函,提取頭文件甘畅,而Swift則不支持該規(guī)則。