Skip to content

Repository files navigation

FOFA & ZoomEye API 搜索和验证工具

一个强大的网络空间搜索引擎 API 搜索、验证和管理工具,支持 FOFA 和 ZoomEye 双平台。

🌟 功能特点

  • 🔍 双平台支持:同时支持 FOFA 和 ZoomEye 两大网络空间搜索引擎
  • 🚀 智能搜索:从 GitHub 等平台自动搜索公开的 API
  • 批量验证:自动验证 API 有效性,过滤无效 API
  • 📊 详细信息:查看账户信息(余额、VIP、配额等)
  • 🎯 灵活控制:支持自定义文件数量,甚至无限制搜索
  • 🔄 智能去重:自动跳过重复文件,提升效率 50%
  • 💾 结果保存:自动保存有效 API 到 JSON 文件
  • 🎨 友好界面:彩色终端输出,实时进度显示
  • ⚙️ 配置管理:支持配置文件,方便管理常用参数
  • 🖥️ 批处理脚本:Windows 用户可使用图形化菜单

📁 项目结构

fofa/
├── fofa_api_searcher.py         # FOFA API 搜索工具
├── fofa_api_tool.py             # FOFA API 验证工具
├── zoomeye_api_searcher.py      # ZoomEye API 搜索工具
├── zoomeye_api_tool.py          # ZoomEye API 验证工具
├── config.py                    # 配置文件管理模块
├── config.ini                   # 配置文件
├── requirements.txt             # Python 依赖
├── run_all.bat                  # 统一启动脚本(推荐)
├── run_fofa.bat                 # FOFA 专用启动脚本
├── run_zoomeye.bat              # ZoomEye 专用启动脚本
├── found_fofa_apis.txt          # FOFA 搜索结果
├── found_zoomeye_apis.txt       # ZoomEye 搜索结果
├── valid_fofa_apis.json         # 有效的 FOFA API
└── valid_zoomeye_apis.json      # 有效的 ZoomEye API

🚀 快速开始

环境要求

  • Python 3.6+
  • requests 库
  • urllib3 库

安装步骤

# 1. 克隆或下载本项目
git clone <repository_url>
cd fofa

# 2. 安装依赖
pip install -r requirements.txt

# 3. (可选) 配置 GitHub Token
# 编辑 config.ini,填入你的 GitHub Token

方式一:使用批处理脚本(Windows 推荐)

# 双击运行
run_all.bat

# 按菜单提示操作:
# 1. 选择平台(FOFA 或 ZoomEye)
# 2. 选择操作(搜索、验证或完整流程)
# 3. 输入文件数量(或直接回车使用默认值)

方式二:命令行使用

FOFA 工具

# 搜索 FOFA API(默认20个)
python fofa_api_searcher.py

# 搜索100个文件
python fofa_api_searcher.py --max-results 100

# 搜索所有文件(无限制)
python fofa_api_searcher.py --max-results 0

# 使用 GitHub Token(推荐)
python fofa_api_searcher.py --github-token YOUR_TOKEN --max-results 100

# 验证搜索到的 API
python fofa_api_tool.py -f found_fofa_apis.txt --test-query

ZoomEye 工具

# 搜索 ZoomEye API(默认20个)
python zoomeye_api_searcher.py

# 搜索200个文件
python zoomeye_api_searcher.py --max-results 200

# 搜索所有文件(无限制)
python zoomeye_api_searcher.py --max-results 0

# 使用 GitHub Token(推荐)
python zoomeye_api_searcher.py --github-token YOUR_TOKEN --max-results 200

# 验证搜索到的 API
python zoomeye_api_tool.py -f found_zoomeye_apis.txt --test-query

📖 详细使用说明

1. FOFA API 工具

搜索工具 (fofa_api_searcher.py)

基本用法:

# 使用默认配置搜索
python fofa_api_searcher.py

# 指定文件数量
python fofa_api_searcher.py --max-results 100

