iOS逆向之class-dump

class-dump:用來dump目標文件的class信息的工具。它利用Objective-C語言的runtime的特性,將存儲在mach-O文件中的@interface和@protocol信息提取出來,并生成對應的.h文件。

1、下載地址:

http://stevenygard.com/projects/class-dump/

2、打開終端輸入

wifi:~ clf$ open /usr/local/bin

3、把dmg文件中的class-dump文件復制到/usr/local/bin

4、賦予其執(zhí)行權限權限:終端輸入

wifi:~ clf$ sudo chmod 777 /usr/local/bin/class-dump

5、運行class-dump,可以看到它的一些基本參數

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格式的二進制文件

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
錯誤集:
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:

原因:經檢驗和查看該項目是用OC和Swift混編。class-dump是利用Object-C語言的runtime特性,提取頭文件,而Swift則不支持該規(guī)則。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容