mcpField
O
origin-ip-discovery

origin-ip-discovery

github.com/uphiago安全1.3k42 次安装8 周前更新
代码仓库

关于 origin-ip-discovery

origin-ip-discovery 是用于查找 CDN 或 WAF 后源站 IP 的安全测试指南,面向需要验证源站暴露情况的研究者。它结合图标哈希、历史 DNS、证书和分析 ID 等线索,并提供验证步骤。

主要功能

  1. 01图标哈希指纹查询
  2. 02历史 DNS 记录检查
  3. 03SSL 证书名称匹配
  4. 04Google Analytics ID 交叉检索
  5. 05源站 IP 与内容验证

适用场景

  1. 01排查 Cloudflare 等 CDN 后的源站地址
  2. 02利用历史 DNS 和证书线索寻找 IP
  3. 03通过 Host 标头及图标验证候选源站

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/uphiago/recon-skills --skill origin-ip-discovery

安装后在 Claude Code 中输入/origin-ip-discovery确认已加载。

详细介绍

源站 IP 发现

发现 CDN/WAF 防护后面的真实服务器 IP(Cloudflare、Akamai、Fastly)。找到源站 IP 后,原始服务器将暴露在外,不受防火墙规则、速率限制或应用层过滤保护。相关技术包括:在 Shodan 上通过 favicon 哈希进行指纹识别、查询被动数据源中的历史 DNS 记录、匹配 SSL 证书 SAN 字段,以及交叉比对 Google Analytics ID。

使用场景

  • 目标位于 Cloudflare/Akamai 后面,所有请求均返回 403 或 CAPTCHA 挑战。
  • 你需要直接访问源站以绕过 WAF 规则。
  • 子域名枚举发现了不在 CDN IP 上的内部/暂存主机。
  • 目标的所有基础设施都使用同一个 favicon。
  • 不同 IP 上的 SSL 证书具有相同的组织名称。

前置条件

  • 带有 curl、python3 和 shodan CLI 的 terminal。
  • Shodan API 密钥:shodan init <KEY>。
  • 目标 favicon 文件或 URL。

快速检测

# Check Cloudflare presence
curl --max-time 30 --connect-timeout 10 -sI "https://target.com" | grep -i "cf-ray\|server: cloudflare"

# If Cloudflare detected, check for common origin leaks
curl --max-time 30 --connect-timeout 10 -sk "https://target.com/cdn-cgi/trace" | grep -E "ip=|colo="

操作步骤

阶段 1 — Favicon 哈希指纹识别
# Get favicon hash
FAVICON_URL="https://target.com/favicon.ico"
curl --max-time 30 --connect-timeout 10 -sk "$FAVICON_URL" -o favicon_target.ico

# Calculate hash
python3 -c "
import hashlib, base64
with open('favicon_target.ico', 'rb') as f:
    hash_bytes = base64.b64encode(hashlib.md5(f.read()).digest())
    print(f'favicon hash: {hash_bytes.decode()}')
"

