| name | android-app-pentesting |
| description | Android application security testing and vulnerability assessment. Use this skill whenever the user needs to analyze Android APKs, test for security vulnerabilities, enumerate components, exploit intents/deep links, or assess AIDL/Binder services. Trigger for any Android security testing, mobile pentesting, APK analysis, or Android vulnerability research tasks. |
Android Application Pentesting
A comprehensive skill for security testing Android applications, from initial reconnaissance to exploitation of common vulnerabilities.
Quick Start
adb shell pm list packages -f | grep <package-name>
adb pull /data/app/<package-name>/base.apk
apktool d base.apk -o <output-dir>
adb shell dumpsys package <package-name> | grep -A 5 "exported"
Android Security Model
Core Concepts
UID Separation: Each app runs under a unique User ID. Apps can only access their own files or shared files. Only the app itself, OS components, and root can access app data.
Sandboxing: Android 5.0+ enforces SELinux, denying all process interactions by default and only allowing expected ones through policies.
Permissions: Declared in AndroidManifest.xml via <uses-permission> elements. Types:
- Normal: Auto-granted, no user approval needed
- Dangerous: Requires user approval, grants elevated access
- Signature: Only apps signed with same certificate
- SignatureOrSystem: Same certificate OR system-level access
Permission Analysis
adb shell dumpsys package <package-name> | grep -A 100 "requested permissions"
adb shell dumpsys package <package-name> | grep -A 100 "granted permissions"
APK Structure Analysis
Extract and Decompile
adb pull /data/app/<package-name>/base.apk ./
apktool d base.apk -o decompiled/
unzip -l base.apk | grep -E "(AndroidManifest|classes.dex|META-INF)"
Key Files to Analyze
| File | Purpose | Security Relevance |
|---|
AndroidManifest.xml | App configuration | Exported components, permissions, intent filters |
classes.dex | Compiled code | Business logic, vulnerability patterns |
META-INF/CERT.RSA | Certificate | App signing verification |
lib/ | Native libraries | Native code vulnerabilities |
assets/ | Additional files | Hidden code, malware |
Smali Analysis
dex2jar base.apk
jad-decompile classes-dex2jar.jar
apktool d base.apk -o decompiled/
Component Enumeration
Activities
adb shell dumpsys package <package-name> | grep -A 100 "activities"
adb shell dumpsys package <package-name> | grep "exported=" | grep "true"
adb shell dumpsys package <package-name> | grep -A 5 "intent-filter"
Services
adb shell dumpsys package <package-name> | grep -A 100 "services"
adb shell dumpsys package <package-name> | grep "service.*exported"
adb shell service list
Broadcast Receivers
adb shell dumpsys package <package-name> | grep -A 100 "receivers"
adb shell dumpsys package <package-name> | grep "receiver.*exported"
Content Providers
adb shell dumpsys package <package-name> | grep -A 100 "providers"
adb shell dumpsys package <package-name> | grep -A 5 "provider"
Intent Vulnerability Testing
Implicit Intent Testing
adb shell am start -a android.intent.action.VIEW \
-d "<scheme>://<host>/<path>"
adb shell am start -a android.intent.action.SEND \
-t "text/plain" \
-e android.intent.extra.TEXT "test payload"
Deep Link Exploitation
adb shell am start -a android.intent.action.VIEW \
-d "<scheme>://<host>/<path>?param=value"
adb shell am start -n <package>/<Activity> \
-a android.intent.action.VIEW \
-d "<scheme>://<host>/<path>"
adb shell am start -a android.intent.action.VIEW \
-d "<scheme>://<host>/web?url=javascript:alert(1)"
Deep Link Discovery
grep -r "android.intent.action.VIEW" decompiled/AndroidManifest.xml
grep -r "android.intent.category.BROWSABLE" decompiled/AndroidManifest.xml
grep -oP 'android:scheme="\K[^"]+' decompiled/AndroidManifest.xml
Common Deep Link Attack Vectors
- Open Redirect:
myapp://host/path?redirect=https://attacker.tld
- Auth Bypass:
myapp://host/login?token=<malicious-token>
- WebView Injection:
myapp://host/web?url=javascript:alert(1)
- Parameter Pollution:
myapp://host/action?param=value¶m=malicious
AIDL/Binder Service Testing
Service Discovery
adb shell service list
adb shell am list services
Service PING (Interface Check)
adb shell service call <service-name> 1
Transaction Calling
adb shell service call mtkconnmetrics 8 i32 1
Brute-Force Method Discovery
for i in $(seq 1 50); do
printf "[+] %2d -> " $i
adb shell service call <service-name> $i 2>/dev/null | head -1
done
Method Mapping via onTransact()
dex2jar <service-jar>
grep -A 100 "onTransact" <decompiled-class>
case TRANSACTION_methodName: // code
data.enforceInterface(DESCRIPTOR);
int param = data.readInt();
methodName(param);
reply.writeNoException();
return true;
Permission Check Analysis
grep -B 5 -A 10 "updateCtaAppStatus\|startMonitor\|privileged" <smali-file>
private void updateCtaAppStatus(int uid, boolean status) {
// No permission check - VULNERABLE
/* privileged code */
}
private void updateCtaAppStatus(int uid, boolean status) {
if (!isPermissionAllowed()) {
throw new SecurityException("uid " + uid + " rejected");
}
/* privileged code */
}
Content Provider Testing
Provider Enumeration
adb shell dumpsys package <package-name> | grep -A 20 "provider"
grep -A 5 "<provider" decompiled/AndroidManifest.xml
Provider Access Testing
adb shell content query --uri "content://<authority>/<path>"
adb shell content insert --uri "content://<authority>/<path>" \
--bind "column1:string:value1"
adb shell content update --uri "content://<authority>/<path>" \
--bind "column1:string:newvalue" \
--selection "column2=?" --selection-arg "value2"
adb shell content delete --uri "content://<authority>/<path>" \
--selection "column=?" --selection-arg "value"
SQL Injection Testing
adb shell content query --uri "content://<authority>/<path>" \
--selection "1=1 OR 1=1"
grep -r "projection" decompiled/smali/ | grep -v "projectionMap"
WebView Security Testing
WebView Configuration Analysis
grep -r "WebView" decompiled/smali/
grep -r "setJavaScriptEnabled" decompiled/smali/
grep -r "setAllowFileAccess" decompiled/smali/
grep -r "setAllowContentAccess" decompiled/smali/
JavaScript Bridge Testing
grep -r "@JavascriptInterface" decompiled/smali/
adb shell am start -a android.intent.action.VIEW \
-d "<scheme>://<host>/web?callback=javascript:alert(1)"
Pre-Installed App Analysis
System App Discovery
adb shell pm list packages -s
adb shell pm list packages -3
adb shell ls -la /system/app/
adb shell ls -la /system/priv-app/
Permission Analysis for System Apps
adb shell dumpsys package <system-package> | grep -A 100 "requested permissions"
grep -r "android.permission.*ROOT\|android.permission.*SYSTEM" decompiled/AndroidManifest.xml
Digital Signature Analysis
Certificate Extraction
unzip -p base.apk META-INF/CERT.RSA > cert.pem
keytool -printcert -file cert.pem
apksigner verify --print-certs base.apk
Signature Verification
apksigner verify base.apk
keytool -printcert -jarfile base.apk
Common Vulnerability Patterns
1. Exported Components Without Permission
<activity android:name=".SensitiveActivity" android:exported="true" />
<activity android:name=".SensitiveActivity"
android:exported="true"
android:permission="com.example.CUSTOM_PERMISSION" />
2. Weak Intent Filter Validation
if (uri.toString().contains("myapp://")) {
}
if (uri.getScheme().equals("myapp") &&
uri.getHost().equals("secure")) {
}
3. Insecure Content Provider
<provider android:name=".MyProvider"
android:exported="true"
android:readPermission="com.example.READ"
android:writePermission="" />
<provider android:name=".MyProvider"
android:exported="true"
android:readPermission="com.example.READ"
android:writePermission="com.example.WRITE" />
4. Sticky Broadcasts
sendStickyBroadcast(intent);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
Testing Workflow
Phase 1: Reconnaissance
- Pull APK from device
- Decompile with apktool
- Analyze AndroidManifest.xml
- List all exported components
- Document permissions
Phase 2: Component Testing
- Test each exported Activity with various intents
- Test each exported Service
- Test each exported Broadcast Receiver
- Test each Content Provider
Phase 3: Deep Link Testing
- Enumerate all custom schemes
- Test each scheme with various payloads
- Check for open redirects
- Test for auth bypass
- Test WebView injection
Phase 4: AIDL/Binder Testing
- List all running services
- PING each service to get interface
- Brute-force transaction codes
- Map methods via onTransact()
- Test for missing permission checks
Phase 5: Reporting
- Document all findings
- Provide PoC for each vulnerability
- Suggest remediation steps
- Prioritize by severity
Tools Reference
| Tool | Purpose | Command |
|---|
apktool | APK decompilation | apktool d app.apk -o out/ |
dex2jar | DEX to JAR conversion | dex2jar classes.dex |
jadx | DEX to Java decompilation | jadx -d out/ app.apk |
adb | Android Debug Bridge | adb shell |
am | Activity Manager | am start -a ACTION |
service | Service management | service list |
content | Content provider access | content query --uri |
Deep-C | Deep link automation | deep-C --apk app.apk |
binder-scanner | AIDL service scanning | python binder-scanner.py |
Security Checklist
References