iOS RE Cheatsheet

ARM64 Β· Swift Β· ObjC Β· Frida Β· IDA Pro Β· SSL Pinning Β· Jailbreak Detection Β· Static & Dynamic Analysis


1. Toolchain Setup

Static Analysis

Tool
Description

IDA Pro

Primary disassembler + decompiler (Hex-Rays)

Ghidra

Free alternative, good Swift support via plugin

Hopper

Lightweight, fast ObjC analysis on macOS

class-dump

ObjC header reconstruction from binary

dsdump

Swift + ObjC metadata dump, more detailed

jtool2

Mach-O swiss-army knife, better than otool

nm / strings

Symbol listing, string extraction

Dynamic Analysis

Tool
Description

Frida

Runtime instrumentation, hook injection

Objection

Frida-based toolkit, SSL bypass, mem dump

lldb

On-device debugger via Xcode / debugserver

frida-trace

Auto-trace ObjC methods & C functions

r2frida

radare2 + Frida combined analysis

Burp Suite

HTTP/S proxy for traffic interception

mitmproxy

Lightweight proxy, scriptable

Utility / Support

Tool
Description

ipsw

Download & extract iOS firmware, DYLD cache

ldid

Sign binaries for sideloading / testing

frida-ios-dump

Decrypt & dump App Store IPAs

bfdecrypt

Inline decryption via Cydia tweak

Filza / iFile

On-device filesystem browser

otool

Object file displaying tool (built-in macOS)

xcrun swift-demangle

Demangle Swift mangled symbol names


2. First Recon β€” Before Opening IDA

Shell Commands

class-dump / dsdump

Decryption β€” App Store IPAs

DYLD Cache & Imports


3. ARM64 Quick Reference

Calling Convention

Register(s)
Role

x0–x7

Function arguments (in order) / return values

x0–x1

Return values (Swift String = x0 low + x1 flags)

x8

sret pointer β€” indirect struct return buffer

x9–x15

Scratch / caller-saved (can be clobbered)

x16–x17

Intra-procedure-call temporaries (IPC)

x18

Platform reserved (iOS: thread-local)

x19–x28

Callee-saved β€” preserved across calls

x29 (fp)

Frame pointer

x30 (lr)

Link register β€” return address

sp

Stack pointer (16-byte aligned)

Key Instructions

sret β€” Struct Return (Critical for Swift)

Common Patterns in IDA


4. Swift Internals β€” IDA Patterns

Swift String Encoding in Registers

x1 top bits

Type

x0 content

0xE0…0xEF

Small inline string

ASCII bytes packed in x0+x1

0x8000 0001…

Large heap String

Pointer to Swift _StringStorage

0xF000…

Foreign (NSString bridge)

Pointer to NSString object

x1>>62 == 2

Data heap large

Pointer to __DataStorage

x1>>62 == 1

Data medium

Encoded inline

x1>>62 == 0

Data inline/small

BYTE6(x1) = length

Skip-Pattern Recognition

These are always boilerplate β€” skip immediately without further analysis:

Function Size Heuristic

Size
Likely type
Action

< 0x20

ARC helper / metadata thunk / getter

Skip

0x20–0x60

CoW helper / Data wrapper / witness init

Skip

0x60–0x100

String/Data utility, possible crypto helper

Quick scan

0x100–0x400

Real logic β€” check functions, parsers

Analyze

> 0x400

Core logic, orchestrators, complex checks

Deep dive

First call in function body:

First call
Action

swift_getTypeByMangledName…

Skip

swift_getWitnessTable

Skip

swift_once

Skip body

swift_allocObject

Note type, continue

CC_SHA256 / CCCrypt

Priority analyze

_dyld_* / sysctl

Security check

objc_msgSend

Read selector

Swift Memory Layouts


5. ObjC Runtime Patterns

objc_msgSend Patterns

Key ObjC Classes & Selectors

Class / Selector
Security Relevance

NSURLSession -dataTaskWithRequest:

HTTP requests β€” hook for traffic interception

NSURLSession -didReceiveChallenge:…

SSL auth challenge β€” pinning bypass target

SecItemCopyMatching

Keychain read β€” dump credentials

SecItemAdd

Keychain write β€” trace stored secrets

SecTrustEvaluate / …WithError:

Certificate validation β€” pinning

NSBundle -pathForResource:ofType:

Reads embedded resources (plist, cert, config)

NSFileManager -fileExistsAtPath:

Jailbreak filesystem checks

UIDevice -systemVersion

OS version checks

NSUserDefaults -objectForKey:

Persistent config / flags storage

FIRCrashlytics -recordError:

Security event telemetry reporting


6. Frida β€” Essential Scripts

CLI β€” Device Setup

Hook Template β€” Universal

Runtime Introspection

Keychain & CommonCrypto Hooks


7. SSL Pinning Bypass

Bypass Levels β€” Try in Order

Level
Method
Notes

1

objection: ios sslpinning disable

Patches common patterns automatically. Try first.

2

SSL Kill Switch 2 (Cydia tweak)

System-wide hook on SecTrustEvaluate.

3

Hook -URLSession:didReceiveChallenge:completionHandler:

Force NSURLSessionAuthChallengeUseCredential with nil.

