mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
56 lines
4.2 KiB
Markdown
56 lines
4.2 KiB
Markdown
# Web API Pentesting
|
||
|
||
{{#include ../../banners/hacktricks-training.md}}
|
||
|
||
## API Pentesting Methodology Summary
|
||
|
||
Pentesting APIs 涉及一种结构化的方法来发现漏洞。本指南概括了一种全面的方法论,强调实用的技术和工具。
|
||
|
||
### **Understanding API Types**
|
||
|
||
- **SOAP/XML Web Services**: 使用 WSDL 格式进行文档编制,通常在 `?wsdl` 路径中找到。工具如 **SOAPUI** 和 **WSDLer** (Burp Suite Extension) 对于解析和生成请求非常重要。示例文档可在 [DNE Online](http://www.dneonline.com/calculator.asmx) 获取。
|
||
- **REST APIs (JSON)**: 文档通常以 WADL 文件形式提供,但像 [Swagger UI](https://swagger.io/tools/swagger-ui/) 这样的工具提供了更用户友好的交互界面。**Postman** 是一个创建和管理示例请求的有价值工具。
|
||
- **GraphQL**: 一种用于 API 的查询语言,提供对 API 中数据的完整和可理解的描述。
|
||
|
||
### **Practice Labs**
|
||
|
||
- [**VAmPI**](https://github.com/erev0s/VAmPI): 一个故意存在漏洞的 API,供实践使用,涵盖 OWASP 前 10 大 API 漏洞。
|
||
|
||
### **Effective Tricks for API Pentesting**
|
||
|
||
- **SOAP/XML Vulnerabilities**: 探索 XXE 漏洞,尽管 DTD 声明通常受到限制。如果 XML 保持有效,CDATA 标签可能允许有效负载插入。
|
||
- **Privilege Escalation**: 测试具有不同权限级别的端点,以识别未授权访问的可能性。
|
||
- **CORS Misconfigurations**: 检查 CORS 设置,以寻找通过已认证会话的 CSRF 攻击的潜在利用可能性。
|
||
- **Endpoint Discovery**: 利用 API 模式发现隐藏的端点。像模糊测试工具这样的工具可以自动化此过程。
|
||
- **Parameter Tampering**: 尝试在请求中添加或替换参数,以访问未授权的数据或功能。
|
||
- **HTTP Method Testing**: 变更请求方法(GET, POST, PUT, DELETE, PATCH)以发现意外行为或信息泄露。
|
||
- **Content-Type Manipulation**: 在不同的内容类型(x-www-form-urlencoded, application/xml, application/json)之间切换,以测试解析问题或漏洞。
|
||
- **Advanced Parameter Techniques**: 在 JSON 有效负载中测试意外数据类型,或玩弄 XML 数据以进行 XXE 注入。同时,尝试参数污染和通配符字符以进行更广泛的测试。
|
||
- **Version Testing**: 较旧的 API 版本可能更容易受到攻击。始终检查并测试多个 API 版本。
|
||
|
||
### **Tools and Resources for API Pentesting**
|
||
|
||
- [**kiterunner**](https://github.com/assetnote/kiterunner): 非常适合发现 API 端点。使用它扫描和暴力破解目标 API 的路径和参数。
|
||
```bash
|
||
kr scan https://domain.com/api/ -w routes-large.kite -x 20
|
||
kr scan https://domain.com/api/ -A=apiroutes-220828 -x 20
|
||
kr brute https://domain.com/api/ -A=raft-large-words -x 20 -d=0
|
||
kr brute https://domain.com/api/ -w /tmp/lang-english.txt -x 20 -d=0
|
||
```
|
||
- [**https://github.com/BishopFox/sj**](https://github.com/BishopFox/sj): sj 是一个命令行工具,旨在通过检查相关的 API 端点的弱身份验证来协助审计 **暴露的 Swagger/OpenAPI 定义文件**。它还提供手动漏洞测试的命令模板。
|
||
- 其他工具如 **automatic-api-attack-tool**、**Astra** 和 **restler-fuzzer** 提供针对 API 安全测试的定制功能,从攻击模拟到模糊测试和漏洞扫描。
|
||
- [**Cherrybomb**](https://github.com/blst-security/cherrybomb): 这是一个基于 OAS 文件审计您的 API 的 API 安全工具(该工具用 Rust 编写)。
|
||
|
||
### **学习和实践资源**
|
||
|
||
- **OWASP API Security Top 10**: 理解常见 API 漏洞的必读材料 ([OWASP Top 10](https://github.com/OWASP/API-Security/blob/master/2019/en/dist/owasp-api-security-top-10.pdf))。
|
||
- **API 安全检查清单**: 一个全面的 API 安全检查清单 ([GitHub link](https://github.com/shieldfy/API-Security-Checklist))。
|
||
- **Logger++ 过滤器**: 用于寻找 API 漏洞,Logger++ 提供有用的过滤器 ([GitHub link](https://github.com/bnematzadeh/LoggerPlusPlus-API-Filters))。
|
||
- **API 端点列表**: 一个经过策划的潜在 API 端点列表,用于测试目的 ([GitHub gist](https://gist.github.com/yassineaboukir/8e12adefbd505ef704674ad6ad48743d))。
|
||
|
||
## 参考
|
||
|
||
- [https://github.com/Cyber-Guy1/API-SecurityEmpire](https://github.com/Cyber-Guy1/API-SecurityEmpire)
|
||
|
||
{{#include ../../banners/hacktricks-training.md}}
|