API漏洞扫描工具
0x01 简介
APIDetector 是一款功能强大且高效的工具,旨在测试各种子域中暴露的 Swagger 端点,具有检测误报的独特智能功能。它对于从事 API 测试和漏洞扫描的安全专业人员和开发人员特别有用。
0x02 工具使用
用法
使用命令行运行 APIDetector。以下是一些使用示例:
-
常见用法,使用 Chrome 用户代理扫描 30 个线程的子域列表,并将结果保存在文件中:
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 -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 -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.compython apidetector.py -d example.com
-
要扫描一个文件中的多个域:
python apidetector.py -i input_file.txtpython apidetector.py -i input_file.txt
-
要指定输出文件:
python apidetector.py -i input_file.txt -o output_file.txtpython apidetector.py -i input_file.txt -o output_file.txt
-
要使用特定数量的线程,请执行以下操作:
python apidetector.py -i input_file.txt -t 20python apidetector.py -i input_file.txt -t 20
-
要同时使用 HTTP 和 HTTPS 协议进行扫描:
python apidetector.py -m -d example.compython apidetector.py -m -d example.com
-
要在安静模式下运行脚本(禁止详细输出),请执行以下操作:
python apidetector.py -q -d example.compython 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"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"
选项
-
-d
、 :要测试的单个域。--domain
-
-i
, :包含要测试的子域的输入文件。--input
-
-o
, :要将有效 URL 写入的输出文件。--output
-
-t
, :用于扫描的线程数(默认值为 10)。--threads
-
-m
、 :测试 HTTP 和 HTTPS 协议。--mixed-mode
-
-q
、:禁用详细输出(默认模式为详细)。--quiet
-
-ua
, :请求的自定义 User-Agent 字符串。--user-agent
-
APIDETECTOR 发现的每个端点的风险详细信息
-
暴露 Swagger 或 OpenAPI 文档端点可能会带来各种风险,主要与信息泄露有关。下面是基于潜在风险级别的有序列表,将相似的端点组合在一起 APIDetector 扫描:
-
1. 高风险端点(直接 API 文档):
-
端点:
-
'/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'
-
-
风险:
-
这些端点通常提供 Swagger UI 界面,该界面提供所有 API 端点的完整概述,包括请求格式、查询参数,有时甚至是示例请求和响应。
-
风险等级:高。暴露这些内容可让潜在攻击者详细了解您的 API 结构和潜在攻击媒介。
-
-
2. 中高风险端点(API 架构/规范):
-
端点:
-
'/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'
-
-
风险:
-
这些端点提供原始 Swagger/OpenAPI 规范文件。它们包含有关 API 端点的详细信息,包括路径、参数,有时还包括身份验证方法。
-
风险等级:中高。虽然它们比 UI 界面需要更多的解释,但它们仍然揭示了有关 API 的大量信息。
-
-
3. 中等风险端点(API 文档版本):
-
端点:
-
'/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'
'/api/swagger/v2/api-docs'
'/api/swagger/v3/api-docs'
-
-
风险:
-
这些端点通常引用特定于版本的文档或 API 说明。它们揭示了有关 API 结构和功能的信息,这可以帮助攻击者了解 API 的功能和潜在弱点。
-
风险等级:中等。这些可能不如完整的文档或架构文件详细,但它们仍为攻击者提供了有用的信息。
-
-
4. 低风险端点(配置和资源):
-
端点:
-
'/swagger-resources'
, , , ,'/swagger-resources/configuration/ui'
'/swagger-resources/configuration/security'
'/api/swagger-resources'
'/api.html'
-
-
风险:
-
这些端点通常提供与 API 文档设置相关的辅助信息、配置详细信息或资源。
-
风险等级:较低。它们可能不会直接透露 API 端点详细信息,但可以深入了解 API 文档的配置和设置。
-
-
总结:
-
最高风险:直接暴露交互式 API 文档接口。
-
中高风险:公开原始 API 架构/规范文件。
-
中等风险:特定于版本的 API 文档。
-
降低风险:API 文档的配置和资源文件。
0x03 项目下载链接
https://github.com/brinhosa/apidetector