blacklanternsecurity/cloudcheck
GitHub: blacklanternsecurity/cloudcheck
一款用于识别 IP 地址和域名是否属于主流云服务商、CDN 或 WAF 的多语言工具,支持 CLI、Python 库和 REST API。
Stars: 86 | Forks: 7
# CloudCheck
[](https://www.python.org)
[](https://pypi.org/project/cloudcheck/)
[](https://www.rust-lang.org)
[](https://crates.io/crates/cloudcheck)
[](https://github.com/blacklanternsecurity/cloudcheck/blob/stable/LICENSE)
[](https://github.com/astral-sh/ruff)
[](https://github.com/blacklanternsecurity/cloudcheck/actions/workflows/rust-tests.yml)
[](https://github.com/blacklanternsecurity/cloudcheck/actions/workflows/python-tests.yml)
[](https://github.com/blacklanternsecurity/cloudcheck/actions/workflows/pipeline-tests.yml)
[](https://github.com/blacklanternsecurity/cloudcheck/actions/workflows/docker-tests.yml)
[](https://github.com/blacklanternsecurity/cloudcheck/actions/workflows/daily-update.yml)
CloudCheck 是一个简单的 Rust 工具,用于检查 IP 地址或主机名是否属于云服务商。它包括:
- 一个 Rust CLI
- 一个 Rust 库
- Python 绑定
## 云服务商特征
最新的云服务商特征可在 [`cloud_providers_v2.json`](https://github.com/blacklanternsecurity/cloudcheck/blob/master/cloud_providers_v2.json) 中获取,该文件通过 [CI/CD](.github/workflows/daily-update.yml) 每日更新。与每个云服务商关联的域名动态获取自 [v2fly community repository](https://github.com/v2fly/domain-list-community),CIDR 获取自 [ASNDB](https://asndb.api.bbot.io/)。
被 [BBOT](https://github.com/blacklanternsecurity/bbot) 和 [BBOT Server](https://github.com/blacklanternsecurity/bbot-server) 使用。
## CLI 使用
```
# 安装
cargo install cloudcheck
# lookup 命令
cloudcheck lookup 8.8.8.8
# 输出:
[
{
"name": "Google",
"tags": ["cloud"],
"short_description": "A suite of cloud computing services provided by Google",
"long_description": "Google Cloud Platform provides infrastructure, platform, and software services for businesses and developers"
}
]
cloudcheck lookup asdf.amazon.com
# 输出:
[
{
"name": "Amazon",
"tags": ["cloud"],
"short_description": "A comprehensive cloud computing platform provided by Amazon",
"long_description": "Amazon Web Services offers infrastructure services, storage, and computing power"
}
]
# serve 命令 - 启动 REST API 服务器
cloudcheck serve
# 服务器监听于 http://127.0.0.1:8080
# Swagger UI 可用于 http://127.0.0.1:8080/swagger-ui
# OpenAPI 规范可用于 http://127.0.0.1:8080/api-docs/openapi.json
# serve 使用自定义 host 和 port
cloudcheck serve --host 0.0.0.0 --port 3000
```
## REST API
```
curl http://127.0.0.1:8080/8.8.8.8
```
## Python 库使用
```
# 安装
pip install cloudcheck
```
```
import asyncio
from cloudcheck import CloudCheck
async def main():
cloudcheck = CloudCheck()
results = await cloudcheck.lookup("8.8.8.8")
print(results) # [{'name': 'Google', 'tags': ['cloud']}]
asyncio.run(main())
```
### 错误处理
```
import asyncio
from cloudcheck import CloudCheck, CloudCheckError
async def main():
cloudcheck = CloudCheck()
try:
results = await cloudcheck.lookup("8.8.8.8")
print(results)
except CloudCheckError as e:
print(f"Error: {e}")
asyncio.run(main())
```
### 配置
```
import asyncio
from cloudcheck import CloudCheck
async def main():
# Custom configuration
cloudcheck = CloudCheck(
signature_url="https://example.com/custom.json", # Custom signature URL
max_retries=5, # Max retry attempts (default: 10)
retry_delay_seconds=2, # Delay between retries (default: 1)
force_refresh=True # Force fresh fetch (default: False)
)
results = await cloudcheck.lookup("8.8.8.8")
print(results)
asyncio.run(main())
```
## Rust 库使用
```
# 添加到 Cargo.toml
[dependencies]
cloudcheck = "8.0"
tokio = { version = "1", features = ["full"] }
```
```
use cloudcheck::CloudCheck;
#[tokio::main]
async fn main() {
let cloudcheck = CloudCheck::new();
let results = cloudcheck.lookup("8.8.8.8").await.unwrap();
println!("{:?}", results); // [CloudProvider { name: "Google", tags: ["cloud"] }]
}
```
### 错误处理
```
use cloudcheck::CloudCheck;
#[tokio::main]
async fn main() {
let cloudcheck = CloudCheck::new();
match cloudcheck.lookup("8.8.8.8").await {
Ok(results) => println!("{:?}", results),
Err(e) => eprintln!("Error: {}", e),
}
}
```
### 配置
```
use cloudcheck::CloudCheck;
#[tokio::main]
async fn main() {
// Custom configuration
let cloudcheck = CloudCheck::with_config(
Some("https://example.com/custom.json".to_string()), // Custom signature URL
Some(5), // Max retry attempts (default: 10)
Some(2), // Delay between retries in seconds (default: 1)
Some(true) // Force fresh fetch (default: false)
);
match cloudcheck.lookup("8.8.8.8").await {
Ok(results) => println!("{:?}", results),
Err(e) => eprintln!("Error: {}", e),
}
}
```
## 更新 JSON 数据库
```
export BBOT_IO_API_KEY=
uv sync
uv run cloudcheck_update/cli.py
```
## 添加新的云服务商
添加新的云服务商时:
1. 在 `cloudcheck/providers` 目录中创建一个新文件,并随意命名,例如 `amazon.py`。
2. 在该文件中,创建一个继承自 `BaseProvider` 的新类。
3. 在该类中,填写适用于你的服务商的以下任何属性:
- `v2fly_company`: 用于 v2fly 域名获取的公司名称。这将动态从 v2fly 社区仓库获取域名,该仓库的目的是跟踪不同公司的域名所有权。
- `org_ids`: 来自 ASNDB 的组织 ID 列表。这些总是比硬编码的 ASN 或 CIDR 更可取,因为它们每日从实时来源更新。像 Amazon 这样的大公司通常每个区域互联网注册机构 (ARIN, RIPE, APNIC, LACNIC, AFRINIC) 都有一个组织 ID,在该组织 ID 内,它们可能有多个 ASN。
- `asns`: ASN 列表,例如 `[12345, 67890]`
- `cidrs`: CIDR 列表,例如 `["1.2.3.4/32", "5.6.7.8/32"]` (始终首选使用 `org_ids`,或者必要时使用 `asns`,而不是手动指定的 CIDR)
- `domains`: 域名列表,例如 `["amazon.com", "amazon.co.uk"]` (始终首选使用 `v2fly_company` 而不是硬编码域名)
- `tags`: 服务商的标签列表。这些在 BBOT 中用于标记与此服务商匹配的 IP、DNS 名称等。示例:`cloud`、`cdn`、`waf` 等。
- `regexes`: 服务商的正则表达式字典。这些在 BBOT 中用于提取/验证云资源(如存储桶)。当前有效的正则表达式是:
- `STORAGE_BUCKET_NAME`: 存储桶名称的正则表达式(在暴力破解存储桶名称时很有用,因为您可以尽早丢弃无效的存储桶名称)。
- `STORAGE_BUCKET_HOSTNAME`: 存储桶主机名的正则表达式
除了上述属性外,如果您有自定义的 CIDR 或域名来源,您可以重写 `fetch_cidrs()` 或 `fetch_domains()` 方法(默认情况下返回空列表)以获取您的自定义 TXT/JSON 文件等。
## 云服务商 (56)
| Name | Description | Tags | Domains | Subnets |
|------|-------------|------|---------|----------|
| Akamai | 内容分发网络和云服务提供商,提供网络和互联网安全服务。 | cloud | 81 | 6362 |
| Alibaba Cloud | 中国云计算公司和阿里巴巴集团的子公司,提供云服务和基础设施。 | cloud | 394 | 96 |
| Amazon Web Services | Amazon 提供的综合云计算平台,提供基础设施服务、存储和计算能力。 | cloud | 245 | 14456 |
| Arvancloud | 伊朗云计算和内容分发网络提供商,提供云基础设施和 CDN 服务。 | cdn | 1 | 20 |
| Backblaze | 云存储和备份服务提供商,提供数据备份和云存储解决方案。 | cloud | 2 | 27 |
| Baidu Cloud Acceleration (百度云加速) | 百度提供的中国内容分发网络和云加速服务。 | cdn | 134 | 0 |
| CacheFly | 内容分发网络提供商,提供全球 CDN 服务。 | cdn | 0 | 82 |
| CDNetworks (씨디네트웍스) | 韩国内容分发网络提供商,提供 CDN 和云服务。 | cdn | 0 | 3 |
| Cisco | 跨国技术公司,设计、制造和销售网络硬件、软件和电信设备。 | cloud | 121 | 643 |
| Cloudflare | 网络基础设施和安全公司,提供内容分发网络服务、DDoS 缓解和 Web 安全解决方案。 | waf | 74 | 2799 |
| Amazon CloudFront | Amazon Web Services 提供的内容分发网络服务,向全球客户交付数据、视频、应用程序和 API。 | cdn | 0 | 174 |
| DDoS Guard | DDoS 保护和内容分发网络服务提供商。 | cdn | 0 | 18 |
| Dell | 跨国技术公司,开发、销售、维修和支持计算机及相关产品和服务。 | cloud | 236 | 99 |
| DigitalOcean | 云基础设施提供商,为开发者和企业提供虚拟专用服务器、托管数据库和其他云服务。 | cloud | 4 | 278 |
| Department of Defense | 美国政府机构,负责协调和监督所有直接与国家安全和美国武装部队相关的政府机构和职能。 | gov | 3 | 9007 |
| Federal Bureau of Investigation | 美国政府机构,作为国内情报和安全部门,负责调查联邦犯罪和保护国家安全。 | gov | 3 | 21 |
| Fastly | 内容分发网络和边缘云平台,提供边缘计算、安全和性能服务。 | cdn | 8 | 1054 |
| Gabia (가비아) | 韩国云托管和基础设施提供商。 | cloud | 0 | 48 |
| G-Core Labs | 内容分发网络和云基础设施提供商,提供 CDN、云计算和边缘服务。 | cdn | 0 | 1435 |
| GitHub | 使用 Git 进行版本控制和协作的基于 Web 的平台,为软件开发和代码存储库提供托管。 | cdn | 33 | 4470 |
| GoCache | 巴西内容分发网络提供商,提供 CDN 服务。 | cdn | 0 | 25 |
| Google Cloud | Google 提供的一套云计算服务,包括基础设施、平台和面向企业和开发者的软件服务。 | cloud | 1109 | 2016 |
| Hewlett Packard Enterprise | 跨国企业信息技术公司,提供服务器、存储、网络和云服务。 | cloud | 16 | 39 |
| Heroku | 云平台即服务,使开发者能够在云中完全构建、运行和操作应用程序。 | cloud | 12 | 0 |
| Hetzner | 德国云托管提供商,提供专用服务器、云实例和存储解决方案。 | cloud | 15 | 116 |
| Hostway (호스트웨이) | 韩国云托管和基础设施提供商。 | cloud | 0 | 59 |
| Huawei | 中国跨国技术公司,设计、开发和销售电信设备、消费电子产品和云服务。 | cloud | 338 | 269 |
| IBM | 跨国技术公司,提供硬件、软件、云计算和咨询服务。 | cloud | 20 | 391 |
| Imperva | 网络安全公司,提供 Web 应用防火墙、DDoS 保护和数据安全解决方案。 | waf | 1 | 355 |
| Kamatera | 云基础设施提供商,提供虚拟专用服务器、云服务器和托管云服务。 | cloud | 1 | 167 |
| KINX (한국인터넷인프라) | 韩国内容分发网络和云基础设施提供商。 | cdn | 0 | 143 |
| KT Cloud (KT클라우드) | KT Corporation 提供的韩国云计算服务。 | cloud | 0 | 18 |
| Leaseweb | 全球托管和云基础设施提供商,提供专用服务器、云托管和 CDN 服务。 | cloud | 0 | 1485 |
| LG U+ (LG유플러스) | 提供 CDN 服务的韩国电信公司。 | cdn | 0 | 171 |
| Microsoft | 跨国技术公司,开发、制造、许可、支持和销售计算机软件、消费电子产品和个人电脑。以 Windows、Office、Azure 云服务和 Xbox 等产品闻名。 | cloud | 690 | 2476 |
| Microsoft 365 | Microsoft 提供的基于云的生产力套件,包括 Office 应用程序和云服务。 | cloud | 189 | 82 |
| Naver Cloud Platform (네이버 클라우드 플랫폼) | Naver Corporation 提供的韩国云计算平台。 | cloud | 0 | 73 |
| NHN Cloud (NHN클라우드) | NHN Corporation 提供的韩国云计算平台。 | cloud | 0 | 122 |
| OVHcloud | 法国云计算公司,提供 Web 托管、专用服务器和云基础设施服务。 | cloud | 3 | 544 |
| Oracle | 跨国技术公司,提供数据库软件、云工程系统和企业软件产品。 | cloud | 18 | 2480 |
| Qrator | DDoS 保护和内容分发网络服务提供商。 | cdn | 0 | 22 |
| Quic.cloud | 内容分发网络和边缘计算平台,提供 CDN 服务。 | cdn | 0 | 155 |
| Russian Federal Security Service | 俄罗斯联邦执行机构,负责反情报、内部和边境安全、反恐和监视。 | gov | 0 | 17 |
| Rackspace | 托管云计算公司,提供托管、云服务和托管基础设施解决方案。 | cloud | 1 | 199 |
| Salesforce | 基于云的软件公司,提供客户关系管理服务和企业云计算解决方案。 | cloud | 41 | 48 |
| Scaleway | 法国云计算公司,提供虚拟专用服务器、裸机服务器和云基础设施服务。 | cloud | 1 | 43 |
| SK Broadband (SK브로드밴드) | 提供 CDN 服务的韩国电信公司。 | cdn | 0 | 22 |
| StormWall | DDoS 保护和 Web 应用防火墙服务提供商。 | cdn | 0 | 18 |
| Sucuri | 网站安全和 Web 应用防火墙服务提供商。 | waf | 0 | 17 |
| Tencent Cloud (腾讯云) | 中国云计算服务提供商和腾讯的子公司,提供云基础设施和平台服务。 | cloud | 599 | 373 |
| United Kingdom Ministry of Defence | 英国政府部门,负责实施英国国防政策并管理英国武装部队。 | gov | 1 | 0 |
| Wasabi | 云存储提供商,提供高性能且低成本的热云存储服务。 | cloud | 1 | 20 |
| X4B | DDoS 保护和内容分发网络服务提供商。 | cdn | 0 | 2 |
| Yandex Cloud | 俄罗斯云计算和互联网服务提供商,提供基础设施、存储和各种数字服务。 | cloud | 59 | 79 |
| Zoho | 印度软件公司,提供基于云的商业软件和生产力工具,包括 CRM、电子邮件和办公套件。 | cloud | 13 | 81 |
| Zscaler | 云安全公司,提供安全互联网访问、云安全和零信任网络访问服务。 | cloud | 0 | 274 |
## 开发
### Python
#### 设置
```
uv sync
uv run maturin develop --release
```
#### 运行测试
```
# python 测试
uv run pytest test_cloudcheck.py -v
# docker 测试
python test_docker.py
```
#### Linting
```
# 检查 linting 问题
uv run ruff check && uv run ruff format .
```
### Rust
#### 运行测试
```
cargo test --verbose --all-features
```
#### 格式化
```
cargo fmt --all
cargo clippy --all-targets --all-features -- -D warnings
```
标签:ASN查询, AWS, Azure, CLI, DPI, GCP, GitHub, IP地址查询, IP地理位置, Python, Rust, WiFi技术, 主机名解析, 二进制发布, 云服务商识别, 云资源枚举, 可视化界面, 商业软件, 威胁情报, 开发者工具, 开源工具, 归属识别, 无后门, 网络安全, 网络流量审计, 请求拦截, 逆向工具, 隐私保护