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 using4 apktool for decompilation, jadx for Java source recovery, and androguard for permission5 analysis, manifest inspection, and suspicious API call detection. Use when performing6 static analysis of android apk malware samples using apktool.7domain: cybersecurity8subdomain: malware-analysis9tags:10- Android11- APK12- apktool13- jadx14- androguard15- mobile-malware16- static-analysis17- reverse-engineering18version: '1.0'19author: oyi7720license: Apache-2.021nist_csf:22- DE.AE-0223- RS.AN-0324- ID.RA-0125- DE.CM-0126category: cybersecurity27metadata:28 source: https://skillmd.com/skills/oyi77/analyzing-android-malware-with-apktool29---303132# Analyzing Android Malware with Apktool3334## Overview3536Android 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.373839## When to Use40**Trigger phrases:**41- "analyzing android malware with apktool"42- "Perform static analysis of Android APK malware samples using apktool for decompi"434445- When investigating security incidents that require analyzing android malware with apktool46- When building detection rules or threat hunting queries for this domain47- When SOC analysts need structured procedures for this analysis type48- When validating security monitoring coverage for related attack techniques4950## Prerequisites5152- Python 3.9+ with `androguard`53- apktool (for resource decompilation)54- jadx (for Java source recovery, optional)55- Isolated analysis environment (VM or sandbox)56- Sample APK files for analysis5758## Steps5960```python61# Example: IOC detection62import re6364IOC_PATTERNS = {65 "ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",66 "domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",67 "hash_md5": r"\b[a-f0-9]{32}\b",68 "hash_sha256": r"\b[a-f0-9]{64}\b",69}7071def extract_iocs(text: str) -> dict:72 return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}73```74751. Parse APK with androguard to extract manifest metadata762. Enumerate requested permissions and flag dangerous combinations773. List activities, services, receivers, and providers from manifest784. Scan for suspicious API calls (reflection, crypto, SMS, telephony)795. Detect dynamic code loading patterns (DexClassLoader, Runtime.exec)806. Extract hardcoded URLs, IPs, and C2 indicators from strings817. Generate risk assessment report with MITRE ATT&CK mobile mappings8283## Expected Output8485- JSON report with permission analysis, component listing, suspicious API calls, network indicators, and risk score86- Extracted strings and potential IOCs from the APK87## When NOT to Use8889- You need to perform the attack, not analyze it (use performing-* skills)90- Task is about detection, not analysis (use detecting-* skills)91- You need to implement controls (use implementing-* skills)92- Task is about threat hunting, not post-incident analysis (use hunting-* skills)93- You don't have access to the artifacts/logs to analyze94- Task requires real-time monitoring (use SOC tools)959697## Red Flags9899- Performing actions without explicit written authorization from the asset owner100- Testing against production systems without a defined scope and rules of engagement101- Analyzing malware on a machine connected to the production network102- Failing to isolate the analysis environment from the internet103- Executing samples without proper containment (VM, sandbox)104105## Process1061071. **Reconnaissance** — Gather target information, identify attack surface, enumerate services1081. **Analysis/Exploitation** — Execute the technique, analyze results, document findings1091. **Reporting** — Document IOCs, write findings, provide remediation recommendations110111## Verification112113- All steps executed successfully against a test environment before production use114- Output documented with screenshots or logs demonstrating expected behavior115- Sample hash recorded and verified (MD5, SHA-1, SHA-256)116- Analysis environment confirmed isolated from production network117- Indicators of compromise (IOCs) extracted and documented118119## Anti-Rationalization Table120121| Rationalization | Reality |122|---|---|123| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |124| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |125| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |