Analyzing Android Malware with Apktool
Overview
Android malware distributed as APK files can be statically analyzed to extract permissions, activities, services, broadcast receivers, and suspicious API calls without executing the sample. This skill uses androguard for programmatic APK analysis, identifying dangerous permission combinations, obfuscated code patterns, dynamic code loading, reflection-based API calls, and network communication indicators.
When to Use
- When investigating security incidents that require analyzing android malware with apktool
- When building detection rules or threat hunting queries for this domain
- When SOC analysts need structured procedures for this analysis type
- When validating security monitoring coverage for related attack techniques
Detection Gaps & Validation
- Dynamic code loading hides the payload. apktool/jadx only show the shipped DEX; malware pulls a second-stage DEX/JAR via
DexClassLoader/loadDex or decrypts a blob in assets/, res/raw/, or lib/*.so. Grep smali for DexClassLoader, System.loadLibrary, and Cipher/Base64 near asset reads before concluding it is benign.
- Reflection + string obfuscation defeat keyword scans.
sendTextMessage/Runtime.exec are reached via Class.forName/getMethod/invoke with XOR/Base64 strings, so literals never appear. Decode with androguard or dex-oracle/simplify first.
- Packers leave a stub. Jiagu/Bangcle/ApkProtect ship a loader DEX and unpack at runtime; detect the packer signature, then dump the real DEX from a rooted emulator.
- Confirm a hit: re-decompile the runtime-dumped DEX (Frida
dexdump or pull from /data/data/<pkg>), validate dangerous permissions against actual API usage and exported <service>/<receiver> flags, and prove extracted C2 URLs are live via mitmproxy rather than dead/decoy strings.
- False positives: ad/analytics SDKs (AdMob, Firebase, Facebook) legitimately request broad permissions, reflection, and network. Confirm the suspect class sits in the app's own package, not a bundled third-party SDK, before flagging.
Prerequisites
- Python 3.9+ with
androguard
- apktool (for resource decompilation)
- jadx (for Java source recovery, optional)
- Isolated analysis environment (VM or sandbox)
- Sample APK files for analysis
Steps
- Parse APK with androguard to extract manifest metadata
- Enumerate requested permissions and flag dangerous combinations
- List activities, services, receivers, and providers from manifest
- Scan for suspicious API calls (reflection, crypto, SMS, telephony)
- Detect dynamic code loading patterns (DexClassLoader, Runtime.exec)
- Extract hardcoded URLs, IPs, and C2 indicators from strings
- Generate risk assessment report with MITRE ATT&CK mobile mappings
Expected Output
- JSON report with permission analysis, component listing, suspicious API calls, network indicators, and risk score
- Extracted strings and potential IOCs from the APK
1---2name: analyzing-android-malware-with-apktool3description: Perform static analysis of Android APK malware samples using apktool for decompilation, jadx for Java source recovery, and androguard for permission analysis, manifest inspection, and suspicious API call detection.4license: Apache-2.05---67# Analyzing Android Malware with Apktool89## Overview1011Android malware distributed as APK files can be statically analyzed to extract permissions, activities, services, broadcast receivers, and suspicious API calls without executing the sample. This skill uses androguard for programmatic APK analysis, identifying dangerous permission combinations, obfuscated code patterns, dynamic code loading, reflection-based API calls, and network communication indicators.121314## When to Use1516- When investigating security incidents that require analyzing android malware with apktool17- When building detection rules or threat hunting queries for this domain18- When SOC analysts need structured procedures for this analysis type19- When validating security monitoring coverage for related attack techniques2021## Detection Gaps & Validation2223- **Dynamic code loading hides the payload.** apktool/jadx only show the shipped DEX; malware pulls a second-stage DEX/JAR via `DexClassLoader`/`loadDex` or decrypts a blob in `assets/`, `res/raw/`, or `lib/*.so`. Grep smali for `DexClassLoader`, `System.loadLibrary`, and `Cipher`/Base64 near asset reads before concluding it is benign.24- **Reflection + string obfuscation defeat keyword scans.** `sendTextMessage`/`Runtime.exec` are reached via `Class.forName`/`getMethod`/`invoke` with XOR/Base64 strings, so literals never appear. Decode with androguard or dex-oracle/simplify first.25- **Packers leave a stub.** Jiagu/Bangcle/ApkProtect ship a loader DEX and unpack at runtime; detect the packer signature, then dump the real DEX from a rooted emulator.26- **Confirm a hit:** re-decompile the runtime-dumped DEX (Frida `dexdump` or pull from `/data/data/<pkg>`), validate dangerous permissions against actual API usage and exported `<service>`/`<receiver>` flags, and prove extracted C2 URLs are live via mitmproxy rather than dead/decoy strings.27- **False positives:** ad/analytics SDKs (AdMob, Firebase, Facebook) legitimately request broad permissions, reflection, and network. Confirm the suspect class sits in the app's own package, not a bundled third-party SDK, before flagging.2829## Prerequisites3031- Python 3.9+ with `androguard`32- apktool (for resource decompilation)33- jadx (for Java source recovery, optional)34- Isolated analysis environment (VM or sandbox)35- Sample APK files for analysis3637## Steps38391. Parse APK with androguard to extract manifest metadata402. Enumerate requested permissions and flag dangerous combinations413. List activities, services, receivers, and providers from manifest424. Scan for suspicious API calls (reflection, crypto, SMS, telephony)435. Detect dynamic code loading patterns (DexClassLoader, Runtime.exec)446. Extract hardcoded URLs, IPs, and C2 indicators from strings457. Generate risk assessment report with MITRE ATT&CK mobile mappings4647## Expected Output4849- JSON report with permission analysis, component listing, suspicious API calls, network indicators, and risk score50- Extracted strings and potential IOCs from the APK