origin-ip-discovery について
origin-ip-discoveryは、CDNやWAFの背後にあるオリジンIPを探すセキュリティ調査ガイドです。ファビコンハッシュ、過去のDNS、証明書名、分析IDを手掛かりにし、候補を検証します。
主な機能
- 01ファビコンハッシュによる検索
- 02過去のDNSレコード確認
- 03SSL証明書名の照合
- 04Google Analytics IDの相互検索
- 05オリジンIPとコンテンツの検証
活用シーン
- 01Cloudflareなどの背後にあるオリジン調査
- 02DNS履歴や証明書からIP候補を探索
- 03Hostヘッダーとファビコンで候補オリジンを検証
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ uphiago/ recon-skills --skill origin-ip-discoveryインストール後、Claude Code で/origin-ip-discoveryを入力して読み込まれたか確認します。
詳細
オリジン IP の特定
CDN/WAF による保護(Cloudflare、Akamai、Fastly)の背後にある実サーバーの IP を特定します。オリジン IP が見つかると、ファイアウォールルール、レート制限、アプリケーション層のフィルタリングが適用されていない状態で、サーバーに直接アクセスできるようになります。手法には、Shodan を使ったファビコンハッシュのフィンガープリント照合、パッシブソースからの過去の DNS レコードの取得、SSL 証明書の SAN フィールドの照合、Google Analytics ID の相互参照などがあります。
使用する場面
- 対象が Cloudflare/Akamai の背後にあり、すべてのリクエストで 403 または CAPTCHA チャレンジが返される場合。
- WAF ルールを回避するために、オリジンへ直接アクセスする必要がある場合。
- サブドメインの列挙で、CDN を経由しない IP 上の内部ホストまたはステージングホストが見つかった場合。
- 対象がすべてのインフラストラクチャで同一のファビコンを使用している場合。
- SSL 証明書が複数の IP で同一の組織名を共有している場合。
前提条件
- curl、python3、shodan CLI が使える
terminal。 - Shodan API キー:
shodan init <KEY>。 - 対象のファビコンファイルまたは 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 — ファビコンハッシュのフィンガープリント照合
# 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 — オリジン IP が漏えいする一般的な経路
# 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 をブロックされることがあります。 ユーザーエージェントとプロキシを切り替えてください。
- Shodan のクエリには API キーが必要です。 無料プランにはレート制限があります。
- オリジンにもファイアウォールルールが適用されている場合があります。 IP が見つかっても、Cloudflare の IP 範囲からのトラフィックしか受け付けない可能性があります。
- Google Analytics ID は無関係なサイト間で共有されていることがあります。 発見を報告する前に、ファビコンまたはコンテンツが一致することを確認してください。
- **サブドメインから見つかった CDN を経由しない IP は、**実際の Web サーバーのオリジンではなく、ロードバランサーの IP の可能性があります。Host ヘッダーを指定してプローブし、確認してください。
検証
- CDN キャッシュ経由のサイトとオリジン IP で、ファビコンハッシュが一致する。
Host: target.comを指定してオリジン IP に HTTPS リクエストを送信すると、同じページコンテンツが返される。- オリジンで開いているポートが CDN 経由で公開されているポートと異なり、オリジンでは SSH、MySQL などが公開されている。
- オリジン IP の SSL 証明書の SAN に対象ドメインが記載されている。
関連スキル
subdomain-enumeration— IP の重複排除に必要なサブドメインリストを生成します。vhost-enumeration— オリジン IP が見つかったら、仮想ホストを列挙します。port-mass-scan— オリジン IP をスキャンして、公開されているサービスを調べます。
コメント
Markdown 対応