Uncovering CloudFlare

从零开始学习 AWS 黑客技术,成为专家 htARTE(HackTricks AWS 红队专家)

支持 HackTricks 的其他方式:

揭示 Cloudflare 的常见技术

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

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

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

  • 如果在 Web 应用程序中发现SSRF,则可以滥用它以获取服务器的 IP 地址。

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

  • 类似地,您可以使用工具搜索网站的 favicon 图标:https://github.com/karma9874/CloudFlare-IPhttps://github.com/pielco11/fav-up

  • 这种方法不太频繁地起作用,因为服务器在通过 IP 地址访问时必须发送相同的响应,但您永远不知道。

揭示 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 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 绕过功能的智能代理

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

其中一些是:

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

反向工程 Cloudflare 反机器人保护

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

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

劣势: 缺点在于理解和欺骗 Cloudflare 故意模糊的反机器人系统所涉及的复杂性,需要不断努力测试不同策略并更新绕过方式,因为 Cloudflare 不断加强其保护措施。

原始文章中找到更多关于如何执行此操作的信息。

参考资料

从零开始学习 AWS 黑客技术,成为 htARTE(HackTricks AWS 红队专家)

支持 HackTricks 的其他方式:

最后更新于