black electronics

CloudFlare

A script for finding a domain's real origin IP addresses via the Cloudflare API.

When a target sits behind Cloudflare, the DNS records visible to the public only show Cloudflare’s proxy IPs. If you have API access to the Cloudflare account (for example, during an internal or credentialed engagement), you can query the zone’s DNS records directly to see the real origin IPs behind any non-proxied (“grey cloud”) entries.

Terminal window
zones=$(curl -s -X GET "https://api.cloudflare.com/client/v4/zones" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" | jq -r '.result[] | "\(.id) \(.name)"')
while read -r zoneid zonename; do
echo "== $zonename =="
curl -s -X GET "https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" | jq -r '.result[] | "\(.type) \(.name) \(.content) \(.proxied)"' | grep "A "
done <<< "$zones"

Treat the API token like any other credential: scope it to the minimum permissions needed (DNS read), and never commit it to a script or repository.

Useful LinksPentest PayloadsCheat Sheets