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
Trigger phrases:
"analyzing android malware with apktool"
"Perform static analysis of Android APK malware samples using apktool for decompi"
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
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
# Example: IOC detection
import re
IOC_PATTERNS = {
"ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",
"domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",
"hash_md5": r"\b[a-f0-9]{32}\b",
"hash_sha256": r"\b[a-f0-9]{64}\b",
}
def extract_iocs(text: str) -> dict:
return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}
- 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
When NOT to Use
- You need to perform the attack, not analyze it (use performing-* skills)
- Task is about detection, not analysis (use detecting-* skills)
- You need to implement controls (use implementing-* skills)
- Task is about threat hunting, not post-incident analysis (use hunting-* skills)
- You don't have access to the artifacts/logs to analyze
- Task requires real-time monitoring (use SOC tools)
Red Flags
- Performing actions without explicit written authorization from the asset owner
- Testing against production systems without a defined scope and rules of engagement
- Analyzing malware on a machine connected to the production network
- Failing to isolate the analysis environment from the internet
- Executing samples without proper containment (VM, sandbox)
Process
- Reconnaissance — Gather target information, identify attack surface, enumerate services
- Analysis/Exploitation — Execute the technique, analyze results, document findings
- Reporting — Document IOCs, write findings, provide remediation recommendations
Verification
- All steps executed successfully against a test environment before production use
- Output documented with screenshots or logs demonstrating expected behavior
- Sample hash recorded and verified (MD5, SHA-1, SHA-256)
- Analysis environment confirmed isolated from production network
- Indicators of compromise (IOCs) extracted and documented
Anti-Rationalization Table
| Rationalization |
Reality |
| "We are too small to be targeted" |
Automated attacks target everyone. Size does not matter. |
| "Security slows us down" |
A breach slows you down 100x more. Build security in from the start. |
| "We will fix it after launch" |
Vulnerabilities in production are exploited within hours. Fix before deploy. |
1---2name: analyzing-android-malware-with-apktool3description: Use when 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. Use when performing static analysis of android apk malware samples using apktool.4license: Apache-2.05---678# Analyzing Android Malware with Apktool910## Overview1112Android 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.131415## When to Use16**Trigger phrases:**17- "analyzing android malware with apktool"18- "Perform static analysis of Android APK malware samples using apktool for decompi"192021- When investigating security incidents that require analyzing android malware with apktool22- When building detection rules or threat hunting queries for this domain23- When SOC analysts need structured procedures for this analysis type24- When validating security monitoring coverage for related attack techniques2526## Prerequisites2728- Python 3.9+ with `androguard`29- apktool (for resource decompilation)30- jadx (for Java source recovery, optional)31- Isolated analysis environment (VM or sandbox)32- Sample APK files for analysis3334## Steps3536```python37# Example: IOC detection38import re3940IOC_PATTERNS = {41 "ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",42 "domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",43 "hash_md5": r"\b[a-f0-9]{32}\b",44 "hash_sha256": r"\b[a-f0-9]{64}\b",45}4647def extract_iocs(text: str) -> dict:48 return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}49```50511. Parse APK with androguard to extract manifest metadata522. Enumerate requested permissions and flag dangerous combinations533. List activities, services, receivers, and providers from manifest544. Scan for suspicious API calls (reflection, crypto, SMS, telephony)555. Detect dynamic code loading patterns (DexClassLoader, Runtime.exec)566. Extract hardcoded URLs, IPs, and C2 indicators from strings577. Generate risk assessment report with MITRE ATT&CK mobile mappings5859## Expected Output6061- JSON report with permission analysis, component listing, suspicious API calls, network indicators, and risk score62- Extracted strings and potential IOCs from the APK63## When NOT to Use6465- You need to perform the attack, not analyze it (use performing-* skills)66- Task is about detection, not analysis (use detecting-* skills)67- You need to implement controls (use implementing-* skills)68- Task is about threat hunting, not post-incident analysis (use hunting-* skills)69- You don't have access to the artifacts/logs to analyze70- Task requires real-time monitoring (use SOC tools)717273## Red Flags7475- Performing actions without explicit written authorization from the asset owner76- Testing against production systems without a defined scope and rules of engagement77- Analyzing malware on a machine connected to the production network78- Failing to isolate the analysis environment from the internet79- Executing samples without proper containment (VM, sandbox)8081## Process82831. **Reconnaissance** — Gather target information, identify attack surface, enumerate services841. **Analysis/Exploitation** — Execute the technique, analyze results, document findings851. **Reporting** — Document IOCs, write findings, provide remediation recommendations8687## Verification8889- All steps executed successfully against a test environment before production use90- Output documented with screenshots or logs demonstrating expected behavior91- Sample hash recorded and verified (MD5, SHA-1, SHA-256)92- Analysis environment confirmed isolated from production network93- Indicators of compromise (IOCs) extracted and documented9495## Anti-Rationalization Table9697| Rationalization | Reality |98|---|---|99| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |100| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |101| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |