mirror of
https://github.com/qtmleap/revkit.git
synced 2026-10-17 07:11:52 +02:00
backup/master-20260808
`+[VoIPClient initGenAudioH]` と `_gen_audio_h` の内部構造を並列 5 系統
で追加解析。旧 `znca_ios_init_gen_audio_h_static.md` の主要結論が複数覆さ
れたので、脚注ベースで訂正しつつ 6 本の新規 spec ドキュメントに事実関係を
移した。
## 訂正された旧結論
- `0x101034204` は CFF dispatch 変数ではなく write-only decoy sink
(629 writes / 0 reads)。真の CFF state は 693 個の private stack slot、
9 zone-base regs (x8/x12/x13/x14/x15/x19/x20/x22/x25/x26/x28) 経由
- 「CFF 694 dispatch site」のうち functional edge はわずか 15、残り 678 は
opaque predicate による no-op (99.7% がダミー)
- 生 SVC 分類: sysctl×12 → sysctl×10 + getpid×4
(`mov w8,#0x14 → mov w16,w8` の register-forward で拾えていなかった)
- `kill()` × 3 は全て sig=0 の良性 liveness probe、self-terminate では
なかった (SVC 直前の `str wzr,[slot]` + dynamic emulation で確認)
- `sysctl` の MIB は 9/10 で `[CTL_KERN=1, KERN_PROC=14, KERN_PROC_PID=1,
pid]` に確定 (`kinfo_proc` P_TRACED パターン)
- 旧 doc の brk 2 発 (`0x1007d98b0`, `0x1007d9a68`) は initGenAudioH に属
さず、無関係な `0x1007d94d0`–`0x1007d9bd0` に属する
- 「Frida hook 時の 500 回再帰 objc_msgSend」は静的に不可能と判明
(`objc_msgSend$initGenAudioH` stub は caller が 1 箇所のみ、selref も 1
箇所のみ)。旧 doc の crash 記述の `Crew@0x7D5B4` は `Crew@0x7D5F4`
(initGenAudioH コールサイトのリターン IP) の転記ミスの可能性大
- whitebox blob (2.13 MiB @ 0x100f70000..0x101192000) の内訳:
1.76 MiB (82.6%) pure table + 380 KiB (17.4%) CFF plumbing (31 islands,
2775 chained-fixup pointer)
- Chow-style AES 仮説は refute: 生 S-box (`63 7c 77 7b`) は blob 全域全
alignment で 0 hit、`_gen_audio_h` の register-indexed LDRB も 0
(SIMD `ldr q0` が 8 発のみ)
- `_gen_audio_h` の 8 個 SIMD load は 6/8 が自関数の 283,520 バイトのスタッ
クフレーム (`x19`) を読んでおり、whitebox blob を直接 index していない。
9-subtable 仮説の SIMD 経路は refute
- `_set_platform_for_gen_audio` は x0 を読まず self-contained、可変
platform id は渡していない
- `_gen_audio_h` は CryptoPP SHA-256 (K[64]) を直接呼ばず、`_CC_SHA256`
stub も未使用
## 新規 spec ドキュメント
- `docs/spec/znca_ios_whitebox_layout.md`: blob の pure/plumbing split、
entropy/pointer-fixup 解析
- `docs/spec/znca_ios_init_gen_audio_h_cff.md`: CFF de-flatten 結果
(dispatch idiom `target = base + state`、functional edge 15/694)
- `docs/spec/znca_ios_antidebug_strings.md`: SVC 35 全分類、MIB/signal
確定、runtime string decoder は 425M+ emulate でも未到達
- `docs/spec/znca_ios_true_selfkill.md`: 空振り報告 + 旧 crash 観測の
転記ミス仮説
- `docs/spec/znca_ios_gen_audio_h_internals.md`: 8 SIMD load 追跡、
9-subtable 仮説の refute
- `docs/spec/znca_ios_init_gen_audio_h_static.md`: 上記に沿ってピンポ
イント訂正パッチ (400→441 行、Edit のみ)
## 未解決 (追跡不可で正直に残置)
- 難読化 anti-debug 比較文字列の runtime decoder 位置と平文値
- 真の self-kill 経路 (存在するかも含めて要実機再現)
- 2 個の pointer-indirect SIMD base の pointee provenance
- `_gen_audio_h` の 277 KiB stack scratch zone の populate 経路
- 間接 crypto call path があるか
## 補助生成物
- `targets/znca_ios_3.4.1/whitebox/tools/*.py`: 前セッションで消失した
npy 生成コードを LIEF ベースで復元
- `targets/znca_ios_3.4.1/analysis/{cff,antidebug,selfkill,gen_audio_h}/
*.py`: capstone/lief/emulator ベースの解析スクリプト群
- CFG dot ファイル: `analysis/cff/cfg_full.dot` + 11 zone 別
- 中間 npy/output: `whitebox/analysis/*.npy`,
`analysis/gen_audio_h/*_output.txt`
## 除外
Nintendo バイナリ (Crew / GameWidgetsExtension / NotificationService /
whitebox_data_*.bin) と Frida ランタイムログはコミット対象外。pickle
キャッシュ (`insns.pkl`, `cfg.pkl`) はスクリプトから再生成可能なので除外。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
revkit
A reverse-engineering toolkit for iOS and Android applications.
- iOS Tweak Development — Build and deploy Substrate tweaks via Theos/Orion (arm64, rootless)
- Frida Hooks — Runtime analysis and dynamic instrumentation for iOS / Android apps
- mitmproxy — Programmable HTTPS traffic capture and protocol decoding
- Binary Analysis — Static analysis of APK / IPA binaries with Ghidra, radare2, jadx, ipsw
Repository Structure
.
├── packages/
│ ├── frida/ # Frida hook scripts (TypeScript → JS)
│ │ └── src/
│ │ ├── ios/ # iOS hooks (ObjC/C++)
│ │ ├── android/ # Android hooks (Java/JNI)
│ │ └── common/ # Shared utilities
│ ├── mitmproxy/ # mitmproxy addons
│ └── tweak/ # iOS Tweaks (Theos/Orion)
│
├── tools/ # Python utilities
│ ├── run.py # Frida hook runner
│ ├── transformers/ # Log transformers (Frida → unified format)
│ └── ...
│
├── handlers/ # Objection handlers (CommonCrypto, Security, etc.)
├── docs/ # Analysis results & specifications
├── assets/ # IPA/APK binaries (.gitignore)
├── raws/ # Raw Frida capture logs (.gitignore)
└── logs/ # Transformed logs (.gitignore)
Development Environment
Everything is pre-configured in a DevContainer. Run Rebuild Container to get all tools ready.
Runtimes
| Tool | Purpose |
|---|---|
| Python 3.12 (uv) | Utilities, log transformation, analysis scripts |
| Node.js 25.x | Frida script build (frida-compile) |
| Bun | Chrome extension build |
| Frida 17.x | Dynamic instrumentation |
| mitmproxy | Programmable HTTPS proxy |
Reverse Engineering Tools
| Tool | Purpose |
|---|---|
| radare2 | ARM64 disassembly & binary analysis |
| Ghidra (headless) | Pseudocode generation & function analysis |
| jadx | Android APK → Java decompilation |
| apktool | Android APK resource extraction & smali |
| ipsw | iOS Mach-O analysis, ObjC/Swift class dump |
| lief (Python) | Mach-O/ELF binary parser |
| capstone (Python) | ARM64 disassembler |
| unicorn (Python) | CPU emulation |
| pywidevine (Python) | Widevine DRM analysis |
iOS Tweak Development
| Tool | Purpose |
|---|---|
| Theos | Tweak build system |
| Orion | Swift tweak framework |
| Swift 5.8 (cross-compile) | Cross-compilation for iOS |
| iOS SDK 15.6 / 16.5 | Build targets |
macOS Host Setup
The DevContainer runs inside Docker Desktop's Linux VM and cannot communicate with iOS devices directly. Use iproxy over USB to avoid issues with Wi-Fi IP changes or network instability.
1. Install iproxy (macOS)
brew install libimobiledevice
2. Start iproxy (macOS)
With the iPhone connected via USB:
iproxy 2222 22 &
iproxy 27042 27042 &
2222 → 22: SSH27042 → 27042: Frida
Connection Diagram
| Purpose | Direction | Route |
|---|---|---|
| SSH | Container → Device | ssh iPhone → host.docker.internal:2222 → iproxy (USB) → device:22 |
| Frida | Container → Device | frida -H host.docker.internal → iproxy (USB) → device:27042 |
| mitmproxy | Device → Container | Set device Wi-Fi proxy to macOS LAN IP:9080 |
Usage
Frida Hooks
# iOS (spawn via objection)
uv run python tools/run.py packages/frida/<script>.js
# Android (spawn mode)
uv run python tools/run.py --android packages/frida/<script>.js
Set device hosts in .env (use host.docker.internal when going through iproxy):
IOS_HOST=host.docker.internal
ANDROID_HOST=192.168.x.x
mitmproxy
Device Setup
- Set the device's Wi-Fi proxy to the macOS LAN IP, port
9080 - Open
http://mitm.iton the device and install the CA certificate- iOS: Settings → General → VPN & Device Management → install mitmproxy → Settings → General → About → Certificate Trust Settings → enable
Launch
uv run mitmdump --listen-port 9080 --set block_global=false \
-s packages/mitmproxy/<addon>.py
Addons are located in packages/mitmproxy/.
iOS Tweaks (Theos)
# Build
make -C packages/tweak/<tweak>
# Package (.deb)
make -C packages/tweak/<tweak> package
# Install to device
make -C packages/tweak/<tweak> package install THEOS_DEVICE_IP=<device-ip>
Binary Analysis
# iOS: ObjC/Swift class dump
ipsw macho info <binary> --class-dump
# Android: APK decompilation
jadx -d /tmp/out <apk>
# Ghidra headless analysis
analyzeHeadless /tmp/project name -import <binary>
Claude Code Skills
Project-specific slash commands available inside Claude Code.
| Command | Description |
|---|---|
/compose |
Assemble an Agent Team as leader and run the plan → approve → execute workflow |
Agents
Specialized agents invoked by /compose.
| Agent | Responsibility |
|---|---|
tweak-engineer |
iOS Tweak development (Orion/Theos, ElleKit C hooks) |
frida-engineer |
Frida hook scripts, runtime analysis |
mitmproxy-engineer |
mitmproxy addons, traffic capture |
python-engineer |
Python utilities, decoders, data processing |
log-monitor |
Frida/mitmproxy/Tweak log monitoring & reporting |
Languages
Python
50.2%
TypeScript
30.1%
JavaScript
11.9%
Objective-C
6.6%
Dockerfile
0.5%
Other
0.5%