Uncovering CloudFlare

Support HackTricks

Common Techniques to Uncover Cloudflare

  • 你可以使用一些服务来获取域名的历史DNS记录。也许网页运行在之前使用过的IP地址上。

  • 同样可以通过检查历史SSL证书来实现,这些证书可能指向原始IP地址。

  • 还要检查指向IP的其他子域的DNS记录,因为其他子域可能指向同一服务器(可能提供FTP、邮件或其他服务)。

  • 如果你在网络应用程序中发现SSRF,你可以利用它来获取服务器的IP地址。

  • 在浏览器中搜索网页的唯一字符串,例如shodan(也许还有google和类似的?)。也许你可以找到带有该内容的IP地址。

  • 以类似的方式,除了寻找唯一字符串外,你还可以使用工具搜索favicon图标:https://github.com/karma9874/CloudFlare-IPhttps://github.com/pielco11/fav-up

  • 这并不总是有效,因为服务器必须在通过IP地址访问时发送相同的响应,但你永远不知道。

Tools to uncover Cloudflare

# You can check if the tool is working with
prips 1.0.0.0/30 | hakoriginfinder -h one.one.one.one

# If you know the company is using AWS you could use the previous tool to search the
## web page inside the EC2 IPs
DOMAIN=something.com
WIDE_REGION=us
for ir in `curl https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.service=="EC2") | select(.region|test("^us")) | .ip_prefix'`; do
echo "Checking $ir"
prips $ir | hakoriginfinder -h "$DOMAIN"
done

从云基础设施中揭示Cloudflare

请注意,即使这是针对AWS机器完成的,也可以针对任何其他云提供商进行。

有关此过程的更好描述,请查看:

# Find open ports
sudo masscan --max-rate 10000 -p80,443 $(curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.service=="EC2") | .ip_prefix' | tr '\n' ' ') | grep "open"  > all_open.txt
# Format results
cat all_open.txt | sed 's,.*port \(.*\)/tcp on \(.*\),\2:\1,' | tr -d " " > all_open_formated.txt
# Search actual web pages
httpx -silent -threads 200 -l all_open_formated.txt -random-agent -follow-redirects -json -no-color -o webs.json
# Format web results and remove eternal redirects
cat webs.json | jq -r "select((.failed==false) and (.chain_status_codes | length) < 9) | .url" | sort -u > aws_webs.json

# Search via Host header
httpx -json -no-color -list aws_webs.json -header Host: cloudflare.malwareworld.com -threads 250 -random-agent -follow-redirects -o web_checks.json

通过 Cloudflare 绕过 Cloudflare

认证源拉取

该机制依赖于 客户端 SSL 证书 来验证连接,连接 Cloudflare 的反向代理 服务器和 服务器,这被称为 mTLS

客户可以简单地使用 Cloudflare 的证书来允许来自 Cloudflare 的任何连接,无论租户如何

因此,攻击者可以仅仅设置一个 在 Cloudflare 中使用 Cloudflare 的证书的域名,并将其指向 受害者 域名的 IP 地址。这样,设置他的域名完全不受保护,Cloudflare 不会保护发送的请求。

更多信息 在这里

允许列表 Cloudflare IP 地址

这将 拒绝不来自 Cloudflare 的 IP 地址范围的连接。这也容易受到之前设置的攻击,攻击者只需 将自己的域名指向 Cloudflare受害者 IP 地址并进行攻击。

更多信息 在这里

绕过 Cloudflare 进行抓取

缓存

有时你只想绕过 Cloudflare 以抓取网页。对此有一些选项:

  • 使用 Google 缓存: https://webcache.googleusercontent.com/search?q=cache:https://www.petsathome.com/shop/en/pets/dog

  • 使用其他缓存服务,如 https://archive.org/web/

工具

一些工具,如以下工具,可以绕过(或曾经能够绕过)Cloudflare 对抓取的保护:

Cloudflare 解决方案

已经开发了多种 Cloudflare 解决方案:

加固的无头浏览器

使用一个不会被检测为自动化浏览器的无头浏览器(你可能需要为此进行自定义)。一些选项包括:

内置绕过的智能代理

智能代理 由专业公司持续更新,旨在超越 Cloudflare 的安全措施(因为这是他们的业务)。

其中一些是:

对于寻求优化解决方案的人,ScrapeOps 代理聚合器 脱颖而出。该服务将超过 20 个代理提供商集成到一个 API 中,自动选择最佳和最具成本效益的代理,以便为你的目标域名提供更优的选择,从而更好地应对 Cloudflare 的防御。

逆向工程 Cloudflare 反机器人保护

逆向工程 Cloudflare 的反机器人措施是智能代理提供商使用的一种策略,适合于大规模网页抓取,而无需高成本地运行多个无头浏览器。

优点: 这种方法允许创建一个极其高效的绕过,专门针对 Cloudflare 的检查,适合大规模操作。

缺点: 缺点在于理解和欺骗 Cloudflare 故意模糊的反机器人系统的复杂性,需要持续努力测试不同的策略并在 Cloudflare 增强其保护时更新绕过。

有关如何做到这一点的更多信息,请参见 原始文章

参考文献

支持 HackTricks

Last updated