Công cụ là tay chân của researcher. Setup đúng từ đầu giúp tiết kiệm hàng trăm giờ.


Disassemblers & Decompilers

IDA Pro + Hex-Rays (Khuyên dùng)

  • Vai trò: Disassembler và decompiler hàng đầu, standard trong industry
  • Tính năng: ARM64 decompilation, type reconstruction, scripting (IDAPython), plugin ecosystem
  • Giá: Đắt (license thương mại), nhưng có bản Education
  • Khi nào dùng: Phân tích kernelcache, IOKit drivers, system daemons
  • Tips:
    • Load kernelcache với đúng base address
    • Dùng DWARF symbols từ Apple KDK (Kernel Debug Kit) khi có
    • IDAPython scripts tự động hóa pattern searching

Ghidra (Free, NSA)

  • Vai trò: Alternative miễn phí cho IDA
  • Tính năng: ARM64 support tốt, decompiler tích hợp, Java-based scripting
  • Khi nào dùng: Khi không có IDA license, hoặc cần second opinion
  • Hạn chế: Decompiler output kém hơn Hex-Rays cho ARM64 kernel code

Binary Ninja

  • Vai trò: Modern disassembler với UI tốt
  • Tính năng: IL (Intermediate Language) layers, API-first design, Python scripting
  • Khi nào dùng: Scripted analysis, khi cần programmatic approach

Hopper

  • Vai trò: Lightweight disassembler cho macOS
  • Tính năng: Nhanh, native macOS app, Objective-C analysis tốt
  • Khi nào dùng: Quick analysis của userspace binaries

Command-Line Tools

otool / jtool2

# otool — Mach-O analysis (built-in macOS)
otool -lV binary          # Load commands (chi tiết)
otool -hV binary          # Mach-O header
otool -tV binary          # Disassemble __TEXT,__text

# jtool2 — Enhanced Mach-O analysis (Jonathan Levin)
jtool2 --pages binary     # Show segment/section layout
jtool2 -d binary          # Disassemble
jtool2 --ent binary       # Extract entitlements
jtool2 -S binary          # Show symbols

codesign / ldid

# codesign — macOS native code signing tool
codesign -d --entitlements :- binary    # Dump entitlements
codesign -dvvv binary                   # Detailed signing info

# ldid — Open-source signing tool (dùng trên jailbroken devices)
ldid -e binary              # Extract entitlements
ldid -Sentitlements.xml binary  # Sign with entitlements

img4tool / img4lib

# Extract và decrypt kernelcache từ IPSW
img4tool -e -o kernelcache.raw kernelcache.img4
# Hoặc dùng pyimg4
python3 -m pyimg4 im4p extract -i kernelcache.im4p -o kernelcache.macho

lipo / file

lipo -info binary           # Architectures trong fat binary
lipo binary -thin arm64e -output binary.arm64e  # Extract single arch
file binary                 # File type identification

Debuggers

lldb

# Attach to process
lldb -n process_name
lldb -p PID

# Basic commands
(lldb) b function_name          # Set breakpoint
(lldb) br s -a 0x100001234     # Breakpoint at address
(lldb) r                        # Run
(lldb) c                        # Continue
(lldb) si                       # Step instruction
(lldb) ni                       # Next instruction (step over)
(lldb) register read            # All registers
(lldb) register read x0 x1 x2  # Specific registers
(lldb) memory read 0x100001234  # Read memory (hex dump)
(lldb) memory read -f x -c 8 -s 8 addr   # 8 uint64 values
(lldb) x/10gx addr             # GDB-style: 10 giant (8-byte) hex values
(lldb) disassemble -a 0x1234   # Disassemble at address
(lldb) image list               # Loaded images + ASLR slides
(lldb) expr -- (int)getpid()   # Evaluate expression

Kernel Debugging

  • Corellium: Virtual iOS devices — full kernel debugging support
  • KDP (Kernel Debug Protocol): Over network, cần development kernel
  • Apple KDK (Kernel Debug Kit): Symbols cho production kernels (cần Apple Developer account)

Dynamic Analysis

Frida

# Inject vào running process
frida -U -n SpringBoard        # USB-connected device
frida -H host:port -n target   # Remote

# Frida script basics
Interceptor.attach(ptr("0x1234"), {
    onEnter(args) {
        console.log("arg0:", args[0]);
    },
    onLeave(retval) {
        console.log("return:", retval);
    }
});

DTrace / Instruments (macOS)

# Trace syscalls
sudo dtruss -p PID
# Trace specific probe
sudo dtrace -n 'syscall::mach_msg_trap:entry { printf("%d", pid); }'

Lab Setup Recommendations

  • Virtual iOS devices trong cloud
  • Full kernel debugging, filesystem access
  • Kernel hooks, custom kernelcache loading
  • Giá: subscription model

Option 2: Physical Device + checkra1n/palera1n

  • iPhone X hoặc cũ hơn (A11 và dưới cho checkm8)
  • checkra1n/palera1n jailbreak
  • SSH access, filesystem read/write
  • Frida cho dynamic analysis
  • Hạn chế: không có kernel debugging trực tiếp

Option 3: macOS cho XNU research

  • Apple Silicon Mac chạy macOS
  • Nhiều kernel subsystems giống iOS
  • Kernel debugging dễ hơn (SIP disable + boot-args)
  • Tốt cho học XNU internals trước khi chuyển sang iOS

Workflow Cơ Bản

1. Extract kernelcache từ IPSW
   └─→ img4tool / pyimg4

2. Load vào IDA/Ghidra với symbols (KDK)
   └─→ Phân tích static

3. Identify target (IOKit driver, syscall handler, ...)
   └─→ Tìm entry points, trace code paths

4. Dynamic analysis trên device/Corellium
   └─→ Frida hooks, lldb debugging

5. Fuzzing (optional)
   └─→ IOKit fuzzer, syscall fuzzer

6. Exploit development
   └─→ PoC → primitive → chain → jailbreak