Frida iOS Hooks
Use this skill when instrumenting iOS Objective-C, Swift, or native behavior.
Setup Checks
frida --version
frida-ps -Uai
frida -U -f com.example.app -l agent.js --no-pause
Confirm runtime availability:
console.log("ObjC.available =", ObjC.available);
console.log(Process.platform, Process.arch);
If ObjC.available is false for an iOS app, use frida-troubleshooting before assuming the script is wrong.
Objective-C Hook Pattern
if (ObjC.available) {
const cls = ObjC.classes.NSURLSession;
const method = cls["- dataTaskWithRequest:completionHandler:"];
Interceptor.attach(method.implementation, {
onEnter(args) {
const request = new ObjC.Object(args[2]);
console.log("[NSURLSession]", request.URL().toString());
}
});
}
Swift and Native Rules
- Enumerate modules and symbols before guessing Swift mangled names.
- Hook Objective-C-visible Swift through ObjC classes when possible.
- For pure Swift/native functions, resolve symbols and use
frida-native-hooks.
- Spawn when hooks must run before app delegate, network stack, or anti-tamper initialization.
- Prefer observation hooks for trust evaluation, crypto, signature generation, and request building before mutating results.
Practitioner Patterns
- Start with Objective-C runtime surfaces when available: delegates, URL loading, keychain, pasteboard, file APIs, crypto wrappers, and jailbreak-detection selectors.
- For Swift-heavy apps, use module/symbol enumeration plus caller stack traces; do not assume selectors exist unless Swift exposes them to Objective-C.
- For pinning, check both Objective-C frameworks and native
Security/BoringSSL/CommonCrypto paths. Apps often mix them.
- Use CodeShare tools such as ObjC method observers for discovery, then replace them with narrow hooks once class/method names are known.
- On rootless jailbreaks, keep a minimal "runtime available" script separate from the real agent so setup failures are not confused with hook bugs.
Discovery Snippets
if (ObjC.available) {
for (const name of Object.keys(ObjC.classes).filter(n => n.includes("Trust"))) {
console.log(name);
}
}
for (const m of Process.enumerateModules()) {
if (m.name.includes("Target")) console.log(m.name, m.base, m.path);
}
Pinning and Rootless Notes
- Identify whether pinning is in
NSURLSession, SecTrustEvaluate*, a third-party framework, or native custom code.
- Rootless jailbreak setups may need matching Frida packages, correct bootstrap path, and updated tooling. Version skew often looks like attach failure or missing ObjC bridge.
- Use Gadget when normal attach is blocked but app modification is in scope.
References
Read references/ios-patterns.md for Objective-C, Swift symbol, SecTrust, module, and rootless troubleshooting patterns.
1---2name: frida-ios-hooks3description: Create and debug Frida hooks for iOS apps, including Objective-C, Swift symbols, modules, Interceptor, TLS pinning, rootless jailbreaks, Gadget, and ObjC issues.4---56# Frida iOS Hooks78Use this skill when instrumenting iOS Objective-C, Swift, or native behavior.910## Setup Checks1112```bash13frida --version14frida-ps -Uai15frida -U -f com.example.app -l agent.js --no-pause16```1718Confirm runtime availability:1920```js21console.log("ObjC.available =", ObjC.available);22console.log(Process.platform, Process.arch);23```2425If `ObjC.available` is false for an iOS app, use `frida-troubleshooting` before assuming the script is wrong.2627## Objective-C Hook Pattern2829```js30if (ObjC.available) {31 const cls = ObjC.classes.NSURLSession;32 const method = cls["- dataTaskWithRequest:completionHandler:"];33 Interceptor.attach(method.implementation, {34 onEnter(args) {35 const request = new ObjC.Object(args[2]);36 console.log("[NSURLSession]", request.URL().toString());37 }38 });39}40```4142## Swift and Native Rules4344- Enumerate modules and symbols before guessing Swift mangled names.45- Hook Objective-C-visible Swift through ObjC classes when possible.46- For pure Swift/native functions, resolve symbols and use `frida-native-hooks`.47- Spawn when hooks must run before app delegate, network stack, or anti-tamper initialization.48- Prefer observation hooks for trust evaluation, crypto, signature generation, and request building before mutating results.4950## Practitioner Patterns5152- Start with Objective-C runtime surfaces when available: delegates, URL loading, keychain, pasteboard, file APIs, crypto wrappers, and jailbreak-detection selectors.53- For Swift-heavy apps, use module/symbol enumeration plus caller stack traces; do not assume selectors exist unless Swift exposes them to Objective-C.54- For pinning, check both Objective-C frameworks and native `Security`/BoringSSL/CommonCrypto paths. Apps often mix them.55- Use CodeShare tools such as ObjC method observers for discovery, then replace them with narrow hooks once class/method names are known.56- On rootless jailbreaks, keep a minimal "runtime available" script separate from the real agent so setup failures are not confused with hook bugs.5758## Discovery Snippets5960```js61if (ObjC.available) {62 for (const name of Object.keys(ObjC.classes).filter(n => n.includes("Trust"))) {63 console.log(name);64 }65}66```6768```js69for (const m of Process.enumerateModules()) {70 if (m.name.includes("Target")) console.log(m.name, m.base, m.path);71}72```7374## Pinning and Rootless Notes7576- Identify whether pinning is in `NSURLSession`, `SecTrustEvaluate*`, a third-party framework, or native custom code.77- Rootless jailbreak setups may need matching Frida packages, correct bootstrap path, and updated tooling. Version skew often looks like attach failure or missing ObjC bridge.78- Use Gadget when normal attach is blocked but app modification is in scope.7980## References8182Read `references/ios-patterns.md` for Objective-C, Swift symbol, `SecTrust`, module, and rootless troubleshooting patterns.