4

Hook TSKSPKIHashCache (TrustKit)

Return hash matching your proxy cert's SPKI.

5

Hook SecTrustEvaluateWithError β†’ force true

Works for custom SecTrust implementations.

6

Find embedded client cert via SecPKCS12Import

Mutual TLS β€” cert embedded in __DATA or bundle.

Bypass Code


8. Jailbreak Detection β€” Bypass

Detection Vectors

Method
What to Spoof

stat / lstat / access

Return ENOENT for JB paths (/bin/bash, /Applications/Cydia.app)

fopen / open

Return NULL/βˆ’1 for JB files

fork()

Sandboxed apps can't fork β†’ return βˆ’1

ptrace(PT_DENY_ATTACH)

Hook ptrace β†’ return 0 (allow debugger)

sysctl(P_TRACED)

Debugger presence β†’ clear flag in returned struct

dlopen(MobileSubstrate)

Return NULL for substrate/tweak libraries

canOpenURL("cydia://")

Force return NO

NSFileManager -fileExistsAtPath:

Return NO for JB paths

vm_region_64

Check __DATA_CONST writability β†’ mask VM_PROT_WRITE

_dyld_image_count / name

Filter out Substrate/tweak dylibs from list

Universal Filesystem Bypass (Frida)


9. IDA Pro β€” Systematic Workflow

1

Phase 1 β€” Orientation (30 min)

  1. Functions window β†’ sort by size DESC β†’ largest = real logic, skip < 0x20 bytes

  2. Imports window β†’ identify security libraries: Security.framework, CommonCrypto, CFNetwork, LocalAuthentication, sqlite3

  3. Strings window β†’ filter: https://, /api/, /v1/, error messages, base64 patterns

  4. Search β†’ class names from dsdump output β†’ jump directly to known interesting classes

  5. Segments β†’ check __DATA.__const and __TEXT.__cstring β†’ embedded certs, keys, endpoints

2

Phase 2 β€” Function Analysis Flow

  1. Check size β†’ apply heuristic (< 0x20 skip, > 0x100 full analysis)

  2. Check first call β†’ swift_getTypeByMangledName β†’ skip immediately

  3. xrefs_to β†’ caller context often explains purpose completely

  4. callgraph(depth=2) β†’ find CC_SHA256, CCCrypt, _dyld_*, sysctl in subtree

  5. Rename locals immediately as you understand them (v1β†’ptr_data, v2β†’len)

  6. set_comments at key addresses β€” document polarity, bypass points, data layout

IDA Shortcuts (macOS)

Shortcut
Action

F5

Decompile current function (Hex-Rays)

N

Rename symbol / variable

;

Add comment at cursor

X

Cross-references TO current address

Ctrl+X

xrefs FROM current address

G

Go to address

Alt+↑ / Alt+↓

Navigate xref history

Space

Toggle graph / linear view

Ctrl+F

Search text in current function

Alt+T

Search all text / strings

Ctrl+Alt+F

Search function names

Tab

Switch between asm and pseudocode

Y

Change type of variable/function

H

Toggle hex display

Naming Conventions

Prefix
Usage

ISS_Integrity_

Integrity check functions (SHA256, manifest)

ISS_Pipeline_

Security check orchestrators / dispatchers

ISS_Util_

Utility / support functions (base64, string parse)

ISS_Crypto_

Cryptographic operations (AES, HMAC)

ISS_Thunk_

Thunks / stubs to real implementations

Swift_Array_

Generic array buffer helpers (skip)

Swift_Data_

Foundation Data helpers (skip)

Swift_String_

String manipulation helpers (skip)

Swift_once_

Lazy initializers (skip)

Swift_lazyType

Type metadata accessors (skip)

Swift_arcRetain/Release

ARC helpers (skip)


10. Analysis Decision Tree

Full Target β€” Where to Start

Priority Import Functions

Function
Security Relevance

CC_SHA256

Integrity / certificate hash

CCCrypt

AES encrypt/decrypt

CCHmac

HMAC signing

SecItemCopyMatching

Keychain read

SecTrustEvaluateWithError

Cert validation

ptrace

Anti-debug

sysctl

Process flags / debugger

_dyld_get_image_name

Loaded dylib enumeration

vm_region_64

Memory protection check

fork / vfork

Sandbox detection

Bypass Hook Priority

Priority
Target
Notes

1

Result comparator (string equality)

One hook kills all checks. Most surgical.

2

Orchestrator / scheduler function

Return early before any check runs.

3

Individual check entry points

Per-check bypass. Handle polarity carefully.

4

Low-level C functions (stat, sysctl, fork)

Coarse but reliable. Risk of side effects.

Common Pitfalls

Pitfall
Explanation

Inverting sret / first arg

x8 = sret ptr. args[0] is NOT always the first argument in Swift.

Wrong polarity on check return

Some checks: 1=detected, others: 1=clean. Always verify before hooking.

In-memory hash (not disk)

Patching binary on disk won't change the in-memory __text hash.

Result struct written before comparison

Hook the struct init (sret), not just the final comparator.

Unmapped checks causing crash

Full bypass mode needs ALL checks mapped first.


ARM64 Β· Swift Β· ObjC Β· Frida Β· IDA Pro