# 无限制搜索(搜索所有找到的文件)
python fofa_api_searcher.py --max-results 0

# 配合 GitHub Token
python fofa_api_searcher.py --github-token YOUR_TOKEN --max-results 200

# 指定输出文件
python fofa_api_searcher.py -o my_apis.json --max-results 100

# 仅搜索 GitHub
python fofa_api_searcher.py --github-only --max-results 50

高级选项:

# 禁用 SSL 验证(不推荐,仅用于特殊网络环境)
python fofa_api_searcher.py --no-verify-ssl

# 设置超时时间
python fofa_api_searcher.py --timeout 60

# 创建配置文件
python fofa_api_searcher.py --create-config

验证工具 (fofa_api_tool.py)

基本用法:

# 交互模式(推荐新手)
python fofa_api_tool.py

# 验证单个 API
python fofa_api_tool.py -e your@email.com -k your_api_key

# 批量验证
python fofa_api_tool.py -f found_fofa_apis.txt

# 验证并测试查询功能
python fofa_api_tool.py -f found_fofa_apis.txt --test-query

# 指定输出文件
python fofa_api_tool.py -f found_fofa_apis.txt -o my_valid_apis.json

2. ZoomEye API 工具

搜索工具 (zoomeye_api_searcher.py)

基本用法:

# 使用默认配置搜索
python zoomeye_api_searcher.py

# 指定文件数量
python zoomeye_api_searcher.py --max-results 200

# 无限制搜索
python zoomeye_api_searcher.py --max-results 0

# 配合 GitHub Token
python zoomeye_api_searcher.py --github-token YOUR_TOKEN --max-results 200

验证工具 (zoomeye_api_tool.py)

基本用法:

# 交互模式
python zoomeye_api_tool.py

# 验证单个 API
python zoomeye_api_tool.py -k your_api_key

# 批量验证
python zoomeye_api_tool.py -f found_zoomeye_apis.txt --test-query

3. 完整工作流程

# FOFA 完整流程
python fofa_api_searcher.py --github-token YOUR_TOKEN --max-results 100 -o found_fofa_apis.txt
python fofa_api_tool.py -f found_fofa_apis.txt --test-query

# ZoomEye 完整流程
python zoomeye_api_searcher.py --github-token YOUR_TOKEN --max-results 200 -o found_zoomeye_apis.txt
python zoomeye_api_tool.py -f found_zoomeye_apis.txt --test-query

# 结果保存在:
# - valid_fofa_apis.json
# - valid_zoomeye_apis.json

⚙️ 配置说明

配置文件 (config.ini)

[github]
# GitHub Personal Access Token(用于搜索)
token = your_github_token_here

[search]
# 默认最大搜索结果数(0 表示不限制)
default_max_results = 100
# 默认网络请求超时时间(秒)
default_timeout = 30

[api]
# FOFA API 配置(可选)
email = 
key = 

[network]
# 是否验证 SSL 证书
verify_ssl = false
# 最大重试次数
max_retries = 2

获取 GitHub Token

  1. 访问 GitHub Token 设置
  2. 点击 "Generate new token (classic)"
  3. 选择 public_repo 权限
  4. 生成并复制 Token
  5. config.ini 中填入 Token

为什么需要 GitHub Token?

  • 未认证:60 次/小时(很快用完)
  • 已认证:5000 次/小时(足够使用)

📊 输出文件说明

FOFA 相关文件

found_fofa_apis.txt / found_fofa_apis.json

  • 搜索到的 FOFA API 列表(未验证)
