hypnguyen1209/offensive-claude / skills/mobile-pentest
mobile-pentest
UnverifiedUse when pentesting an Android/iOS app — Frida 17 instrumentation, SSL-pinning & root/jailbreak bypass, Android 14/15 CA injection, exported-component/content-provider abuse, deep-link/WebView chains, biometric bypass, Flutter/React-Native RE
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.7 KB |
| references/android-component-attacks.md | markdown | 10.5 KB |
| references/crossplatform-re-instrumentation.md | markdown | 8.9 KB |
| references/environment-interception.md | markdown | 12.1 KB |
| references/insecure-storage-crypto.md | markdown | 8.7 KB |
| references/ios-offensive.md | markdown | 8.1 KB |
| references/webview-deeplink-exploitation.md | markdown | 9.3 KB |
| scripts/android_ca_inject.sh | script | 2.8 KB |
| scripts/component_fuzz.sh | script | 4.1 KB |
| scripts/hermes_triage.py | script | 5.6 KB |
| scripts/ios_bypass_suite.js | script | 6.0 KB |
| scripts/manifest_attack_surface.py | script | 8.2 KB |
| scripts/universal_unpin.js | script | 6.7 KB |
references/crossplatform-re-instrumentation.md
View on GitHub# Cross-Platform RE & Native Instrumentation
> **ATT&CK (Mobile):** T1521.001 (Encrypted Channel / pinning bypass), T1640 (bytecode RE), T1635 (Install Insecure/Malicious Config) · **CWE:** CWE-295, CWE-656
Hybrid/native targets that defeat the default Java/ObjC hooks: **Flutter** (Dart compiled to native,
own TLS stack, ignores system proxy), **React Native Hermes** (compiled JS bytecode), and raw
**NDK `.so`** native libraries. How to identify, reverse, intercept, and patch each.
---
## 1. Detecting the Framework
```bash
apktool d base.apk -o decoded ; unzip -o base.apk -d unz >/dev/null
# Flutter
ls decoded/lib/*/ | grep -E 'libflutter\.so|libapp\.so'
# React Native + Hermes
ls unz/assets/ | grep -E 'index\.android\.bundle'
file unz/assets/index.android.bundle
# "Hermes JavaScript bytecode, version NN" => Hermes (binary, needs hermes-dec/hbctool)
# ASCII/JS text => plain RN (just beautify the JS)
ls decoded/lib/*/ | grep -E 'libhermes\.so|libjsc\.so|libreactnativejni\.so'
# Native NDK
file decoded/lib/arm64-v8a/*.so
```
`scripts/hermes_triage.py` automates this detection across split APKs and prints the next-step command
for each framework (Hermes version, Flutter engine presence, native libs + their exported `Java_*`/JNI
symbols).
---
## 2. Flutter — Interception & Pinning Bypass
**Why default tricks fail**: Flutter's `dart:io` HTTP client has its **own** TLS stack and **ignores the
Android system proxy and user CA store**. Cert verification lands in BoringSSL inside `libflutter.so` at
`ssl_crypto_x509_session_verify_cert_chain`.
### 2a. reFlutter (static patch — most reliable)
```bash
pip install reflutter
reflutter base.apk # choose option 1 (traffic interception); patches libflutter.so
# -> outputs release.RE.apk ; signature is now invalid, re-sign:
apksigner sign --ks debug.keystore --ks-pass pass:android release.RE.apk
adb install release.RE.apk
# reFlutter routes traffic to the proxy it baked in; set Burp to that IP:port and DISABLE system proxy.
```
Caveats (2025-2026): reFlutter matches **byte patterns** in known engine builds — it can fail on very
recent Flutter engine versions, and for **split APKs** you must patch the APK that actually contains
`libflutter.so`. `scripts/hermes_triage.py --flutter` identifies the correct split.
### 2b. Frida native hook (when reFlutter can't patch the engine version)
```js
// Locate libflutter.so and neutralize cert-chain verification.
// Pattern-scan for ssl_crypto_x509_session_verify_cert_chain or hook BoringSSL custom_verify.
const fl = Process.getModuleByName('libflutter.so');
const setVerify = fl.findExportByName ? fl.findExportByName('SSL_CTX_set_custom_verify') : null;
// libflutter often strips symbols; fall back to a memory pattern for the verify routine, then:
Interceptor.attach(targetVerifyAddr, { onLeave(ret) { ret.replace(0); } }); // 0 = ssl_verify_ok
```
### 2c. Transport-layer fallback (proxy-unaware / anti-proxy apps)
```bash
# iptables transparent redirect beats proxy-detection logic and Dart's proxy-ignorance
adb shell su -c 'iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to <PROXY_IP>:8080'
adb shell su -c 'iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to <PROXY_IP>:8080'
# Or ProxyDroid / DNS redirect (DNSChef) to capture device traffic regardless of app proxy settings.
```
---
## 3. React Native — Hermes Bytecode RE
Hermes is the default RN engine on Android since **RN 0.70**. Release bundles are compiled HBC (no
variable names; you get `closure_0`, `r10020`). Tooling:
| Tool | Use | Notes |
|------|-----|-------|
| **hermes-dec** (P1 Security) | disassemble + pseudo-decompile | `hbc-disassembler` / `hbc-decompiler`; aims at all HBC versions; OWASP MASTG-TOOL-0104. Output uses jumps/labels + registers. |
| **hbctool** (bongtrop) | disasm **and reassemble** | best for **patching**: `disasm` → edit `.hasm` → `asm`; supports a limited HBC-version set. |
| **hermes-decomp** (SymbioticSec) | structured decompile (Rust) | reconstructs `if/while/for`; HBC v40–99; xref/bin-diff/graphviz. |
```bash
# Identify version, then disassemble
file unz/assets/index.android.bundle # e.g. "version 96"
pip install hermes-dec
hbc-disassembler unz/assets/index.android.bundle out.hasm
hbc-decompiler unz/assets/index.android.bundle out.pseudo.js
# Patch a check (e.g. premium/jailbreak gate) and reassemble with hbctool
pip install hbctool || git clone https://github.com/bongtrop/hbctool
hbctool disasm unz/assets/index.android.bundle hasm_dir
# edit hasm_dir/instruction.hasm: make the gating function return true
hbctool asm hasm_dir index.android.bundle.patched
cp index.android.bundle.patched decoded/assets/index.android.bundle
apktool b decoded -o patched.apk && apksigner sign --ks debug.keystore patched.apk
```
### 3a. Dynamic injection via Frida (no static patch)
`libhermes.so`'s `loadScriptFromAssets` (in `CatalystInstanceImpl`) loads the bundle. Hook it and load
your own JS into the live runtime:
```js
Java.perform(() => {
const CI = Java.use('com.facebook.react.bridge.CatalystInstanceImpl');
// After init, push a script you control that exists in a readable path
CI.loadScriptFromFile.implementation = function (file, src, x) {
console.log('[hermes] loadScriptFromFile ' + file);
return this.loadScriptFromFile('/data/local/tmp/inject.js', src, x);
};
});
```
---
## 4. Native `.so` (NDK / JNI) Analysis
```bash
# Triage exported JNI surface
nm -D --defined-only decoded/lib/arm64-v8a/libnative.so | grep -E 'Java_|JNI_OnLoad'
readelf -d decoded/lib/arm64-v8a/libnative.so | grep NEEDED
# Decompile in Ghidra/IDA: start at JNI_OnLoad (often does RegisterNatives to hide symbol names),
# then trace Java_<pkg>_<class>_<method>. Look for: hardcoded keys, custom pinning, anti-tamper.
```
Trace native calls at runtime with Frida (covers obfuscated native pinning/anti-debug):
```js
const m = Process.getModuleByName('libnative.so');
m.enumerateExports().filter(e => e.name.startsWith('Java_') || e.name === 'JNI_OnLoad')
.forEach(e => Interceptor.attach(e.address, {
onEnter(a) { console.log('[native] ' + e.name); },
onLeave(r) { /* inspect/override return for anti-debug routines */ }
}));
```
For deeper static work hand off to the `reverse-engineering` skill (Ghidra/IDA, JNI struct typing,
RegisterNatives recovery).
---
## Detection
- **Flutter reFlutter patch**: the APK is repackaged/re-signed → **signature changes**; integrity/Play
Integrity attestation and app self-signature checks detect it. Runtime BoringSSL hook leaves a modified
prologue at the verify routine (detectable by native integrity checks). TLS: leaf cert = proxy cert.
- **Hermes patch**: modified `index.android.bundle` → bundle hash/signature mismatch if the app verifies
it; re-signed APK fails attestation. Dynamic `loadScriptFromFile` hook is a Frida IOC.
- **Native hooks**: Interceptor trampolines are detectable by CRC/PROT checks on `.text`.
- Sigma (proxy egress) for hybrid-app interception is the same TLS-fingerprint/proxy-cert rule as in
`environment-interception.md`:
```yaml
title: Hybrid App TLS via Interception Proxy
logsource: { category: proxy }
detection: { sel: { tls.ja3: '<known mitm JA3>' }, condition: sel }
level: high
```
## OPSEC
- Prefer **reFlutter static patch** over a runtime BoringSSL hook for Flutter — runtime hooks on the
stripped verify routine are crash-prone across engine versions.
- For Hermes, prefer **dynamic `loadScriptFromFile` injection** if you only need behavior change; static
reassembly changes the bundle hash and is more detectable.
- Re-sign with a throwaway debug keystore; the repackaged app is attributable, keep it on lab devices.
- Transport-layer `iptables` redirect is the stealthiest interception vs the app (no proxy setting, no
patch) but requires root and touches device netfilter rules — flush them after (`iptables -t nat -F OUTPUT`).
## References
- SensePost — Intercepting HTTPS in Flutter, full hardcore Frida (2025) — https://sensepost.com/blog/2025/intercepting-https-communication-in-flutter-going-full-hardcore-mode-with-frida/
- reFlutter (Impact-I) — https://github.com/Impact-I/reFlutter
- l33t-En0ugh — Bypass SSL pinning for Flutter via reFlutter — https://l33t-en0ugh.gitbook.io/infosec/android-pentesting/bypass-ssl-pinning-for-flutter-apps-using-reflutter-framework
- P1 Security — hermes-dec disassembler/decompiler — https://github.com/P1sec/hermes-dec and https://www.p1sec.com/blog/releasing-hermes-dec-an-open-source-disassembler-and-decompiler-for-the-react-native-hermes-bytecode
- OWASP MASTG — hermes-dec (MASTG-TOOL-0104) — https://mas.owasp.org/MASTG/tools/generic/MASTG-TOOL-0104/
- bongtrop — hbctool (assemble/disassemble HBC) — https://github.com/bongtrop/hbctool
- SymbioticSec — hermes-decomp — https://github.com/SymbioticSec/hermes-decomp
- Cognisys Labs — How to Decompile a Hermes React Native Binary — https://labs.cognisys.group/posts/How-to-Decompile-Hermes-React-Native-Binary/
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |