--- name: android-apk-recon-static description: Android APK acquisition and static recon — pull/merge split APKs, decompile with apktool/jadx/dex2jar, detect packers/obfuscators with apkid, and map the attack surface (entry points, dangerous APIs). Tier 1. Prerequisite for all other Android static work. Use at the start of any APK engagement. Aligns to OWASP MASTG. --- # Android APK Recon & Static Analysis Acquire the APK (merging splits), decompile it, and map the code so later skills know where to look. First step of every Android test. ## Trigger phrases `apk, pull apk, split apk, apkeditor, apktool, jadx, dex2jar, apkid, decompile, smali, android static analysis, mobsf baseline` ## Method 1. **Locate & pull** the package: - `adb shell pm list packages | grep ` - `adb shell pm path ` — lists base + split paths. - `adb pull /data/app/.../base.apk ./` 2. **Merge split/App-Bundle APKs** (standalone base often won't install / misses resources): - `adb shell pm path | cut -d ':' -f 1 | xargs -n1 -I{} adb pull {} splits/` - `java -jar APKEditor.jar m -i splits/ -o merged.apk` - `java -jar uber-apk-signer.jar -a merged.apk --allowResign -o merged_signed` 3. **Baseline with MobSF** (automated static) for a fast overview, then go manual. 4. **Decompile:** - `apktool d app.apk -o app_src` — smali + decoded manifest + resources. - `jadx -d app_java app.apk` (or `jadx-gui app.apk` interactive) — Java. - `d2j-dex2jar app.apk -o app.jar && jd-gui app.jar` — alternate Java path when jadx fails. 5. **Fingerprint packing/obfuscation:** `apkid app.apk` — flags packers, obfuscators, anti-VM/anti-debug (dictates whether you need `android-native-lib-analysis` / `android-root-antidebug-bypass`). 6. **Map the attack surface** — grep decompiled code for entry points and dangerous APIs: - `grep -rniE "Runtime.exec|ProcessBuilder|loadUrl|addJavascriptInterface|openFileOutput|getExternalStorage|WebView" app_java/` - Note Activities/Services/Receivers/Providers, crypto, network, and auth logic for the specialized skills. 7. **Repackage** (after smali edits for later tests): `apktool b app_src -o patched.apk && java -jar uber-apk-signer.jar -a patched.apk --allowResign`. ## Modern / rare techniques - **In-memory decrypt of packed/encrypted DEX** with Frida when `apkid` flags a packer — dump the real classes at runtime instead of fighting the unpacker statically. - **Merged-bundle gotcha:** a single `base.apk` that fails to install standalone, or missing resources in jadx, means a split bundle — always merge before concluding "no resources." ## Escalation / chaining Feeds every other Android skill: manifest → `android-manifest-analysis`; strings/keys → `android-secrets-hardcoded`; `.so` → `android-native-lib-analysis`; obfuscation/anti-tamper → `android-root-antidebug-bypass`. ## Backend & tooling Preferred Kali path (native Kali / WSL+Kali / Kali-SSH / Kali-MCP / HexStrike). These need the user's device/emulator (adb) + Kali tooling (apktool/jadx/dex2jar/apkid/MobSF/APKEditor). Windows-local last resort. See `zazy-orchestrator`. ## Verification (background, before reporting) Confirm the decompile is complete (resources + all DEX present after merge) before basing findings on it; re-decompile with a second tool (dex2jar/JD-GUI) if jadx output looks truncated or obfuscated. ## Evidence Package name, APK hash(es), apkid output, decompiled tree, and a surface map (components, dangerous API call sites) to drive the rest of the engagement. Remediation: R8/ProGuard, move secrets/logic server-side or to NDK, integrity checks.