Identifies broken link hijacking vulnerabilities by crawling web apps for references to expired domains, dangling CNAMEs, dead cloud resources (AWS S3, GitHub Pages), and subdomain takeovers. Useful for security audits and bug bounties.
npx claudepluginhub killvxk/cybersecurity-skills-zhThis skill uses the workspace's default tool permissions.
- 审计 Web 应用程序中对过期或未申领外部资源的引用时
Crawls web apps to find broken link hijacking vulnerabilities: expired domains, dangling CNAMEs, dead S3/Azure/GitHub resources claimable by attackers. For security audits and bug bounties.
Discovers and exploits broken link hijacking vulnerabilities by identifying expired domains, decommissioned cloud resources, and dead external services. For web app audits, supply chain assessments, and bug bounties.
Guides SSRF penetration testing in web apps: identifies URL input risks, exploits internal/cloud metadata access, blind SSRF via OOB, bypasses like IP tricks/DNS rebinding, checklists, and impact evaluation.
Share bugs, ideas, or general feedback.
# 使用 broken-link-checker 发现失效链接
npx broken-link-checker http://target.com --recursive --ordered \
--exclude-internal --filter-level 3 -o broken_links.txt
# 从页面源码提取所有外部链接
curl -s http://target.com | grep -oP 'https?://[^"'"'"'\s>]+' | sort -u > all_links.txt
# 提取 JavaScript 源文件
curl -s http://target.com | grep -oP 'src="[^"]*"' | grep -v target.com > external_scripts.txt
# 提取 CSS 引用
curl -s http://target.com | grep -oP 'href="[^"]*\.css"' | grep -v target.com > external_css.txt
# 使用 Wayback Machine 获取历史外部引用
curl -s "https://web.archive.org/web/timemap/link/http://target.com" | \
grep -oP 'https?://[^>]+' | sort -u > historical_links.txt
# 使用 Burp Suite 爬取
# 配置 Spider 范围包含 target.com
# 查看 Site Map > 按"External"过滤以列出所有外部引用
# 检查外部域名是否已注册
for domain in $(cat external_domains.txt); do
whois $domain 2>/dev/null | grep -qi "no match\|not found\|available" && \
echo "[可申领] $domain"
done
# 检查外部链接的 HTTP 状态
while read url; do
status=$(curl -o /dev/null -s -w "%{http_code}" "$url" --max-time 5)
if [ "$status" = "000" ] || [ "$status" = "404" ]; then
echo "[失效] $url (状态: $status)"
fi
done < all_links.txt
# 检查悬空 CNAME 记录
for sub in $(cat subdomains.txt); do
cname=$(dig +short CNAME $sub)
if [ -n "$cname" ]; then
resolved=$(dig +short $cname)
if [ -z "$resolved" ]; then
echo "[悬空] $sub -> $cname (未解析)"
fi
fi
done
# 检查云资源可用性
# AWS S3 存储桶
aws s3 ls s3://target-assets 2>&1 | grep -q "NoSuchBucket" && echo "[可申领] S3: target-assets"
# 检查 GitHub Pages 接管
# 如果 CNAME 指向 <user>.github.io 且返回 404
curl -s https://subdomain.target.com | grep -q "There isn't a GitHub Pages site here"
# 检查 AWS S3 接管
curl -s http://subdomain.target.com | grep -q "NoSuchBucket"
# 检查 Azure Blob Storage
curl -s http://subdomain.target.com | grep -q "The specified container does not exist"
# 检查 Heroku
curl -s http://subdomain.target.com | grep -q "No such app"
# 检查 Shopify
curl -s http://subdomain.target.com | grep -q "Sorry, this shop is currently unavailable"
# 使用 subjack 进行自动化接管检测
subjack -w subdomains.txt -c fingerprints.json -t 100 -o takeover_candidates.txt
# 使用 nuclei 接管模板
subfinder -d target.com -silent | nuclei -t http/takeovers/ -o takeovers.txt
# 检查外部 JavaScript 域名是否可注册
curl -s http://target.com | grep -oP 'src="https?://([^/"]+)' | \
cut -d'/' -f3 | sort -u | while read domain; do
whois "$domain" 2>/dev/null | grep -qi "no match\|available" && \
echo "[可劫持脚本] $domain 被 target.com 加载"
done
# 检查 npm/CDN 包引用
curl -s http://target.com | grep -oP 'unpkg\.com/[^@/]+' | sort -u
curl -s http://target.com | grep -oP 'cdn\.jsdelivr\.net/npm/[^@/]+' | sort -u
# 验证引用的包是否仍然存在
# 检查 npm 注册表中已废弃或已删除的包
# 对于过期域名:注册该域名
# 对于 S3 存储桶:在同一区域创建同名存储桶
aws s3 mb s3://target-expired-bucket --region us-east-1
# 对于 GitHub Pages:创建匹配名称的仓库
# 创建带有概念验证内容的 <org>.github.io 仓库
# 对于未申领的社交媒体:申领该账号
# 用良性概念验证内容记录接管过程
# 提供概念验证内容
echo "<html><body><h1>断链劫持 PoC - [您的名字]</h1></body></html>" > index.html
# 上传到已申领的资源
# 根据资源类型确定影响:
# - 外部 JavaScript:对所有加载该脚本的页面实施完整 XSS
# - 外部 CSS:UI 篡改,通过 CSS 注入进行数据外泄
# - 外部图片/资源:钓鱼、追踪
# - CNAME 子域名:Cookie 窃取、钓鱼、OAuth 绕过
# 检查被劫持资源是否为父域名提供 Cookie
# 检查被劫持子域名是否在 OAuth 重定向白名单中
# 验证被劫持域名是否接收敏感 Referer 头
| 概念 | 定义 |
|---|---|
| 断链劫持(Broken Link Hijacking) | 申领目标网站引用的外部资源的控制权 |
| 悬空 CNAME(Dangling CNAME) | 指向未申领或已停用服务的 DNS CNAME 记录 |
| 子域名接管(Subdomain Takeover) | 通过供应 CNAME 指向的服务来申领子域名 |
| 外部脚本劫持(External Script Hijacking) | 注册目标加载的 JavaScript 所在的过期域名 |
| 供应链攻击(Supply Chain Attack) | 通过入侵外部依赖项来注入恶意内容 |
| 失效链接(Dead Link) | 返回 404 或 DNS 解析失败的 URL 引用 |
| 资源指纹识别(Resource Fingerprinting) | 通过错误消息和响应头识别特定云服务 |
| 工具 | 用途 |
|---|---|
| broken-link-checker | 通过 Web 爬取自动发现断链 |
| subjack | 子域名接管检测工具 |
| nuclei | 基于模板的接管检测扫描器 |
| can-i-take-over-xyz | 容易受到接管攻击的服务的社区数据库 |
| BadDNS | 用于检测域名/子域名接管的 DNS 审计工具 |
| Wayback Machine | 用于发现过去外部引用的历史 URL 分析 |
## 断链劫持报告
- **目标**: http://target.com
- **外部链接总数**: 145
- **失效链接**: 12
- **可劫持资源**: 3
### 发现
| # | 资源 | 类型 | 状态 | 影响 |
|---|----------|------|--------|--------|
| 1 | analytics.expired-domain.com | JavaScript | 域名可注册 | 完整 XSS |
| 2 | assets.target.com -> S3 存储桶 | 静态资源 | 存储桶已删除 | 内容注入 |
| 3 | blog.target.com -> GitHub Pages | 子域名 | 无 GitHub 仓库 | 子域名接管 |
### 修复建议
- 删除对已停用外部资源的引用
- 删除未使用子域名的悬空 CNAME 记录
- 为外部脚本实施子资源完整性(SRI)
- 定期审计外部依赖项的可用性
- 使用 Content Security Policy 限制允许的脚本来源