executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
re-iosiOS 应用分析:Mach-O、class-dump、越狱环境。 触发词:ios逆向、ipa、class-dump、越狱
Independent GitHub snapshot · Automated classification · Original documentation governs
静态分析(解包 / class-dump / otool)可免沙箱;动态(越狱设备 / 模拟器 / 受管设备)按 [[re-analyze/platform-tips]] 最高原则在受控环境执行。
apt install unzip / dnf install unzip / pacman -S unzipunzip -vbrew install class-dump 公式已从 homebrew-core 下架(2026 实测 formulae.brew.sh 无此公式),不再可用class-dump --help(输出 usage 即可)xcode-select --install(Xcode Command Line Tools)llvm-otool(apt install llvm / brew install llvm)otool -h /bin/lsbrew install libimobiledevice(含 idevice_id / ideviceinfo / ideviceinstaller)apt install libimobiledevice-utils(Debian/Ubuntu);Arch: pacman -S libimobiledeviceidevice_id -l 列出已连接设备 UDID;ideviceinfo 输出设备型号/iOS 版本/UDIDssh root@<设备IP> 能登录App Store 加密应用的解密后端按目标 iOS 与越狱版本选择已适配当前 Frida API 的维护实现,没有跨版本通用的单一工具。
frida --version 与设备 frida-server 版本对齐,再选与该 Frida 世代兼容的 dumper。Frida 17 起移除了静态 Module 查找/枚举 API(见 [[re-frida]] 常见坑),仍依赖这些旧 API 的 dumper 在 Frida 17 下直接报错AloneMonkey/frida-ios-dump 的 Frida agent 使用 Module.ensureInitialized、静态 Memory.read*、Module.findExportByName(null, …)、Process.enumerateModulesSync——这些 API 在 Frida 17 已移除,该仓库更适合作为脱壳算法与 Mach-O 重组逻辑的参考;直接使用需搭配 Frida 16 及以下的 frida-server,或自行按新版 API 移植mremap_encrypted 的实现(UnFairPlay / unfaird 一类),不依赖 frida 运行时插桩,按目标 iOS 版本评估可用性brew install libusbmuxd(原 usbmuxd 公式已改名);Linux apt install usbmuxd(Debian/Ubuntu,含 iproxy);Arch pacman -S libusbmuxdiproxy -h(转发工具可用性);选定 dumper 按其自身 -h 输出确认参数按顺序执行,每步记下结果(证据路径 + sha256,见 [[re-triage]])。
ipa 解包与签名检查:
unzip app.ipa -d app/
file app/Payload/*.app/* # 确认主二进制是 arm64 Mach-O
codesign -dv app/Payload/*.app/ 2>&1 # 签名类型(Apple Distribution / Development / adhoc)
otool -l app/Payload/*.app/ | grep -B1 -A4 LC_ENCRYPTION_INFO # 查 cryptid
cryptid 1 = App Store 加密,磁盘上代码是密文,先脱壳(步骤 5)再继续。
Payload/<App>.app/ 是主二进制与资源;SwiftSupport/ 是系统 Swift 库(模拟器包常见);embedded.mobileprovision 是签名描述文件(macOS 上 security cms -D -i 可读 entitlement 与过期时间)file 确认主二进制是 arm64/arm64e 真机架构——x86_64 模拟器产物无动态分析价值,直接跳过class-dump 头文件:
class-dump -H app/Payload/*.app/ -o headers/
类名 / 方法名 / 属性即大部分业务接口,先看 headers 再进反编译。加密二进制先脱壳(步骤 5)再 dump,否则只得到壳的类。Swift 方法不进 OC 头文件(见坑 4)。
二进制走 [[re-format-macho]]:
otool -h app/Payload/*.app/ # 架构 / cputype
otool -L app/Payload/*.app/ # 依赖 dylib(framework 清单)
结构、load commands、入口、段、签名按 [[re-format-macho]] 步骤执行;Swift 二进制用 strings -n 6 找符号与错误消息辅助定位。
越狱环境动态调试:
iproxy 2222 22 & # usbmuxd 转发设备 ssh 到本机 2222
ssh -p 2222 root@127.0.0.1 # 登录越狱设备
设备上启动目标 App;断点 / 单步调试经 debugserver + lldb(见 [[re-lldb]]);hook / 绕过优先 [[re-frida]](frida-server 安装见该技能)。
脱壳(FairPlay 解密):
frida --version # 主机 Frida 世代——选 dumper 前先定
iproxy 2222 22 &
<选定 dumper> <BundleID 或 App 名> # 按目标 iOS / Frida 版本选维护实现,拉取并解密
file <输出>.ipa
otool -l <输出>/Payload/*.app/ | grep -A4 LC_ENCRYPTION_INFO # 确认 cryptid 0
思路:从已解密的内存镜像读取 Mach-O 头与段,重组为解密 ipa。dumper 必须与主机 frida --version 及设备 frida-server 的世代匹配(见工具准备);脱壳产物回到步骤 1-3 复跑。
cryptid 1 加密,磁盘上的代码是密文;对策——步骤 1 先查 LC_ENCRYPTION_INFO,加密先按步骤 5 脱壳codesign -f -s - adhoc 重签(仅自签场景)或重新用开发者证书签名;免费账号到期重新安装strings / swift-demangle 找符号,逻辑分析靠 [[re-format-macho]] + 反编译([[re-binary-core]])file 显示主二进制是 x86_64,动态分析全不可用;原因——分发方给了模拟器包(常带 SwiftSupport/);对策——步骤 1 用 file 确认 arm64/arm64e 真机架构,模拟器产物跳过brew install class-dump 报 No available formula;原因——homebrew-core 已移除该公式(2026 实测);对策——nygard/class-dump 源码构建,或换 class-dump-swift(见工具准备)