Skip to main content Switch to mobile version frida-code-mode 1.0.0 Write TypeScript Frida instrumentation, compile with frida-compile, run on device, and stream attributable send() telemetry. Generic CLI + library.
pip install frida-code-mode Copy PIP instructions
Write TypeScript instrumentation for Frida 17, compile it into a single bundle with frida-compile, and run it on Android or iOS with attributed telemetry, live RPC queries, and same-PID hot reload with automatic rollback.
Frida 17 ready: bundles frida-java-bridge, frida-objc-bridge, and frida-swift-bridge once per agent, catching removed GumJS APIs at compile time.
Hot reload + rollback: swap hooks inside a live process without restarting the target; runtime init errors automatically restore the last working bundle.
Two communication paths: asynchronous send() event streams (_fcm envelope) plus synchronous generation-checked RPC queries via call_export.
Three ways to use: MCP server for AI agents, CLI/REPL for interactive testing, or Python SDK for security pipelines.
Live Mobile Hacking Lab demos
Both captures below were recorded against real Mobile Hacking Lab targets (Secure Notes on Android API 31 and No Escape on an iPhone X running iOS 16.7.16). Each session spawns the app, captures real hooks, queries live state with call_export, hot-reloads in the same PID, and recovers automatically when a broken hook is loaded. See the release verification matrix.
1. MCP Server (AI Agents)
Works with Claude Code, Antigravity, Cursor, and Gemini CLI over stdio (frida-code-mode-mcp). Requires Python 3.10+ and Node.js/npm.
{ "mcpServers": { "frida-code-mode": { "command": "uvx", "args": ["--from", "frida-code-mode[mcp]", "frida-code-mode-mcp"] } } } MCP tools Tool Purpose use_frida Compile TypeScript (code or entry), spawn/attach, and optionally keep a session_id alive for same-PID hot reload call_export Discover or invoke registered RPC queries (queries in runHooks) bound to the active generation drain_session Read queued HookEvent observations after manual or automated app interaction close_session Detach from the target and release the session (kill_process=True terminates the app) list_sessions List open sessions with pid, generation, and agent_sha256 list_devices / ensure_server Inspect adb devices and ensure a matching frida-server on Android Example MCP workflow
Start a persistent session (keep_alive=True):
For full TypeScript modules with RPC queries, pass entry="path/to/agent.ts" and invoke call_export(session_id, name="...", expected_generation=generation). See docs/INTEGRATING.md.
Install the CLI with uv or pip:
uv tool install "frida-code-mode" Inline execution (exec)
Run a TypeScript snippet without scaffolding a project. Java, t (Telemetry), and config are pre-wired for snippets:
frida-code-mode devices frida-code-mode server --serial emulator-5554 frida-code-mode exec \ --package com.mobilehackinglab.securenotes \ --serial emulator-5554 \ --duration 6 \ -c 'const p = Module.findGlobalExportByName("openat"); if (p) Interceptor.attach(p, { onEnter(args) { t.hit({ path: args[1].readUtf8String() }); } });' Events print to stdout as NDJSON (run and exec exit 1 if the agent reports an error):
{"kind": "hook_installed", "hook": "inline", "source": "inline", "seq": 0, "agent_ts": 1796356792.9, "host_ts": 1796356792.5, "data": {}} {"kind": "hook_hit", "hook": "inline", "source": "inline", "seq": 1, "agent_ts": 1796356793.1, "host_ts": 1796356792.7, "data": {"path": "/data/user/0/com.mobilehackinglab.securenotes/shared_prefs"}} Scaffold a project and hot-reload (init + repl)
frida-code-mode init ./my-hooks --install frida-code-mode repl src/index.ts \ --project ./my-hooks \ --package com.mobilehackinglab.securenotes \ --serial emulator-5554 Saving changes under src/ recompiles and reloads the bundle into the running process. If a reload fails at compile time or throws during startup, the REPL restores the previous working bundle.
iOS and remote transports
# iOS over USB frida-code-mode run src/ios_probe.ts --platform ios --package com.mobilehackinglab.No-Escape # iOS or jailbroken device over SSH port forwarding frida-code-mode run src/ios_probe.ts --platform ios --package com.mobilehackinglab.No-Escape \ --transport ssh --host 192.168.1.50 --ssh-user mobile # Remote frida-server over TCP (e.g. adb forward tcp:27042 tcp:27042) frida-code-mode run src/index.ts --package com.mobilehackinglab.securenotes \ --transport remote --host 127.0.0.1 --remote-port 27042 --no-server 3. Writing TypeScript Hooks & Using the Python SDK
Install the library with pip install frida-code-mode.
TypeScript hook + live RPC query (agent.ts)
Pass objc: ObjC as any (from frida-objc-bridge) on iOS so deferred hooks schedule onto the main queue safely under spawn.
Python SDK (CodeModeRunner & CodeModeSession)
from pathlib import Path from frida_code_mode import ( CodeModeRunner, Platform, RunConfig, TargetConfig, TransportConfig, TransportKind, ) runner = CodeModeRunner(agent_project_dir=Path("agent")) agent = runner.compile("agent.ts", "build/agent.js") result = runner.run( RunConfig( target=TargetConfig(platform=Platform.ANDROID, package="com.mobilehackinglab.securenotes"), transport=TransportConfig(kind=TransportKind.USB, serial="emulator-5554"), duration=8.0, ), agent, ) for event in result.hits(): print(event.hook, event.data) For long-lived sessions with call_export() and hot-reload, or wrapping an existing frida.core.Device, see docs/INTEGRATING.md.
Why Frida 17 Needs Compiled Hooks
Runtime bridges are separate packages: Java, ObjC, and Swift are no longer globals in GumJS. Uncompiled scripts throw ReferenceError: Java is not defined unless they import the bridge and bundle with frida-compile.
Removed APIs are caught before runtime: Module.findExportByName(null, name) was removed in Frida 17 in favor of Module.findGlobalExportByName(name). Type-checking against @types/frida-gum catches breaking changes before touching the device.
One bundle prevents the two-bridge collision: loading two separately compiled frida-java-bridge bundles into one process silently drops Java hooks (0 events). runHooks([...], { java }) composes hooks into a single bundle so the bridge is imported once.
Events vs. Live Queries
Telemetry (send() / _fcm envelope): every Telemetry call (t.installed, t.hit, t.error, t.log, t.custom) emits a monotonic _fcm envelope so the observed app cannot spoof hook attribution:
{ "_fcm": { "v": 1, "kind": "hook_hit", "hook": "provider-trace", "seq": 2, "ts": 1796356792942 }, "uri": "content://com.mobilehackinglab.securenotes.secretprovider", "selection": "pin=1234" } Live RPC queries (call_export): synchronous bounded JSON calls (2s timeout, 8 KiB args, 64 KiB result) tagged with an opaque generation ID so stale calls after a reload or rollback fail explicitly instead of silently reading the wrong script.
See docs/CONTRACT.md for the full v1 wire contract and error taxonomy.
frida_code_mode/ workspace.py Embedded TS template, managed cache, inline snippet wrapper compiler.py frida-compile wrapper with sha256 verification events.py _fcm envelope parser -> typed HookEvent config.py RunConfig / TargetConfig / TransportConfig transport/ USB, remote TCP, SSH forward, and iproxy transports android/ Injectable adb wrapper + frida-server provisioning & recovery session.py spawn/attach -> load -> stream -> reload -> call_export -> detach runner.py One-shot orchestration with cooperative budget & retention caps repl.py File watcher -> recompile -> hot-reload with rollback cli.py devices / server / init / compile / run / exec / repl mcp.py Stateful MCP server (use_frida / call_export / drain_session / close_session) docs/CONTRACT.md — Stable v1 Python, CLI, MCP, and _fcm contract
docs/INTEGRATING.md — Python SDK integration, CodeModeSession, and RPC queries
docs/REAL_DEVICE_TESTING.md — Real-device verification steps and v1.0.0 test matrix
docs/architecture/README.md — Interactive architecture diagram
SECURITY.md — Vulnerability reporting policy
python3 -m venv .venv && .venv/bin/pip install -e ".[dev]" (cd agent && npm install) .venv/bin/ruff check . .venv/bin/pytest (cd agent && npm run typecheck && npm test && npm run build) License
Released: Dec 4, 2026
Both files in this release have provenance metadata.
View provenance details
MIT View SPDX License List
frida instrumentation mobile android ios security dast
Release files for frida-code-mode 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 170.3 kB
Release files / frida_code_mode-1.0.0.tar.gz
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.
Release files / frida_code_mode-1.0.0-py3-none-any.whl
Security for frida-code-mode 1.0.0
Both files in this release have been uploaded with provenance metadata.
With provenance frida_code_mode-1.0.0.tar.gz Dec 4, 2026
With provenance frida_code_mode-1.0.0-py3-none-any.whl Dec 4, 2026
Attestation for frida_code_mode-1.0.0.tar.gz
Attestation for frida_code_mode-1.0.0-py3-none-any.whl
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.
Release history Release notifications | RSS feed
Dec 4, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from 1274d9b











