已在 BlackHat Arsenal 2024 上展示(链接)
/swagger-ui/index.html 端点生成概念验证APIDetector v3 需要 Python 3.x 及以下包:
flask # Web 框架
requests # HTTP 客户端
playwright # 浏览器自动化(用于截图)
nest_asyncio # 异步 IO 支持
所有依赖项均列在 requirements.txt 中,并可在设置过程中自动安装。
安装所需包后,您需要安装 Playwright 浏览器:
python -m playwright install
这对于截图功能的正常运行是必需的。
git clone https://github.com/brinhosa/apidetector.git
cd apidetector
# 在 macOS/Linux 上:
python3 -m venv venv
source venv/bin/activate
# 在 Windows 上:
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
playwright install
python app.py
python app.py --port 8080 --host 0.0.0.0
打开浏览器并导航到终端中显示的 URL。
使用 Web 界面:
截图将保存在 screenshots 目录中,以备将来参考。
APIDetector v3 提供两种交互方式:现代 Web 界面(v3 新增)和传统命令行界面(原版)。
python app.py [选项]
可用选项:
示例:
# 使用默认设置运行(localhost:5000)
python app.py
# 使用自定义端口运行
python app.py -p 8080
# 允许外部访问
python app.py --host 0.0.0.0
# 在调试模式下运行
python app.py -d
访问 Web 界面:
查看结果:
通过命令行运行 APIDetector。以下是一些用法示例:
常见用法:使用 30 个线程扫描子域名列表,使用 Chrome 用户代理,并将结果保存到文件:
python apidetector.py -i list_of_company_subdomains.txt -o results_file.txt -t 30 -ua "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"
扫描单个域名:
python apidetector.py -d example.com
从文件扫描多个域名:
python apidetector.py -i input_file.txt
指定输出文件:
python apidetector.py -i input_file.txt -o output_file.txt
使用特定数量的线程:
python apidetector.py -i input_file.txt -t 20
同时使用 HTTP 和 HTTPS 协议扫描:
python apidetector.py -m -d example.com
静默模式运行脚本(抑制详细输出):
python apidetector.py -q -d example.com
使用自定义用户代理运行脚本:
python apidetector.py -d example.com -ua "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36"
如果您使用的是 APIDetector v2,请将命令替换为 apidetectorv2.py。
-d, --domain:要测试的单个域名。-i, --input:包含要测试的子域名的输入文件。-o, --output:用于写入有效 URL 的输出文件。-t, --threads:用于扫描的线程数(默认值为 10)。-m, --mixed-mode:同时测试 HTTP 和 HTTPS 协议。-q, --quiet:禁用详细输出(默认模式为详细)。-ua, --user-agent:自定义请求的用户代理字符串。暴露 Swagger 或 OpenAPI 文档端点可能带来各种风险,主要涉及信息泄露。以下是基于潜在风险级别按降序排列的列表,APIDetector 扫描将相似端点分组在一起:
'/swagger-ui.html', '/swagger-ui/', '/swagger-ui/index.html', '/api/swagger-ui.html', '/documentation/swagger-ui.html', '/swagger/index.html', '/api/docs', '/docs', '/api/swagger-ui', '/documentation/swagger-ui''/openapi.json', '/swagger.json', '/api/swagger.json', '/swagger.yaml', '/swagger.yml', '/api/swagger.yaml', '/api/swagger.yml', '/api.json', '/api.yaml', '/api.yml', '/documentation/swagger.json', '/documentation/swagger.yaml', '/documentation/swagger.yml''/v2/api-docs', '/v3/api-docs', '/api/v2/swagger.json', '/api/v3/swagger.json', '/api/v1/documentation', '/api/v2/documentation', '/api/v3/documentation', '/api/v1/api-docs', '/api/v2/api-docs', '/api/v3/api-docs', '/swagger/v2/api-docs', '/swagger/v3/api-docs', '/swagger-ui.html/v2/api-docs', '/swagger-ui.html/v3/api-docs', , '/swagger-resources', '/swagger-resources/configuration/ui', '/swagger-resources/configuration/security', '/api/swagger-resources', '/api.html'欢迎为 APIDetector 做出贡献!请随时 fork 仓库、进行更改并提交 pull request。 特别感谢协助测试和提出功能建议的贡献成员:
APIDetector 工具严格仅用于测试和教育目的。APIDetector 的开发者不承担任何责任,并否认因使用本工具而产生的任何误用、意外后果或损害的所有责任。严禁任何未经授权、非法或以其他方式有害地使用 APIDetector。最终用户完全有责任确保遵守所有相关的当地、州、联邦和国际法律。使用本工具即表示用户确认拥有必要的授权来测试其打算扫描的网络或系统,并同意赔偿开发者因使用本工具而产生的所有索赔。 最终用户完全有责任确保其使用本工具不违反管辖所测试网络或系统的任何法律限制或服务条款。
免责声明:APIDetector 工具使用 APIDetector 工具专为合法测试和教育目的而设计。其按“现状”提供,不附带任何形式的明示或暗示的保证。APIDetector 的开发者及分发者明确否认因使用本工具而产生的误用、意外后果或损害的任何责任。 **重要法律声明:**严禁未经授权、非法或不道德地使用 APIDetector。用户全权负责遵守所有适用的当地、州、联邦和国际法律,以及与其所涉及的网络或系统相关的任何服务条款。使用 APIDetector 即表示用户确认其拥有必要的授权来测试目标网络或系统。 **风险承担与赔偿:**通过下载、安装或使用 APIDetector,用户承担因使用而产生的所有法律责任。APIDetector 的开发者及分发者不对因使用本工具而产生的任何法律后果、损害或第三方索赔承担责任。用户同意赔偿并使开发者和分发者免受因其行为而引起的任何索赔、法律费用或责任。
本项目采用 MIT 许可证 授权。
| 选项 | 描述 | 默认值 |
|---|
-p, --port | 端口号 | 5000 |
--host | 主机地址 | 127.0.0.1 |
-d, --debug | 启用调试模式 | False |
'/api/swagger/v2/api-docs''/api/swagger/v3/api-docs'