--- name: android-pentest description: Android application penetration testing — APK static analysis, insecure data storage, exported-component and IPC abuse, insecure communication and certificate-pinning bypass, dynamic instrumentation with Frida/objection, deep-link and WebView attacks, root detection bypass, and backend/API testing. Aligns to OWASP MASVS/MASTG. Use for any APK or Android target. --- # Android Penetration Testing Test the app (static + dynamic), its local data, its IPC surface, and its backend. Align to OWASP MASVS; use MASTG techniques. Most high-impact findings are insecure storage, broken IPC/exported components, weak crypto, and backend authorization. ## Trigger phrases `android, apk, mobile app, frida, objection, mobsf, smali, deep link, webview, certificate pinning, root detection, keystore` ## Toolchain (WSL/Kali or host) `apktool`, `jadx`/`jadx-gui`, `dex2jar`, `MobSF` (static+dynamic), `frida`/`objection`, `adb`, `drozer`, `nuclei`, Burp with device proxy, an emulator (Genymotion/AVD) or rooted device. ## 1. Acquire & inventory - Obtain the APK (from device via `adb pull`, or provided). Split APKs: merge with `apkeditor`/bundletool. - `MobSF` for a fast baseline. Then manual: `apktool d app.apk` (resources/manifest/smali), `jadx` (Java source). ## 2. Static analysis - **Manifest:** `android:debuggable`, `allowBackup`, `usesCleartextTraffic`, `minSdk` (old = more exploitable), exported `activity`/`service`/`receiver`/`provider` (no permission), custom permissions, deep-link `intent-filter` schemes/hosts, `networkSecurityConfig`. - **Secrets:** hardcoded API keys, tokens, endpoints, crypto keys, Firebase URLs, cloud creds in `strings.xml`, `BuildConfig`, resources, native libs (`strings` on `.so`). Check for exposed Firebase (`.firebaseio.com/.json`), open S3/GCS. - **Crypto & logic:** weak algorithms (ECB, hardcoded IV/keys), custom crypto, insecure random, root/pinning logic (to bypass later), auth logic, feature flags. ## 3. Insecure data storage On a rooted device/emulator, inspect after using the app: - `/data/data//`: `shared_prefs` (tokens/PII in plaintext), `databases` (SQLite — creds, cached data), `files`, external storage (world-readable), cache. - Keystore misuse, backup extraction (`adb backup` if `allowBackup=true`), logcat leakage (`adb logcat` — tokens/PII printed), clipboard, screenshots in app-switcher. ## 4. IPC / exported-component abuse - **Exported activities:** launch directly (`adb shell am start`) to bypass auth screens / access internal screens. - **Services/receivers:** send crafted intents (`am startservice`, `am broadcast`) to trigger privileged actions. - **Content providers:** query/update exported providers (`adb shell content query --uri content://...`), test SQLi and path traversal in provider paths (file disclosure). - **drozer** for systematic IPC attack-surface enumeration and exploitation. - **Intent redirection / task hijacking**, pending-intent abuse. ## 5. Deep links & WebView - **Deep links:** fuzz registered schemes/hosts; can you reach authenticated screens, inject params, or trigger actions unauthenticated? Open-redirect-style abuse, parameter injection into WebView. - **WebView:** `setJavaScriptEnabled(true)` + `addJavascriptInterface` (JS→native bridge → RCE on old APIs), `loadUrl` with attacker URL, file access (`setAllowFileAccess`, `file://` → local file theft), XSS in WebView reaching the bridge. ## 6. Dynamic instrumentation (Frida/objection) - **objection:** `android hooking`, dump keystore, disable SSL pinning (`android sslpinning disable`), bypass root detection (`android root disable`), inspect/invoke methods, read memory. - **Frida scripts:** hook crypto to grab keys/plaintext, bypass pinning and root/jailbreak checks, tamper logic (feature unlock, auth bypass), trace sensitive methods. ## 7. Network / communication - Proxy traffic (install Burp CA; for Android 7+ use the networkSecurityConfig/Frida pinning bypass). Inspect all API calls; test the backend with `api-security` + web skills (this is where most real impact is). - Cleartext traffic, weak TLS, cert validation disabled, pinning that's bypassable. ## 8. Backend testing The mobile backend is a full API — run `api-security`, `web-access-control`, `web-auth-session`, `web-sqli`, etc. against captured endpoints. Mobile apps often expose weaker/legacy endpoints. ## Depth & chaining - Hardcoded cloud/API keys → backend/cloud compromise (→ `cloud-pentest`). - Exported provider SQLi/traversal → local data theft; WebView bridge → RCE. - Pinning bypass unlocks the whole backend test — do it early. ## Evidence `adb`/Frida output, extracted secrets (redacted), the vulnerable manifest/component, intercepted requests, and dynamic PoCs. Map each to MASVS control.