Frida

A dynamic instrumentation toolkit that injects a JavaScript engine into a running native process so you can hook functions, read and modify memory, and change behavior at runtime without touching the binary on disk — the backbone of mobile dynamic analysis.

How it works

Frida (Ole André Vadla Ravnås) injects the QuickJS engine (formerly Duktape) into a target. On attach it uses ptrace to hijack a thread, allocates memory for a bootstrapper, spins up a fresh thread that connects to frida-server and loads frida-agent.so, then restores and resumes the hijacked thread. The agent opens a bidirectional channel back to the REPL or a Python script. Three modes:

  • Injected — frida-server runs as a daemon (default localhost:27042); needs root/jailbreak because unprivileged ptrace is blocked.
  • Embedded — frida-gadget is embedded into the app (manually or via Objection’s patchapk/patchipa), for non-rooted/non-jailbroken devices.
  • Preloaded — gadget loads autonomously from a config, like LD_PRELOAD/DYLD_INSERT_LIBRARIES.

Core APIs: Interceptor (inline trampoline hooking at the function prologue), Stalker (JIT-based instruction tracing), and the Java / Objective-C bridges for high-level class and method access. CLI tools include frida-ps, frida-trace, and frida-compile.

What it is used for

On mobile, a handful of hooks cover most of a dynamic assessment: disabling certificate pinning, defeating root/jailbreak and anti-Frida checks, extracting keys from the Keychain/Keystore, intercepting crypto calls to see plaintext, dumping heap objects and searching memory for secrets, and flipping client-side authorization flags. Objection wraps these as ready-made commands for testers who don’t want to write JS; Grapefruit offers a web UI over the same engine.

  • Script generation from static analysis. Fridexa infers class, method and overload targets from JADX/apktool output and emits app-specific scripts in observe-only or bypass mode, with URL capture for OkHttp, Retrofit, URL.openConnection and WebView, optional Burp proxy setup and duplicate-hook prevention. Pasted Frida console output is parsed for failed hooks and unconfirmed modules, with optional local-LLM revision shown as a diff. Its author’s caveat: a generated bypass is not a proven bypass, especially for Ktor, Flutter, native code and obfuscation Fridexa.

  • Typical AndroGoat set (Frida 17.4.1, Android 13 emulator): force isRooted()/isEmulator() to false, flip an isAdmin field, redirect onAuthenticationFailed to the success path, and always-pass CertificatePinner.check AndroGoat.

  • iOS lab hook set (evilcorp-ios): wrap the reply block of -[LAContext evaluatePolicy:localizedReason:reply:] to force biometric success, enumerate -[* URLSession:didReceiveChallenge:completionHandler:] with ApiResolver("objc") and call the handler with .useCredential for the presented trust, and rewrite ptrace request 31 (PT_DENY_ATTACH) to 0. Run with frida -U -N <bundle-id> -l script.js jankesec.

  • Coverage-guided fuzzing with Stalker (LibAFL Frida mode). Gum is linked into the fuzzer itself, so no frida-server or ptrace is needed: an unrooted phone running as the shell user in /data/local/tmp works because that SELinux domain may generate and execute its own code. Stalker recompiles only the target library’s basic blocks (everything else is excluded and runs natively), injecting AFL-style edge-coverage code, CmpLog records for SUBS/CBZ/TBZ operands (so input-to-state replacement solves magic values), and binary-level ASan shadow checks. The target must be mapped before FridaInstrumentationHelper builds its ranges (link it as DT_NEEDED of the harness) or coverage is 0%. Measured ~6,000 exec/s on one core and ~30,000 on eight against Samsung’s closed-source libimagecodec.quram.so, rediscovering CVE-2026-21096 within seconds. On Android, LibAFL 0.16’s Frida ASan failed to start (39-bit address space shadow, has_tls() reading TPIDRRO_EL0, a futex deadlock), so crashes were confirmed with an ASan-built reproducer instead (fast_unwind_on_fatal=1) Mobile Hacking Lab.

Version notes that break scripts

  • Frida 17 removed the bundled runtime bridges from GumJS. CLI tools still bundle them, but custom tooling must install bridges via frida-pm (e.g. frida-java-bridge) and bundle with frida-compile. Native APIs changed: Process.enumerateModules() now returns Module objects; Module.getSymbolByName was removed in favor of Process.getModuleByName(...).getExportByName(...) or Module.getGlobalExportByName(...).
  • 17.26–17.27 improved Linux device-tunnel throughput ~7×, added a UART transport for the XNU (iOS) agent, gave device-discovery tunnels a stable UUID (fixing iOS 27.2 teardown), and brought idund to macOS for faster iOS connections.
  • 17.27.0 can attach() to an already-running debuggable Android app on a non-rooted device by injecting Gadget over JDWP (breaking on Binder.execTransact()), not only at spawn — useful against apps that only check for instrumentation at launch.

Detection and the arms race

Frida is noisy, and RASP vendors hunt for it: scans of loaded memory maps for agent artifacts, probes of the default Frida ports on 127.0.0.1, suspicious thread names, and comparing libc function prologues against a baseline to spot trampolines. See Jailbreak and Root Detection Bypass for how these signals are weighted, and Jailbreak and Root Detection Bypass for how testers evade them (Magisk DenyList/Zygisk, attaching after launch, hiding gum). This is an explicit cat-and-mouse: each side adapts to the other.

Setup notes

Install with pip install frida-tools. On Apple Silicon, rooted Android emulation (Magisk + frida-server pushed over ADB) pairs with Burp/mitmproxy for traffic capture. Objection needs a rooted/jailbroken device with frida-server or a gadget-patched app; it cannot instrument a production-signed store build you can’t repackage.

Sources