# Search Shodan for IPs serving this favicon
HASH=$(python3 -c "
import hashlib, base64
with open('favicon_target.ico','rb') as f:
    print(base64.b64encode(hashlib.md5(f.read()).digest()).decode())
")
shodan search "http.favicon.hash:$HASH" --fields ip_str,port,org,hostnames

# Automatedtools
python3 favUp.py -ff favicon_target.ico --shodan-cli
python3 favUp.py --web target.com -sc
阶段 2 — 历史 DNS 记录
# SecurityTrails — DNS history
curl --max-time 30 --connect-timeout 10 -s "https://securitytrails.com/domain/target.com/history/a" \
  -H "APIKEY: $SECURITYTRAILS_KEY" \
  | jq '.records[].values[].ip' | sort -u

# AlienVault OTX — passive DNS
curl --max-time 30 --connect-timeout 10 -s "https://otx.alienvault.com/api/v1/indicators/domain/target.com/passive_dns" \
  | jq '.passive_dns[].address' | sort -u

# Automatedtools
echo "target.com" | originiphunter
cat domains.txt | originiphunter
阶段 3 — SSL 证书搜索
# crt.sh — find all certs for the domain, extract unique IPs from SAN fields
curl --max-time 30 --connect-timeout 10 -s "https://crt.sh/?q=%25.target.com&output=json" \
  | jq -r '.[].name_value' | tr ',' '\n' | sort -u > cert_domains.txt

# Censys — search by parsed names
# Web: https://search.censys.io — query: parsed.names: target.com

# Shodan — search by SSL subject CN
shodan search "ssl.cert.subject.cn:target.com" --fields ip_str,port,org

# Netlas — deep infrastructure search
# Web: https://netlas.io — query: domain:*.target.com
阶段 4 — Google Analytics ID 交叉比对
# Extract Analytics ID from target pages
curl --max-time 30 --connect-timeout 10 -s "https://target.com" | grep -Eo '(?:UA-|G-|GTM-)[A-Z0-9]+'

# Find all domains sharing the same GA ID
curl --max-time 30 --connect-timeout 10 -s "https://api.hackertarget.com/analyticslookup/?q=UA-XXXXXXXX-X"
curl --max-time 30 --connect-timeout 10 -s "https://builtwith.com/relationships/target.com"

# Automated
cat subdomains.txt | analyticsrelationships
阶段 5 — 常见源站泄露途径
# Direct IP in page source
curl --max-time 30 --connect-timeout 10 -sk "https://target.com" | grep -Eo '\b(?:\d{1,3}\.){3}\d{1,3}\b' | sort -u

# DNS CNAME chain — may expose origin
dig target.com ANY +noall +answer
dig www.target.com CNAME +short

# MX records — mail server often shares infrastructure
dig target.com MX +short

# SPF records — may contain non-CDN IPs
dig target.com TXT +short | grep -Eo '\b(?:\d{1,3}\.){3}\d{1,3}\b'

# Subdomain with different IP pattern
subfinder -d target.com -silent | dnsx -silent -a -resp-only | sort -u > all_ips.txt
# Filter out Cloudflare IPs (104.x, 172.64-71.x)
grep -vE '^104\.(1[6-9]|2[0-9]|3[0-1])\.|^172\.(6[4-9]|7[0-1])\.' all_ips.txt > non_cf_ips.txt
# Probe each for the target's content
for ip in $(cat non_cf_ips.txt); do
  curl --max-time 30 -sk --connect-timeout 5 "https://$ip" -H "Host: target.com" -o /dev/null -w "%{http_code} $ip\n"
done | grep -v "^403\|^000"
阶段 6 — 验证源站
# Check if IP serves the target's content
curl --max-time 30 --connect-timeout 10 -sk "https://ORIGIN_IP" -H "Host: target.com" | grep -o '<title>[^<]*</title>'

# Verify favicon matches
curl --max-time 30 --connect-timeout 10 -sk "https://ORIGIN_IP/favicon.ico" -H "Host: target.com" -o favicon_origin.ico
md5sum favicon_target.ico favicon_origin.ico  # should match

# Probe ports directly on origin
naabu -host ORIGIN_IP -p - -rate 2000

注意事项

  • Cloudflare 可能会在你重复扫描时封禁你的 IP。 轮换 user-agent 和代理。
  • Shodan 查询需要 API 密钥。 免费套餐有速率限制。
  • 源站也可能受到防火墙规则保护。 即使找到了 IP,它也可能只接受来自 Cloudflare IP 段的流量。
  • 不同网站可能共用 Google Analytics ID。 在确认发现之前,请通过 favicon 或内容匹配进行验证。
  • 子域名对应的非 CDN IP 可能是负载均衡器, 而非实际的 Web 服务器源站。使用 Host 标头探测以确认。

验证

  1. CDN 缓存网站与直接访问源站 IP 时的 favicon 哈希一致。
  2. 使用 Host: target.com 向源站 IP 发送 HTTPS 请求,返回相同的页面内容。
  3. 源站开放的端口与 CDN 代理的端口不同(源站暴露 SSH、MySQL 等)。
  4. 源站 IP 上的 SSL 证书在 SAN 中列出了目标域名。

相关技能

  • subdomain-enumeration — 生成 IP 去重所需的子域名列表。
  • vhost-enumeration — 找到源站 IP 后,枚举虚拟主机。
  • port-mass-scan — 扫描源站 IP 上暴露的服务。

评论

支持 Markdown