Android Reverse Engineering
Overview
This skill provides a structured workflow for decompiling, analyzing, and dynamically instrumenting Android APK files. It covers static analysis with jadx/apktool, dynamic analysis with Frida, and complete security audit workflows. Use it for vulnerability research, malware analysis, CTF challenges, or understanding closed-source apps.
When to Use
- Analyzing a suspicious APK for malware indicators or data exfiltration
- Security auditing a third-party Android application before enterprise deployment
- CTF challenges involving Android APKs
- Reverse engineering an app to understand its API contract or obfuscation scheme
- Extracting hardcoded secrets, API keys, or certificate pins
Step-by-Step Workflow
Phase 1: Reconnaissance & Static Extraction
Obtain and verify the APK
# Pull from device
adb shell pm list packages | grep <app-name>
adb shell pm path com.target.app
adb pull /data/app/com.target.app-1/base.apk ./target.apk
# Verify APK integrity
apksigner verify --verbose target.apk
file target.apk # Should be Zip archive
Decompile with apktool (resources + smali)
apktool d target.apk -o target_decompiled/
# Flags: -r (no resource decode), -s (no smali), -f (force overwrite)
ls target_decompiled/
# AndroidManifest.xml, smali/, res/, assets/, lib/
Decompile to Java with jadx
jadx target.apk -d target_java/ --threads-count 4
jadx-gui target.apk # GUI for interactive analysis
Inspect the manifest first
cat target_decompiled/AndroidManifest.xml | grep -E "(permission|activity|service|receiver|provider)"
# Look for: exported components, dangerous permissions, deeplinks
Phase 2: Static Analysis
Search for secrets and hardcoded values
grep -r "api_key\|apikey\|secret\|password\|token\|private_key" target_java/ -i
grep -r "http://\|https://" target_java/ | grep -v "schemas\|android\|google"
grep -r "AES\|RSA\|MD5\|SHA\|encrypt\|decrypt" target_java/ -i
Analyze native libraries
ls target_decompiled/lib/arm64-v8a/
strings target_decompiled/lib/arm64-v8a/libapp.so | grep -E "http|key|pass|token"
nm -D target_decompiled/lib/arm64-v8a/libapp.so # Symbol table
Check certificate pinning
grep -r "CertificatePinner\|X509TrustManager\|checkServerTrusted\|pinnedCertificate" target_java/ -i
Phase 3: Dynamic Analysis with Frida
Set up Frida server on device
adb root
adb push frida-server /data/local/tmp/
adb shell chmod 755 /data/local/tmp/frida-server
adb shell /data/local/tmp/frida-server &
frida-ps -U # List running processes
Hook methods at runtime
// hook_crypto.js - Intercept AES encryption
Java.perform(function() {
var Cipher = Java.use("javax.crypto.Cipher");
Cipher.doFinal.overload("[B").implementation = function(data) {
console.log("doFinal called with: " + bytesToHex(data));
var result = this.doFinal(data);
console.log("Result: " + bytesToHex(result));
return result;
};
});
frida -U -l hook_crypto.js -f com.target.app --no-pause
Bypass certificate pinning
// certpin_bypass.js
Java.perform(function() {
var TrustManager = Java.registerClass({
name: "com.custom.TrustManager",
implements: [Java.use("javax.net.ssl.X509TrustManager")],
methods: {
checkClientTrusted: function(chain, authType) {},
checkServerTrusted: function(chain, authType) {},
getAcceptedIssuers: function() { return []; }
}
});
});
Phase 4: Traffic Interception
- Route traffic through Burp Suite
# On host
adb shell settings put global http_proxy <host-ip>:8080
# Install Burp CA on device (Android < 7)
adb push burp_ca.cer /sdcard/
adb shell am start -n com.android.certinstaller/.CertInstallerMain \
--es name "Burp CA" --es certPath /sdcard/burp_ca.cer
Key Commands Reference
# jadx batch decompile + search
jadx target.apk -d out/ && grep -r "BuildConfig\|API_URL" out/
# Smali to Java mental model: v0-vN are registers, p0=this
# Find all exported Activities
aapt dump xmltree target.apk AndroidManifest.xml | grep -A2 "exported"
# Frida trace all methods in a class
frida-trace -U -j 'com.target.app.NetworkClient!*' com.target.app
# objection for automated analysis
objection -g com.target.app explore
> android sslpinning disable
> android hooking list classes
# Pull app databases
adb shell run-as com.target.app cp /data/data/com.target.app/databases/app.db /sdcard/
adb pull /sdcard/app.db
sqlite3 app.db .tables
Common Patterns
Pattern 1: API Key Extraction
# Step 1: Search compiled strings
jadx target.apk -d out/ 2>/dev/null
grep -r "X-Api-Key\|Authorization\|Bearer" out/ --include="*.java"
# Step 2: Check BuildConfig
find out/ -name "BuildConfig.java" -exec cat {} \;
# Step 3: Search native strings
find target_decompiled/lib -name "*.so" -exec strings {} \; | grep -i "key\|token\|secret"
Pattern 2: Reverse-Engineer Custom Obfuscation
# Map ProGuard obfuscated names using mapping file
# Find mapping.txt in build artifacts or crash reports
jadx --deobf target.apk -d out_deobf/ # auto deobfuscation
# Manual: look for single-letter class names — likely obfuscated
Pattern 3: Modify & Repack APK
apktool d target.apk -o modified/
# Edit smali files to patch logic
# e.g., change if-eqz to if-nez to flip a condition
vim modified/smali/com/target/app/LicenseCheck.smali
apktool b modified/ -o modified_unsigned.apk
# Sign with debug key
keytool -genkey -v -keystore debug.keystore -alias debug -keyalg RSA -keysize 2048 -validity 10000
jarsigner -verbose -keystore debug.keystore modified_unsigned.apk debug
adb install modified_unsigned.apk
Pitfalls to Avoid
Root detection bypasses needed: Many apps detect rooted devices or Frida presence. Use Magisk with Zygisk + LSPosed + XPrivacyLua to hide root. For Frida detection, rename the binary: mv frida-server frida-server32 and use --no-pause with spawn mode.
Multi-dex apps: Large apps use multiple dex files. jadx handles this automatically, but apktool may require --only-main-classes. Check classes2.dex, classes3.dex — auth logic often lives in secondary dex files.
Legal and ethical boundaries: Always have written authorization before analyzing a production app. Reverse engineering for security research is legal in most jurisdictions under responsible disclosure frameworks, but modifying and redistributing is not. Maintain a clear audit trail.
Related Skills
security-pen-testing — Full application penetration testing
c-security-review — Native code (C/C++) security review
semgrep-rule-creator — Static analysis rule creation
api-security-hardening — Securing the server-side APIs discovered
GitNexus Index
{
"skill": "android-reverse-engineering",
"category": "security",
"triggers": ["apk", "android reverse", "jadx", "frida", "decompile android", "apktool", "smali", "malware android"],
"outputs": ["decompiled source", "hooked runtime", "extracted secrets", "traffic analysis"],
"complexity": "high",
"tools": ["jadx", "apktool", "frida", "objection", "adb", "burpsuite"]
}
1---2name: android-reverse-engineering3description: Reverse engineer Android APKs using jadx, apktool, frida, and static/dynamic analysis workflows to understand app internals, detect malware, or perform security research.4---56# Android Reverse Engineering78## Overview910This skill provides a structured workflow for decompiling, analyzing, and dynamically instrumenting Android APK files. It covers static analysis with jadx/apktool, dynamic analysis with Frida, and complete security audit workflows. Use it for vulnerability research, malware analysis, CTF challenges, or understanding closed-source apps.1112## When to Use1314- Analyzing a suspicious APK for malware indicators or data exfiltration15- Security auditing a third-party Android application before enterprise deployment16- CTF challenges involving Android APKs17- Reverse engineering an app to understand its API contract or obfuscation scheme18- Extracting hardcoded secrets, API keys, or certificate pins1920## Step-by-Step Workflow2122### Phase 1: Reconnaissance & Static Extraction23241. **Obtain and verify the APK**25 ```bash26 # Pull from device27 adb shell pm list packages | grep <app-name>28 adb shell pm path com.target.app29 adb pull /data/app/com.target.app-1/base.apk ./target.apk3031 # Verify APK integrity32 apksigner verify --verbose target.apk33 file target.apk # Should be Zip archive34 ```35362. **Decompile with apktool (resources + smali)**37 ```bash38 apktool d target.apk -o target_decompiled/39 # Flags: -r (no resource decode), -s (no smali), -f (force overwrite)40 ls target_decompiled/41 # AndroidManifest.xml, smali/, res/, assets/, lib/42 ```43443. **Decompile to Java with jadx**45 ```bash46 jadx target.apk -d target_java/ --threads-count 447 jadx-gui target.apk # GUI for interactive analysis48 ```49504. **Inspect the manifest first**51 ```bash52 cat target_decompiled/AndroidManifest.xml | grep -E "(permission|activity|service|receiver|provider)"53 # Look for: exported components, dangerous permissions, deeplinks54 ```5556### Phase 2: Static Analysis57585. **Search for secrets and hardcoded values**59 ```bash60 grep -r "api_key\|apikey\|secret\|password\|token\|private_key" target_java/ -i61 grep -r "http://\|https://" target_java/ | grep -v "schemas\|android\|google"62 grep -r "AES\|RSA\|MD5\|SHA\|encrypt\|decrypt" target_java/ -i63 ```64656. **Analyze native libraries**66 ```bash67 ls target_decompiled/lib/arm64-v8a/68 strings target_decompiled/lib/arm64-v8a/libapp.so | grep -E "http|key|pass|token"69 nm -D target_decompiled/lib/arm64-v8a/libapp.so # Symbol table70 ```71727. **Check certificate pinning**73 ```bash74 grep -r "CertificatePinner\|X509TrustManager\|checkServerTrusted\|pinnedCertificate" target_java/ -i75 ```7677### Phase 3: Dynamic Analysis with Frida78798. **Set up Frida server on device**80 ```bash81 adb root82 adb push frida-server /data/local/tmp/83 adb shell chmod 755 /data/local/tmp/frida-server84 adb shell /data/local/tmp/frida-server &85 frida-ps -U # List running processes86 ```87889. **Hook methods at runtime**89 ```javascript90 // hook_crypto.js - Intercept AES encryption91 Java.perform(function() {92 var Cipher = Java.use("javax.crypto.Cipher");93 Cipher.doFinal.overload("[B").implementation = function(data) {94 console.log("doFinal called with: " + bytesToHex(data));95 var result = this.doFinal(data);96 console.log("Result: " + bytesToHex(result));97 return result;98 };99 });100 ```101 ```bash102 frida -U -l hook_crypto.js -f com.target.app --no-pause103 ```10410510. **Bypass certificate pinning**106 ```javascript107 // certpin_bypass.js108 Java.perform(function() {109 var TrustManager = Java.registerClass({110 name: "com.custom.TrustManager",111 implements: [Java.use("javax.net.ssl.X509TrustManager")],112 methods: {113 checkClientTrusted: function(chain, authType) {},114 checkServerTrusted: function(chain, authType) {},115 getAcceptedIssuers: function() { return []; }116 }117 });118 });119 ```120121### Phase 4: Traffic Interception12212311. **Route traffic through Burp Suite**124 ```bash125 # On host126 adb shell settings put global http_proxy <host-ip>:8080127128 # Install Burp CA on device (Android < 7)129 adb push burp_ca.cer /sdcard/130 adb shell am start -n com.android.certinstaller/.CertInstallerMain \131 --es name "Burp CA" --es certPath /sdcard/burp_ca.cer132 ```133134## Key Commands Reference135136```bash137# jadx batch decompile + search138jadx target.apk -d out/ && grep -r "BuildConfig\|API_URL" out/139140# Smali to Java mental model: v0-vN are registers, p0=this141# Find all exported Activities142aapt dump xmltree target.apk AndroidManifest.xml | grep -A2 "exported"143144# Frida trace all methods in a class145frida-trace -U -j 'com.target.app.NetworkClient!*' com.target.app146147# objection for automated analysis148objection -g com.target.app explore149> android sslpinning disable150> android hooking list classes151152# Pull app databases153adb shell run-as com.target.app cp /data/data/com.target.app/databases/app.db /sdcard/154adb pull /sdcard/app.db155sqlite3 app.db .tables156```157158## Common Patterns159160### Pattern 1: API Key Extraction161```bash162# Step 1: Search compiled strings163jadx target.apk -d out/ 2>/dev/null164grep -r "X-Api-Key\|Authorization\|Bearer" out/ --include="*.java"165166# Step 2: Check BuildConfig167find out/ -name "BuildConfig.java" -exec cat {} \;168169# Step 3: Search native strings170find target_decompiled/lib -name "*.so" -exec strings {} \; | grep -i "key\|token\|secret"171```172173### Pattern 2: Reverse-Engineer Custom Obfuscation174```bash175# Map ProGuard obfuscated names using mapping file176# Find mapping.txt in build artifacts or crash reports177jadx --deobf target.apk -d out_deobf/ # auto deobfuscation178# Manual: look for single-letter class names — likely obfuscated179```180181### Pattern 3: Modify & Repack APK182```bash183apktool d target.apk -o modified/184# Edit smali files to patch logic185# e.g., change if-eqz to if-nez to flip a condition186vim modified/smali/com/target/app/LicenseCheck.smali187apktool b modified/ -o modified_unsigned.apk188# Sign with debug key189keytool -genkey -v -keystore debug.keystore -alias debug -keyalg RSA -keysize 2048 -validity 10000190jarsigner -verbose -keystore debug.keystore modified_unsigned.apk debug191adb install modified_unsigned.apk192```193194## Pitfalls to Avoid1951961. **Root detection bypasses needed**: Many apps detect rooted devices or Frida presence. Use Magisk with Zygisk + LSPosed + XPrivacyLua to hide root. For Frida detection, rename the binary: `mv frida-server frida-server32` and use `--no-pause` with spawn mode.1971982. **Multi-dex apps**: Large apps use multiple dex files. jadx handles this automatically, but apktool may require `--only-main-classes`. Check `classes2.dex`, `classes3.dex` — auth logic often lives in secondary dex files.1992003. **Legal and ethical boundaries**: Always have written authorization before analyzing a production app. Reverse engineering for security research is legal in most jurisdictions under responsible disclosure frameworks, but modifying and redistributing is not. Maintain a clear audit trail.201202## Related Skills203204- `security-pen-testing` — Full application penetration testing205- `c-security-review` — Native code (C/C++) security review206- `semgrep-rule-creator` — Static analysis rule creation207- `api-security-hardening` — Securing the server-side APIs discovered208209## GitNexus Index210211```json212{213 "skill": "android-reverse-engineering",214 "category": "security",215 "triggers": ["apk", "android reverse", "jadx", "frida", "decompile android", "apktool", "smali", "malware android"],216 "outputs": ["decompiled source", "hooked runtime", "extracted secrets", "traffic analysis"],217 "complexity": "high",218 "tools": ["jadx", "apktool", "frida", "objection", "adb", "burpsuite"]219}220```