Android Pentesting
Android is the most open mobile platform and therefore the easiest to audit: apps ship as an APK (really a ZIP with code compiled to DEX, resources, and the manifest), and with standard tools you can decompile them, read their code almost like the original, instrument them at runtime, and intercept their traffic. This card covers the Android-specific flow: getting the APK, static analysis, dynamic analysis, and the platform’s typical vectors.
flowchart TD
APK["APK (base.apk + splits)"] --> DEC["apktool / jadx"]
DEC --> MAN["AndroidManifest.xml"]
DEC --> CODE["smali/Java code"]
MAN --> EXP["Exported components"]
MAN --> DL["Deeplinks"]
CODE --> SEC["Secrets / endpoints"]
EXP --> DYN["Dynamic: adb + Frida"]
DL --> DYN
SEC --> DYN
DYN --> BK["Backend / API"]
Threat model
Section titled “Threat model”On Android the attacker can be another installed app, a user with root over their own device, or someone with physical/backup access. What they want:
- Secrets in the binary: API keys, credentials, and internal URLs in code, resources, or
.sofiles. - Exposed components: Activities/Services/Providers/Receivers with
exported="true"invokable by any app. - Poorly validated deeplinks: entry points that bypass the UI (see Deeplinks and IPC).
- Insecure storage: cleartext data in
shared_prefs/SQLite (see Insecure Storage). - Interceptable traffic: no TLS or bypassable pinning (see SSL Pinning and Bypass).
- Dangerous WebViews:
addJavascriptInterface, loading untrusted content.
The APK and its pieces
Section titled “The APK and its pieces”An APK is a ZIP; unzip -l base.apk already shows the structure:
AndroidManifest.xml— permissions, components, deeplinks,exported/debuggable/allowBackupflags.classes.dex(one or more) — Dalvik bytecode: the app’s code.resources.arscandres/— resources, strings, layouts.lib/<abi>/*.so— native libraries (C/C++ code).assets/— embedded files (sometimes config or secrets).
Modern apps ship as an App Bundle and the Play Store delivers several split APKs; analysing them often requires merging the splits.
Getting the APK
Section titled “Getting the APK”# from a device with the app installedadb shell pm list packages | grep targetadb shell pm path com.target.app # shows the APK path(s)adb pull /data/app/~~abc==/com.target.app-xyz==/base.apk# if there are splits (App Bundle): merge them with bundletool or use a mirrorStatic analysis
Section titled “Static analysis”# decompile to smali + readable resources (decodes the binary manifest)apktool d base.apk -o out/# DEX -> Java for comfortable readingjadx-gui base.apk # GUI decompilerjadx -d out_jadx base.apk # CLI mode# classic alternatived2j-dex2jar base.apk && jd-gui base-dex2jar.jarWhat to review in the manifest and code:
# dangerous flags in the decoded manifestgrep -E 'android:(debuggable|allowBackup|exported|usesCleartextTraffic)' out/AndroidManifest.xml# secrets in code, resources, and assetsgrep -rniE 'api[_-]?key|secret|password|token|BEGIN (RSA|PRIVATE)|https?://' out/# secrets in native librariesstrings out/lib/*/*.so | grep -iE 'http|key|secret'android:debuggable="true"→ debuggable app: extract data withrun-aswithout root.android:allowBackup="true"→ backup extractable withadb backup.android:usesCleartextTraffic="true"→ allows cleartext HTTP.- Components with
exported="true"or anintent-filter→ IPC surface.
Dynamic environment
Section titled “Dynamic environment”# emulator (AVD) or rooted deviceadb devicesadb shell# proxy to intercept traffic (see mob-ssl): Burp + its CA# runtime instrumentation (see mob-frida)frida-ps -U # device processes over USBobjection -g com.target.app explore # interactive explorationIPC and exported components
Section titled “IPC and exported components”Exported components are Android’s key surface: an Activity, Service, Content Provider, or Broadcast Receiver with exported="true" can be invoked by any other app or by adb, bypassing UI controls.
# launch an exported Activityadb shell am start -n com.target.app/.AdminActivity# start an exported Serviceadb shell am start-service -n com.target.app/.SyncService# send a Broadcastadb shell am broadcast -a com.target.app.ACTION_RESET# query an exported Content Provideradb shell content query --uri content://com.target.app.provider/usersAn exported Content Provider without permissions can leak data or be vulnerable to SQLi/path traversal; a Receiver can trigger logic with forged intents. drozer automates the whole analysis of this surface:
drozer console connectrun app.package.attacksurface com.target.apprun app.provider.query content://com.target.app.provider/usersRed Team
Section titled “Red Team”Testing against an app you own or have permission to test:
- Extract secrets: review
strings.xml,BuildConfig, assets, and.so; many apps leave third-party keys or internal endpoints. - Abuse exported/deeplinks: invoke internal Activities and try malicious parameters.
- Backup/debug: if
allowBackup=true,adb backup -f backup.ab com.target.appand extract withabe.jar; ifdebuggable=true,run-asgives access to the data without root. - WebViews: look for
setJavaScriptEnabled(true),addJavascriptInterface, and loading of controllable URLs. - Traffic and backend: bypass pinning (SSL Pinning and Bypass) and attack the API like a web app (Web Methodology).
# backup without root (if allowBackup=true)adb backup -f backup.ab -noapk com.target.app# read a debuggable app's data without rootadb shell run-as com.target.app cat /data/data/com.target.app/shared_prefs/prefs.xmlBlue Team
Section titled “Blue Team”- Don’t hardcode secrets; move keys and sensitive logic to the backend.
- In production:
debuggable=false,allowBackup=false(or afullBackupContentthat excludes sensitive data),usesCleartextTraffic=false. - Minimise exported components;
exported=falseby default, protect the necessary ones withsignaturepermissions, and validate all input (intents, Content Providers). - Encrypted storage (Insecure Storage) and TLS + pinning (SSL Pinning and Bypass).
- Secure WebViews: no unnecessary
addJavascriptInterface, no loading of untrusted content,setAllowFileAccess(false). - MASVS-RESILIENCE: root/tamper/debug detection and obfuscation with R8/ProGuard raise the cost, they don’t replace backend security.
Checklist
Section titled “Checklist”- Get the APK (adb pull / bundletool / mirror)
- Decompile (apktool/jadx) and review the manifest
-
debuggable/allowBackup/exported/usesCleartextTrafficflags - Secrets in code/resources/assets/
.so - Exported components and IPC (drozer,
am/content) - Deeplinks (Deeplinks and IPC)
- Insecure storage (Insecure Storage)
- Backup/debug extractable without root
- Insecure WebViews (
addJavascriptInterface) - Traffic + SSL pinning (SSL Pinning and Bypass) and backend