iOS逆向 - Mach-O

2019-06-28  本文已影响0人  linleiqin

简介

Mach-O是Mach object的缩写,是Mac\iOS上用于存储程序、库的标准格式

属于Mach-O格式的文件类型有

可以在xnu源码中,查看到Mach-O格式的详细定义

xnu/EXTERNAL_HEADERS/mach-o/loader.h
#define MH_OBJECT   0x1     /* relocatable object file */
#define MH_EXECUTE  0x2     /* demand paged executable file */
#define MH_FVMLIB   0x3     /* fixed VM shared library file */
#define MH_CORE     0x4     /* core file */
#define MH_PRELOAD  0x5     /* preloaded executable file */
#define MH_DYLIB    0x6     /* dynamically bound shared library */
#define MH_DYLINKER 0x7     /* dynamic link editor */
#define MH_BUNDLE   0x8     /* dynamically bound bundle file */
#define MH_DYLIB_STUB   0x9     /* shared library stub for static */
                    /*  linking only, no section contents */
#define MH_DSYM     0xa     /* companion file with only debug */
                    /*  sections */
#define MH_KEXT_BUNDLE  0xb     /* x86_64 kexts */

常见的Mach-O文件类型


Mach-O的基本结构

一个Mach-O文件包含3个主要区域


窥探Mach-O的结构

1、命令行工具

file:查看Mach-O的文件类型

file 文件目录

otool:查看Mach-O特定部分和段的内容

lipo:常用于多架构Mach-O文件的处理
查看架构信息:

lipo  -info  文件路径

导出某种特定架构:

lipo  文件路径  -thin  架构类型  -output  输出文件路径

合并多种架构:

lipo  文件路径1  文件路径2  -output  输出文件路径

2、GUI工具

MachOView

dyld和Mach-O


其他

在Xcode中查看target的Mach-O类型

Build Settings->Mach-O Type


Xocde
上一篇 下一篇

猜你喜欢

热点阅读