# Project Motivation This is part of a greater idea to automate mobile pentesting with multiple agents that communicate over a protocol like A2A. This is a rough draft version where not all the tooling may work. It is possible to use stdio versions of this mcp server to make setup easier, but the intent of this is to have completely isolated devices that can cross-communicate on a network. **Use at your own risk.** # Known Issues (both platforms) - Different AI models will have varied success on invoking the correct tool - The 0.15.2 5ire release might break AI invocation, it's better to just [manually run the project with node](https://github.com/nanbingxyz/5ire/blob/main/DEVELOPMENT.md) - Session management is not implemented, so if you kill a process there will be a dangling session and there is no way to list interactive sessions - Tool prompts need to be reworked to help the agents pick the tool more accurately - No graceful shutdown on the server - **Security in general is not implemented.** Your messages can be sniffed and they do not require authorization. **Use at your own risk.** # Workstation Requirements - An MCP-compatible client with streamable HTTP support. Going forward, development is targeting [Gemini CLI](https://github.com/google-gemini/gemini-cli) and [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview), since both are building native multi-agent orchestration that aligns with this project's direction. - **Gemini CLI** — add the on-device server (replace ``): ```bash gemini mcp add --transport http frida-c2-mcp http://:6767/mcp ``` - [5ire](https://github.com/nanbingxyz/5ire) is a great GUI option and was used extensively during development. If using 5ire: the 0.15.2 release has a Gemini invocation issue on Windows — run as a node project via [this guide](https://github.com/nanbingxyz/5ire/blob/main/DEVELOPMENT.md) with node `22.19.0` and `npm run dev -- --no-sandbox --disable-gpu`. - Point your client at the device's MCP endpoint. Example config (5ire format): ``` { "name": "fridaMCP", "key": "frida", "url": "http://:6767/mcp", "approvalPolicy": "always" } ``` --- # Android Setup (`cli.py`) ## Tested on - Pixel 9 running Android 16 API 36 - Magisk 30.4 - Frida 17.2.14 - 5ire with Gemini 2.5 Flash ## Device Requirements - A rooted Android device - Take a look at the process with [Magisk](https://github.com/topjohnwu/Magisk) - You can use an emulator, but a physical device is cooler :3 also with the emulator the networking isn't immediately obvious to setup, you'll have to use adb port forwarding or a non-standard network bridge in whatever emulator you're using - Unless you're dealing with sensitive data on the device just set Magisk to auto approve any superuser request - A Frida server - Just use the latest [Frida Magisk module](https://github.com/ViRb3/magisk-frida/releases). Make sure to match the client version of the Frida you choose to use / compile - Install termux - Use the [GitHub version of termux](https://github.com/termux/termux-app) - Inside of termux install the root repo - `pkg install root-repo` - Inside of termux install all the packages (I might be missing stuff here) - The following should install necessary build tools: `pkg install git python clang gcc rust nodejs ninja pkg-config libresolv-wrapper wget` - Do NOT install frida with pip -- it will fail cuz of the C bindings. - Manually build the Frida client - Find the latest frida-core-devkit for the appropriate architecture and use `wget` to grab the .xz file - `mkdir -p frida-core && tar -xf -C frida-core` - Grab the frida-python project `git clone https://github.com/frida/frida-python.git` - Run the following (there might be missing steps here) ``` # This config should work but if it gives you trouble try hardcoding all the paths instead of using $HOME references export HOME=/data/data/com.termux/files/home export PREFIX=/data/data/com.termux/files/usr export FRIDA_CORE_DEVKIT="$HOME/frida-core" export PKG_CONFIG_PATH="$HOME/frida-core" # CHANGE THIS BASED ON WHAT ARCHITECTURE YOU'RE ON cd $HOME/frida-python/deps/toolchain-linux-arm64/bin/ # Some of the toolchain native binaries are broken so we'll swap them out here # Replace pkg-config mv pkg-config pkg-config.backup ln -sf $PREFIX/bin/pkg-config ./pkg-config # Replace ninja mv ninja ninja.backup ln -sf $PREFIX/bin/ninja ./ninja # In the termux environment libresolv doesn't exist but libresolv_wrapper does, so we'll make a symlink here too ln -sf $PREFIX/lib/libresolv_wrapper.so $PREFIX/lib/libresolv.so # Build with hijacked toolchain cd $HOME/frida-python rm -rf build/ LDFLAGS="-L$PREFIX/lib -lpython3.12 -llog -latomic" \ pip install . --no-index --no-build-isolation # LEAVE THE frida-python library before testing! cd ~ python3 -c "import frida;print(frida.__version__) ``` - Setup termux environment - Place `cli.py` in your home directory which should be `/data/data/com.termux/files/home` - Inside of the home folder `/data/data/com.termux/files/home`, install node dependencies `npm install buffer frida-java-bridge process`. This is needed for Frida 17 because you need to compile (in our case bundle and transpile) javascript code in order for it to run. This is due to the script's design of using temporary files inside of `/data/data/com.termux/files/usr/tmp` to handle bundling and transpiling. By hardcoding the path to home instead of using the default temp directory, we ensure the node_modules are persistent and reachable by esbuild. The process is: write temp file -> bundle/transpile -> pass "compiled" logic to the rest of the script. - Install `esbuild` globally, this is what we'll use to bundle and transpile scripts instead of `frida-compile` because `frida-compile` uses V8's JIT compiler, which requires W^X memory — blocked by Android's `untrusted_app` SELinux domain in Termux (causes SIGSEGV). `esbuild` is a statically linked Go binary with no JIT, so it runs cleanly. Can install with `npm` but can also install via `pkg install esbuild`. - Install python dependencies - `pip install -r requirements-android.txt` - **WARNING** Do not run `pip install frida`, because it will break. Build from source per the instructions above. - **WARNING** FastMCP 3.x has breaking API changes. This repo is still on FastMCP 2.x for both Android and iOS — migration hasn’t kept pace with upstream. Use `requirements-android.txt`; don’t install an unpinned `fastmcp`. - Install your target application. As a PoC we use [AndroGoat](https://github.com/satishpatnayak/AndroGoat) - **NOTE**: For some devices, Magisk places the `su` binary at `/system_ext/bin/su`, which the default root detection in AndroGoat doesn't check. Fix by changing `if(isRooted())// || isRooted1())` --> `if(isRooted() || isRooted1())` or adding your su binary path to the `isRooted` array. ## Android Happy Path Conversation with Gemini 2.5 Flash: User: ``` open owasp.sat.agoat ``` Gemini: ``` The application owasp.sat.agoat has been started with process ID (PID) 22153. ``` User: ``` create an interactive session with that new process ``` Gemini: ``` An interactive session has been created for process ID 22153. The session ID is session_22153_1766192976. ``` User: ``` can you generate frida code to intercept a method called isRooted1 in the class owasp.sat.agoat.RootDetectionActivity ``` Gemini: ``` The Frida script has been loaded into the application process. The script attempts to: 1. Locate the class owasp.sat.agoat.RootDetectionActivity. 2. Hook the method isRooted1. 3. Implement a bypass that logs the call and always returns false (to simulate a non-rooted device), effectively defeating this specific root detection check. The hooks are now active for the owasp.sat.agoat application. ``` **If this doesn't work, try just pasting in the contents of test-frida-script.js and say run this in the current session and set keep_alive to true.** **At this point you should be able to hit the "CHECK ROOT" button and see "Device is not rooted."** User: ``` can you kill the application that we launched ``` Gemini: ``` The process with PID 22153 (owasp.sat.agoat) has been successfully terminated. ``` --- # iOS Setup (`ios.py`) ## Tested on - iPhone X running iOS 16.7.12 - palera1n rootless jailbreak - Frida 17.6.0 - Custom Python 3.12.5 build (see below) - Gemini CLI v0.33.1 (Gemini 2.5 / Gemini 3) ## Prerequisites - A jailbroken iOS device (rootless jailbreak, e.g. palera1n) - SSH access to the device - A Frida server running on-device (match the frida-python version) ## Installing Python 3.12 No modern Python runtime exists in the Procursus repo for rootless jailbreaks. A custom Python 3.12.5 `.deb` is provided in `ios_precompiled/`. This is based on [python3.12-ios-arm64](https://github.com/k1tty-xz/python3.12-ios-arm64) by k1tty-xz, modified for rootless jailbreak support (`/var/jb/` layout). ```bash # Copy the deb to the device scp ios_precompiled/python3.12_3.12.5-1_iphoneos-arm64.deb mobile@:/tmp/ # Install (dpkg needs root — use sudo) ssh mobile@ sudo dpkg -i /tmp/python3.12_3.12.5-1_iphoneos-arm64.deb # Verify python3 --version ``` This installs to `/var/jb/usr/local/` (rootless jailbreak layout). It includes `libpython3.12.dylib`, the standard library, and OpenSSL/libffi support. ## Installing pip ```bash python3 -m ensurepip python3 -m pip install --upgrade pip ``` ## Installing precompiled wheels All required native wheels are provided in `ios_precompiled/`. These were cross-compiled from macOS targeting `arm64-apple-ios`. ```bash # Copy all wheels to the device scp ios_precompiled/*.whl mobile@:/tmp/ # Install each wheel (order matters for dependencies) ssh mobile@ python3 -m pip install /tmp/cffi-*.whl python3 -m pip install /tmp/cryptography-*.whl python3 -m pip install /tmp/pydantic_core-*.whl python3 -m pip install /tmp/rpds_py-*.whl python3 -m pip install /tmp/PyYAML-*.whl python3 -m pip install /tmp/frida-*.whl python3 -m pip install /tmp/lupa-*.whl ``` ### Signing after install (required) iOS requires code signing for all native extensions. After every `pip install` of a wheel containing `.so` files, you must re-sign them with `ldid`: ```bash PY_SITE="/var/jb/var/mobile/.local/lib/python3.12/site-packages" # Sign all native extensions find "$PY_SITE" -name "*.so" -type f -exec ldid -S {} \; # Or sign a specific package after install find "$PY_SITE/cryptography" -name "*.so" -type f -exec ldid -S {} \; ``` If you skip this step, Python will crash with `Killed: 9` when importing any native module. ## Installing pure-Python dependencies These don't need signing since they have no native code: ```bash python3 -m pip install -r requirements-ios.txt ``` **WARNING**: Do not run `pip install frida` — it will try to download a prebuilt binary that won't work. Use the provided wheel instead. **WARNING**: FastMCP 3.x has breaking API changes. This repo is still on FastMCP 2.x for both Android and iOS — migration hasn’t kept pace with upstream. Use `requirements-ios.txt`; don’t install an unpinned `fastmcp`. ## Fixing frida-tools shebangs (important) When you install `frida-tools` (which provides `frida-compile`), the script shebangs default to the Procursus Python 3.9 path. You need to update them to point to your Python 3.12: ```bash # Install frida-tools over the base frida library python3 -m pip install frida-tools # Fix shebangs in frida-tools scripts SCRIPTS="/var/jb/var/mobile/.local/bin" for script in "$SCRIPTS/frida" "$SCRIPTS/frida-compile" "$SCRIPTS/frida-discover" \ "$SCRIPTS/frida-kill" "$SCRIPTS/frida-ls-devices" "$SCRIPTS/frida-ps" \ "$SCRIPTS/frida-trace"; do if [ -f "$script" ]; then sed -i '' '1s|.*|#!/var/jb/usr/local/bin/python3|' "$script" fi done # Verify head -1 "$SCRIPTS/frida-compile" # Should show: #!/var/jb/usr/local/bin/python3 ``` Without this fix, `frida-compile` will either fail to launch or use the wrong Python and miss all your installed packages. ## Installing node_modules for frida-compile (no Node.js required on-device) This is a nodeless setup — Node.js does **not** need to be installed on the iPhone. However, `frida-compile` still resolves bridge imports from a `node_modules/` directory at runtime. Since `frida-objc-bridge` is just a JavaScript wrapper (no native code), you can install it on any machine with Node.js and copy the result over: ```bash # On your Mac/PC (or any machine with npm): mkdir /tmp/ios_modules && cd /tmp/ios_modules npm install frida-objc-bridge # Copy to iPhone: scp -r /tmp/ios_modules/node_modules mobile@:~/ ``` The `node_modules/` folder just needs to be in the same directory where `ios.py` runs (the home directory). ## Running the server ```bash # Place ios.py in your home directory scp ios.py mobile@:~/ # Run as the mobile user ssh mobile@ cd ~ python3 ios.py ``` The server starts on `0.0.0.0:6767` with streamable HTTP transport. ## Compiled packages reference All precompiled packages in `ios_precompiled/`: | Package | Version | Why it's needed | |---------|---------|----------------| | **Python 3.12.5** (`.deb`) | 3.12.5-1 | Base runtime — not available via Procursus for rootless jailbreaks | | **frida-python** | 17.6.0 | Core Frida bindings | | **pydantic-core** | 2.41.5 | Required by FastMCP / pydantic | | **cryptography** | 47.0.0.dev1 | Dependency chain for FastMCP; needed SIGILL fix for A11 (iPhone X) | | **cffi** | 2.0.1.dev0 | Required by cryptography | | **pyyaml** | 7.0.0.dev0 | Required by FastMCP deps | | **rpds-py** | 0.30.0 | Required by FastMCP deps | | **lupa** | 2.6 | Lua embedding | ## Target application notes As a PoC we use [DVIA-v2](https://github.com/prateek147/DVIA-v2) for jailbreak detection bypass. **NOTE**: DVIA-v2's jailbreak detection ("Jailbreak Test 2") does not reliably detect rootless jailbreaks (e.g. palera1n) because it checks for files/paths that only exist on rootful setups. To make the demo work, you need to patch the app so the jailbreak check always returns `true` (i.e. "Device is jailbroken") — then use Frida to bypass it back to `false`. This is similar to the Android setup where AndroGoat's `isRooted1` logic needed uncommenting to detect Magisk's non-standard `su` path. ## iOS Happy Path Full workflow validated with Gemini CLI v0.33.1 (Gemini 2.5 / Gemini 3): 1. Agent opens target app (e.g. DVIA-v2) 2. Agent creates interactive session with the running process 3. Agent runs one-shot script to enumerate ObjC classes containing "jailbreak" — output returned inline 4. Agent creates persistent hook to bypass jailbreak detection — hooks stay active 5. User triggers the jailbreak check in-app, sees "Device is not jailbroken" 6. Agent calls `get_session_messages` and sees hook intercept logs ``` ▝▜▄ Gemini CLI v0.33.1 ▝▜▄ ▗▟▀ Logged in with Google /auth ▝▀ Gemini Code Assist for individuals /upgrade ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ > Get device info and find the identifier for 'DVIA-v2'. Launch the app and immediately attach an interactive session using the returned PID. Find all Objective-C classes containing 'jailbreak' by executing a single Frida script that outputs the results via console.log(). Do not waste tokens listing processes or using persistent scripts. ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ✦ I will now retrieve the device information and locate the 'DVIA-v2' application identifier. ✦ I've identified the application as com.highaltitudehacks.DVIAswiftv2.U8VDD9PP9H. I will now launch the application and attach an interactive session to its PID. ✦ The application has been launched with PID 2509. I will now create an interactive session and search for Objective-C classes containing "jailbreak". ✦ I will now execute a Frida script within the interactive session to find all Objective-C classes containing "jailbreak" and log the results. ✦ I've retrieved the device information and application identifier for 'DVIA-v2' (com.highaltitudehacks.DVIAswiftv2.U8VDD9PP9H). After launching the application (PID 2509), I attached an interactive session and executed a Frida script to identify Objective-C classes containing "jailbreak". The script successfully identified two classes: JailbreakDetection and DVIA_v2.JailbreakDetectionViewController. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ > what methods are contained within the JailbreakDetection class? ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ✦ I will now list the methods for the JailbreakDetection class by executing a Frida script in the current session. ✦ The JailbreakDetection class contains many inherited methods, but the most relevant one is: - + isJailbroken (Class method) This method is likely used to perform the jailbreak detection logic. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ > can you create a persistent script to force that method to always be 0 ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ✦ I will now create and execute a persistent Frida script to hook the isJailbroken method and force it to return 0. ✦ I have successfully created and executed a persistent Frida script to hook the isJailbroken class method in the JailbreakDetection class. This script will now intercept any calls to that method and force its return value to 0, effectively bypassing the jailbreak detection logic. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ > looks like it worked, can you get session messages to make sure you're seeing it too? ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ ✦ I will now retrieve the session messages to confirm that the hook is intercepting calls and forcing the return value to 0. ✦ I've confirmed that the hook is active and working as expected. The session messages show that the isJailbroken method was intercepted, its original return value was 0x0, and it was successfully forced to 0. ```