重要提示:截至2024年底,Censys 不再为免费账户提供 API 访问权限。这意味着 CloudFlair 已无法再与免费的 Censys 账户配合使用。
CloudFlair 是一款用于发现由 CloudFlare(或 CloudFront)保护的网站的原生服务器的工具,这些服务器公开暴露且未恰当地限制对相关 CDN IP 范围的网络访问。
该工具利用 Censys 的互联网范围扫描数据,查找暴露的 IPv4 主机,这些主机带有与目标域名关联的 SSL 证书。需要 API 密钥,可从您的 Censys 账户 获取。
有关此常见配置错误及 CloudFlair 工作原理的更多详细信息,请参阅配套博客文章:https://blog.christophetd.fr/bypassing-cloudflare-using-internet-wide-scan-data/
以下是 CloudFlair 的实际运行效果。
$ python cloudflair.py myvulnerable.site
[*] The target appears to be behind CloudFlare.
[*] Looking for certificates matching "myvulnerable.site" using Censys
[*] 75 certificates matching "myvulnerable.site" found.
[*] Looking for IPv4 hosts presenting these certificates...
[*] 10 IPv4 hosts presenting a certificate issued to "myvulnerable.site" were found.
- 51.194.77.1
- 223.172.21.75
- 18.136.111.24
- 127.200.220.231
- 177.67.208.72
- 137.67.239.174
- 182.102.141.194
- 8.154.231.164
- 37.184.84.44
- 78.25.205.83
[*] Retrieving target homepage at https://myvulnerable.site
[*] Testing candidate origin servers
- 51.194.77.1
- 223.172.21.75
- 18.136.111.24
responded with an unexpected HTTP status code 404
- 127.200.220.231
timed out after 3 seconds
- 177.67.208.72
- 137.67.239.174
- 182.102.141.194
- 8.154.231.164
- 37.184.84.44
- 78.25.205.83
[*] Found 2 likely origin servers of myvulnerable.site!
- 177.67.208.72 (HTML content identical to myvulnerable.site)
- 182.102.141.194 (HTML content identical to myvulnerable.site)
(此示例中的 IP 地址已做混淆处理,替换为随机生成的 IP)
$ export CENSYS_API_ID=...
$ export CENSYS_API_SECRET=...
$ git clone https://github.com/christophetd/CloudFlair.git
cd CloudFlair
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python cloudflair.py myvulnerable.site
或用于 CloudFront
python cloudflair.py myvulnerable.site --cloudfront
$ python cloudflair.py --help
usage: cloudflair.py [-h] [-o OUTPUT_FILE] [--censys-api-id CENSYS_API_ID] [--censys-api-secret CENSYS_API_SECRET] [--cloudfront] domain
positional arguments:
domain 要扫描的域名
options:
-h, --help 显示此帮助信息并退出
-o OUTPUT_FILE, --output OUTPUT_FILE
用于输出可能的源服务器的文件(默认:None)
--censys-api-id CENSYS_API_ID
Censys API ID。也可通过 CENSYS_API_ID 环境变量定义(默认:None)
--censys-api-secret CENSYS_API_SECRET
Censys API 密钥。也可通过 CENSYS_API_SECRET 环境变量定义(默认:None)
--cloudfront 检查 CloudFront 而非 CloudFlare(默认:False)
提供了一个轻量级的 CloudFlair Docker 镜像(christophetd/cloudflair)。可以使用以下命令轻松启动扫描。
$ docker run --rm -e CENSYS_API_ID=your-id -e CENSYS_API_SECRET=your-secret christophetd/cloudflair myvulnerable.site
您也可以创建一个包含环境变量定义的文件,并使用 Docker 的 --env-file 选项。
$ cat censys.env
CENSYS_API_ID=your-id
CENSYS_API_SECRET=your-secret
$ docker run --rm --env-file=censys.env christophetd/cloudflair myvulnerable.site
已在 Python 3.6 上测试。如有错误报告或问题,请随时提交 issue。