[
    {
        "email": "example@example.com",
        "key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
]

valid_fofa_apis.json

  • 验证通过的有效 FOFA API(含详细信息)
[
    {
        "email": "example@example.com",
        "key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "username": "user123",
        "fcoin": 48,
        "isvip": true,
        "vip_level": 1,
        "remain_api_query": 10000,
        "remain_api_data": 10000,
        "verified_at": "2025-10-11 12:34:56"
    }
]

ZoomEye 相关文件

found_zoomeye_apis.txt / found_zoomeye_apis.json

  • 搜索到的 ZoomEye API 列表(未验证)
[
    {
        "api_key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    }
]

valid_zoomeye_apis.json

  • 验证通过的有效 ZoomEye API(含详细信息)
[
    {
        "api_key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "username": "user123",
        "email": "example@example.com",
        "role": "developer",
        "quota": {
            "remain_free_quota": 10000,
            "total_quota": 10000
        },
        "verified_at": "2025-10-11 12:34:56"
    }
]

💡 使用技巧

文件数量设置指南

设置值 效果 时间 适用场景
20(默认) 搜索20个文件 2-5分钟 快速测试
50 搜索50个文件 5-10分钟 一般使用
100 搜索100个文件 10-15分钟 推荐设置 ✓
200 搜索200个文件 15-25分钟 深度搜索
0 无限制 30-50分钟 完整搜索

性能优化建议

  1. 必须配置 GitHub Token - 提升 API 限制从 60 次/小时到 5000 次/小时
  2. 合理设置文件数 - 根据需求选择,不是越多越好
  3. 使用无限制模式 - 适合第一次搜索,获取最多 API
  4. 网络稳定环境 - 避免搜索中途断开
  5. 批处理脚本 - Windows 用户推荐使用 run_all.bat

搜索策略建议

策略1:快速验证

# 先搜索少量快速验证
python fofa_api_searcher.py --max-results 20
python fofa_api_tool.py -f found_fofa_apis.txt --test-query

策略2:常规搜索

# 搜索100个,平衡速度和数量
python fofa_api_searcher.py --max-results 100
python fofa_api_tool.py -f found_fofa_apis.txt --test-query

策略3:完整搜索

# 无限制模式,获取所有可能的 API
python fofa_api_searcher.py --max-results 0
python fofa_api_tool.py -f found_fofa_apis.txt --test-query

策略4:双平台组合

# 同时搜索 FOFA 和 ZoomEye
python fofa_api_searcher.py --max-results 100
python zoomeye_api_searcher.py --max-results 200
python fofa_api_tool.py -f found_fofa_apis.txt --test-query
python zoomeye_api_tool.py -f found_zoomeye_apis.txt --test-query

❓ 常见问题

Q: FOFA 和 ZoomEye 有什么区别?

A:

  • FOFA: 需要 email + key 两个参数,白帽汇(知道创宇)开发
  • ZoomEye: 只需一个 API key(UUID格式),知道创宇开发
  • 两者功能类似但数据来源不同,建议两者都搜索

Q: 如何搜索更多文件?

A:

# 方法1:命令行参数
python fofa_api_searcher.py --max-results 200

# 方法2:配置文件
# 编辑 config.ini:
[search]
default_max_results = 200

# 方法3:无限制模式
python fofa_api_searcher.py --max-results 0

Q: 为什么找不到 API?

A: 可能原因:

  1. 未配置 GitHub Token(最常见)- 很快达到 API 限制
  2. 网络连接问题 - 检查网络
  3. 搜索关键词覆盖不全 - 工具已内置多个关键词
  4. 公开的 API 较少 - 正常现象

解决方案:

  • 配置 GitHub Token(最重要!)
  • 增加搜索文件数:--max-results 200
  • 使用无限制模式:--max-results 0

Q: API 验证失败?

A: 可能原因:

  • API 已过期或被撤销
  • 网络连接问题
  • FOFA/ZoomEye 服务暂时不可用
  • Email/Key 格式错误

Q: 为什么显示"找到 30/100 个文件"?

A:

  • 30/100 = 当前查询在 GitHub 返回了 30 个结果 / 你设置的总目标 100
  • 工具会运行多个查询,直到达到你设置的总数
  • 例如:查询1找到30个 + 查询2找到40个 + 查询3找到30个 = 总共100个

Q: 如何后台运行长时间搜索?

A:

# Windows
start /B python fofa_api_searcher.py --max-results 0

# Linux/Mac
nohup python fofa_api_searcher.py --max-results 0 &

Q: SSL 证书错误怎么办?

A:

# 添加 --no-verify-ssl 参数(不推荐,但可以解决问题)
python fofa_api_searcher.py --no-verify-ssl

⚠️ 注意事项

重要提示

  1. 仅用于学习和研究目的 - 请勿用于非法用途
  2. 尊重隐私 - 搜索到的 API 可能是他人泄露的
  3. 遵守服务条款 - 使用 FOFA/ZoomEye API 时遵守各自的服务条款
  4. 注意 API 限制 - 留意查询次数和数据限制
  5. 配置 GitHub Token - 强烈建议配置以避免 API 限制
  6. 网络环境 - 确保网络稳定,避免中途断开

性能说明

  • 搜索速度: 取决于文件数量和网络速度
  • API 限制: GitHub API 有速率限制(已认证:5000次/小时)
  • 重复处理: 工具会自动跳过重复文件,提升效率 50%

敏感信息保护

  • config.ini 中的 GitHub Token 是敏感信息
  • 不要将包含 Token 的配置文件上传到公开仓库
  • 如需上传,请先删除或使用 .gitignore 排除

🔧 故障排除

问题:GitHub API 限制

错误信息: API rate limit exceeded

解决方案:

  1. 配置 GitHub Token
  2. 等待限制重置(通常1小时)
  3. 减少搜索频率

问题:网络超时

错误信息: TimeoutConnection error

解决方案:

# 增加超时时间
python fofa_api_searcher.py --timeout 60

问题:找不到文件

错误信息: File not found

解决方案:

  • 确保在正确的目录运行
  • 检查文件名是否正确
  • 先运行搜索工具再运行验证工具

📈 更新日志

v1.2 (2025-10-11) - 重要更新 🔥

Bug 修复:

  • 🐛 修复重复处理问题:同一文件不会被重复下载和处理
  • 🐛 修复文件数量限制:现在可以搜索任意数量的文件
  • 🐛 修复每个查询固定30个的问题:现在根据设置动态调整

新功能:

  • ✨ 无限制搜索模式:设置 --max-results 0 搜索所有文件
  • ✨ 动态请求数量:根据用户设置智能调整每个查询的请求数
  • ✨ 批处理脚本优化:添加文件数量输入提示

改进:

  • 📊 进度显示优化:实时显示处理进度和统计信息
  • ⚡ 性能提升 50%:避免重复下载,搜索效率显著提升
  • 🎯 智能文件分配:多个搜索关键词智能分配文件配额

v1.1 (2025-10-11)

  • ✨ 新增 ZoomEye API 搜索功能
  • ✨ 新增 ZoomEye API 验证功能
  • 📝 更新文档,添加 ZoomEye 使用说明
  • 🎨 新增统一启动脚本 run_all.bat

v1.0 (2025-10-11)

  • 🎉 初始版本发布
  • ✅ 支持 FOFA API 搜索
  • ✅ 支持 GitHub 代码搜索
  • ✅ 支持批量验证 API
  • ✅ 支持配置文件管理
  • ✅ 支持交互式操作

📄 许可证

本项目仅供学习和研究使用。使用者需自行承担使用本工具的风险和责任。

📣 免责声明

  • 本工具仅用于技术学习和研究
  • 使用本工具产生的任何后果由使用者自行承担
  • 请勿将本工具用于任何非法用途
  • 请遵守相关法律法规和服务条款
  • 搜索到的 API 可能是他人公开泄露的,请合理使用

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📞 支持

如有问题,请:

  1. 查看本 README 的常见问题部分
  2. 检查 config.ini 配置是否正确
  3. 确认已安装所有依赖
  4. 提交 Issue 描述问题

🔗 相关链接


版本: v1.2
作者: dafebgche
最后更新: 2025-10-11

⭐ 如果这个工具对你有帮助,请给个 Star!

About

搜索fofa key和zoomeye api key

Resources

Stars

9 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages