逆向基础知识及工具:class-dump

2020-06-25  本文已影响0人  船长_Kevin

Class-dump

This is a command-line utility for examining the Objective-C runtime information stored in Mach-O files. It generates declarations for the classes, categories and protocols. This is the same information provided by using ‘otool -ov’, but presented as normal Objective-C declarations, so it is much more compact and readable.

上面是官方的介绍
一句话简介
\color{red}{Class-dump是一个导出Mach-O头文件的一个命令工具}

普及一下什么是Mach-O文件

Mach-O文件结构
参考苹果官方文档,Mach-O文件结构由Header,Load Commands,Data三部分组成
详细Mach-O文件,以后我们再详谈,类型1,2一般为我们常常分析的文件


下面开始介绍具体用法

这是一个只有不到500K的一个小工具,官网下载后双击打开,将class-dump复制到/usr/local/bin目录,方便以后使用

image.png

命令行验证是否安装成功

$  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)
        -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 -H Mach-文件 -o 导出文件地址

导出的头文件,自己根据文件名和方法名猜吧,实际逆向过程中,很多工具需要配合使用,看自己习惯哪种工具MachOView、class-dump、Hopper Disassembler、ida


image.png

我没加密混淆的代码,基本把头文件都正确导出了.

image.png
上一篇 下一篇

猜你喜欢

热点阅读