Skip to content
Back to skills

Android Frida Hook

ASecurity

Generates production-grade Frida 16 and Frida 17 instrumentation scripts for authorized Android app reverse engineering. Use when writing Frida Java or Native hooks, fixing Frida 17 API crashes (Memory.readUtf8String removal, bridge loading), inspecting overloaded or obfuscated Java methods, hooking dynamically loaded DEX, or diagnosing SSL Pinning and proxy detection.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
developmentjavascriptrustjavarailsdebuggingapi

Works with

  • api
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add muyang520/awesome-mobile-re-mcp-skills --skill android-frida-hook --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Android Frida Hook?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Android Frida Hook
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/muyang520-android-frida-hook/badge)](https://www.skillsdirectory.com/skills/muyang520-android-frida-hook)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: android-frida-hook
description: >-
  Generates production-grade Frida 16 and Frida 17 instrumentation scripts for authorized Android app reverse engineering.
  Use when writing Frida Java or Native hooks, fixing Frida 17 API crashes (Memory.readUtf8String removal, bridge loading),
  inspecting overloaded or obfuscated Java methods, hooking dynamically loaded DEX, or diagnosing SSL Pinning and proxy detection.
---

# Android Frida Hooking & Runtime Triage SOP (Frida 16/17 Safe)

LLMs frequently generate broken Frida scripts due to **Frida 17 breaking API changes**, uninspected Java method overloads, raw `byte[]` UTF-8 corruption, and premature hooks before `DexClassLoader` or `System.loadLibrary` runs. Follow every rule below when authoring or debugging Android Frida scripts.

- **Bundled Frida 17 Swiss-Army Script**: [frida17_android_swiss_army.js](./scripts/frida17_android_swiss_army.js)

---

## Rule 1: Mandatory Frida 17 Compatibility Guardrails

Frida 17.0+ removed legacy `Memory.*` static helpers and decoupled language bridges in custom compiled agents:

| Deprecated / Broken in Frida 17 (NEVER WRITE) | Correct Frida 16 & 17 Idiom (ALWAYS WRITE) |
| :--- | :--- |
| `Memory.readUtf8String(p)` | `p.readUtf8String()` |
| `Memory.readCString(p)` | `p.readCString()` |
| `Memory.readByteArray(p, len)` | `p.readByteArray(len)` |
| `Memory.writeByteArray(p, bytes)` | `p.writeByteArray(bytes)` |
| `Memory.readPointer(p)` | `p.readPointer()` |
| `Module.findExportByName("libc.so", "open")` (Frida 17 prefers instance call) | `Process.getModuleByName("libc.so").findExportByName("open")` (or `Module.findGlobalExportByName("open")` on 17+) |

> **Frida 17 Bridge Check**: If `typeof Java === "undefined"` inside an embedded gadget or custom agent, compile with `frida-compile` importing `frida-java-bridge` (`import Java from "frida-java-bridge";`), or verify `frida-server` matches the host `frida-tools` major version (`17.x` <-> `17.x`).

---

## Rule 2: Never Hook Overloaded Java Methods Blindly

Obfuscated Android apps (`a.b.c(String, byte[], int)`) routinely overload method names 5–20 times. Calling `Cls.a.implementation = ...` without `.overload(...)` throws an immediate runtime exception.

Always iterate `.overloads` dynamically when exact parameter types are unconfirmed, and serialize `byte[]` safely as both Hex and printable preview:

```javascript
function bytesToHex(javaBytes) {
  if (!javaBytes) return "null";
  const u8 = Java.array("byte", javaBytes);
  return Array.from(u8, b => ((b & 0xff).toString(16).padStart(2, "0"))).join("");
}

function hookAllOverloads(className, methodName, printStack = false) {
  Java.perform(() => {
    const Target = Java.use(className);
    const Throwable = Java.use("java.lang.Throwable");
    const Log = Java.use("android.util.Log");

    if (!Target[methodName]) {
      console.log(`[!] Method ${methodName} not found on ${className}`);
      return;
    }

    Target[methodName].overloads.forEach((ov, idx) => {
      const sig = ov.argumentTypes.map(t => t.className).join(", ");
      console.log(`[+] Hooking ${className}.${methodName}(${sig}) [#${idx}]`);

      ov.implementation = function (...args) {
        const formattedArgs = args.map((arg, i) => {
          if (arg === null || arg === undefined) return `arg${i}=null`;
          if (sig.split(", ")[i] === "[B") return `arg${i}(hex)=${bytesToHex(arg)}`;
          return `arg${i}=${arg}`;
        });
        const ret = ov.apply(this, args);
        const retStr = (ov.returnType.className === "[B") ? bytesToHex(ret) : String(ret);
        console.log(`\n[*] ${className}.${methodName}(${formattedArgs.join(", ")}) => ${retStr}`);
        if (printStack) {
          console.log(Log.getStackTraceString(Throwable.$new()));
        }
        return ret;
      };
    });
  });
}
```

---

## Rule 3: Handling Packed Apps & Dynamic `DexClassLoader`

If `Java.use("com.target.SignUtil")` throws `ClassNotFoundException`, **do not guess the class doesn't exist**—commercial apps often load business DEX via secondary `ClassLoader`s (`InMemoryDexClassLoader`, `DexClassLoader`, or packed `Application.attachBaseContext`):

```javascript
Java.perform(() => {
  Java.enumerateClassLoaders({
    onMatch(loader) {
      try {
        if (loader.findClass("com.target.SignUtil")) {
          Java.classFactory.loader = loader;
          console.log(`[+] Switched active ClassLoader to: ${loader}`);
        }
      } catch (_) {}
    },
    onComplete() {}
  });
});
```

---

## Rule 4: Authorized Network & Proxy/VPN Detection Triage

When an Android app shows `"Network Error"` only while MITM proxy or VPN is active, check these 3 layers in order before assuming custom native TLS:

1. **Proxy / VPN Environment Checks**:
   - `System.getProperty("http.proxyHost")` / `"http.proxyPort"` -> return `null` / `""`.
   - `NetworkInterface.getName()` -> inspect callers checking `"tun0"`, `"ppp0"`, or `"wlan0"` VPN flags.
   - `ConnectivityManager.getNetworkCapabilities(...)` -> `hasTransport(NetworkCapabilities.TRANSPORT_VPN)` (`0x4`).
2. **Java/Conscrypt Trust & Pinning**:
   - `com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive` (Android 7+ system CA check).
   - `okhttp3.CertificatePinner.check` (note: often ProGuard/R8-obfuscated; locate in `jadx-ai-mcp` by searching `"Certificate pinning failure!"` or `"sha256/"`).
3. **Cronet / Conscrypt Native Engine (`libsscronet.so`, `libcronet.*.so`, `libboringssl.so`)**:
   - Search loaded modules via `Process.enumerateModules().filter(m => /ssl|cronet|boring|quic|net/i.test(m.name))`.
   - Disable QUIC/HTTP3 early or hook BoringSSL `SSL_CTX_set_custom_verify` / `ssl_crypto_x509_session_verify_cert_chain`.

---

## Verification Steps
1. If `jadx-ai-mcp` is available, search string constants (`"sha256/"`, `"X-Sign"`, `System.loadLibrary`) **before** writing hooks so class and method signatures are exact.
2. Run `frida -U -f <package> -l hook.js` (spawn mode) for early initialization (`JNI_OnLoad`, `CertificatePinner` builder), or `-F` (attach foreground) for post-login UI actions to avoid startup anti-Frida sweeps.

Files in this skill

  • SKILL.md6 KB
  • scripts/frida17_android_swiss_army.js4.8 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.