Skip to content

x-glacier/kali-pentest / kali-pentest-zh

kali-pentest-zh

Flagged

通过 SSH 或 Docker 使用 Kali Linux CLI 工具执行授权渗透测试。 覆盖:信息收集、漏洞分析、嗅探与欺骗、Web/API 渗透、漏洞利用、密码攻击、无线、云原生安全、RFID/NFC、VoIP/ICS、逆向工程、取证分析、后渗透/C2、报告生成。

FileKindSize
SKILL.mdskill md15.6 KB
references/cloud-native/README.mdmarkdown4.2 KB
references/cloud-native/tools/azurehound.mdmarkdown4.0 KB
references/cloud-native/tools/docker-bench-security.mdmarkdown1.9 KB
references/cloud-native/tools/kube-bench.mdmarkdown1.7 KB
references/cloud-native/tools/kubescape.mdmarkdown1.7 KB
references/cloud-native/tools/pacu.mdmarkdown3.0 KB
references/cloud-native/tools/peirates.mdmarkdown6.4 KB
references/cloud-native/tools/prowler.mdmarkdown1.5 KB
references/cloud-native/tools/scoutsuite.mdmarkdown1.2 KB
references/environment/README.mdmarkdown1.4 KB
references/environment/docker-mode-networking.mdmarkdown2.2 KB
references/environment/docker-mode-persistent-container.mdmarkdown3.8 KB
references/environment/docker-mode.mdmarkdown2.0 KB
references/environment/local-mode.mdmarkdown946 B
references/environment/server-mode.mdmarkdown4.1 KB
references/environment/state-files.mdmarkdown2.3 KB
references/exploitation/README.mdmarkdown9.6 KB
references/exploitation/tools/chisel.mdmarkdown3.2 KB
references/exploitation/tools/coercer.mdmarkdown2.5 KB
references/exploitation/tools/dns2tcp.mdmarkdown3.8 KB
references/exploitation/tools/evil-winrm.mdmarkdown2.9 KB
references/exploitation/tools/evilginx2.mdmarkdown2.2 KB
references/exploitation/tools/getsploit.mdmarkdown2.0 KB
references/exploitation/tools/gophish.mdmarkdown6.1 KB
references/exploitation/tools/impacket.mdmarkdown10.9 KB
references/exploitation/tools/iodine.mdmarkdown3.5 KB
references/exploitation/tools/ligolo-ng.mdmarkdown3.3 KB
references/exploitation/tools/metasploit.mdmarkdown11.0 KB
references/exploitation/tools/mitm6.mdmarkdown2.6 KB
references/exploitation/tools/msfconsole.mdmarkdown3.9 KB
references/exploitation/tools/msfvenom.mdmarkdown8.5 KB
references/exploitation/tools/mssqlpwner.mdmarkdown2.5 KB
references/exploitation/tools/netcat.mdmarkdown4.4 KB
references/exploitation/tools/odat.mdmarkdown3.0 KB
references/exploitation/tools/proxytunnel.mdmarkdown2.2 KB
references/exploitation/tools/routersploit.mdmarkdown2.9 KB
references/exploitation/tools/searchsploit.mdmarkdown4.7 KB
references/exploitation/tools/setoolkit.mdmarkdown1015 B
references/exploitation/tools/smbclient.mdmarkdown2.8 KB
references/exploitation/tools/socat.mdmarkdown2.8 KB
references/exploitation/tools/veil.mdmarkdown2.9 KB
references/forensics/README.mdmarkdown8.8 KB
references/forensics/tools/bulk-extractor.mdmarkdown4.5 KB
references/forensics/tools/chainsaw.mdmarkdown2.6 KB
references/forensics/tools/chkrootkit.mdmarkdown2.6 KB
references/forensics/tools/dc3dd.mdmarkdown2.9 KB
references/forensics/tools/dcfldd.mdmarkdown3.2 KB
references/forensics/tools/ddrescue.mdmarkdown3.6 KB
references/forensics/tools/exiftool.mdmarkdown2.5 KB
references/forensics/tools/foremost.mdmarkdown2.4 KB
references/forensics/tools/hashdeep.mdmarkdown3.5 KB
references/forensics/tools/plaso.mdmarkdown3.7 KB
references/forensics/tools/regripper.mdmarkdown3.4 KB
references/forensics/tools/rkhunter.mdmarkdown3.4 KB
references/forensics/tools/scalpel.mdmarkdown2.6 KB
references/forensics/tools/sleuthkit.mdmarkdown4.0 KB
references/forensics/tools/ssdeep.mdmarkdown3.1 KB
references/forensics/tools/steghide.mdmarkdown2.8 KB
references/forensics/tools/stegseek.mdmarkdown2.5 KB
references/forensics/tools/tcpdump.mdmarkdown2.8 KB
references/forensics/tools/tcpflow.mdmarkdown3.4 KB
references/forensics/tools/testdisk.mdmarkdown3.0 KB
references/forensics/tools/tshark.mdmarkdown3.0 KB
references/forensics/tools/volatility.mdmarkdown5.0 KB
references/forensics/tools/yara.mdmarkdown3.3 KB
references/information-gathering/README.mdmarkdown15.6 KB
references/information-gathering/tools/altdns.mdmarkdown1.9 KB
references/information-gathering/tools/amass.mdmarkdown9.1 KB
references/information-gathering/tools/arp-scan.mdmarkdown1.9 KB
references/information-gathering/tools/assetfinder.mdmarkdown1.9 KB
references/information-gathering/tools/autorecon.mdmarkdown2.9 KB
references/information-gathering/tools/certgraph.mdmarkdown3.3 KB
references/information-gathering/tools/cloud-enum.mdmarkdown2.1 KB
references/information-gathering/tools/cloudbrute.mdmarkdown2.1 KB
references/information-gathering/tools/dig.mdmarkdown2.3 KB
references/information-gathering/tools/dmitry.mdmarkdown2.0 KB
references/information-gathering/tools/dnsenum.mdmarkdown1.7 KB
references/information-gathering/tools/dnsgen.mdmarkdown1.5 KB
references/information-gathering/tools/dnsmap.mdmarkdown1.8 KB
references/information-gathering/tools/dnsrecon.mdmarkdown2.7 KB
references/information-gathering/tools/dnstwist.mdmarkdown3.0 KB
references/information-gathering/tools/dnsx.mdmarkdown2.8 KB
references/information-gathering/tools/eyewitness.mdmarkdown2.4 KB
references/information-gathering/tools/fierce.mdmarkdown2.5 KB
references/information-gathering/tools/finalrecon.mdmarkdown2.4 KB
references/information-gathering/tools/findomain.mdmarkdown2.5 KB
references/information-gathering/tools/fping.mdmarkdown2.3 KB
references/information-gathering/tools/getallurls.mdmarkdown2.4 KB
references/information-gathering/tools/gowitness.mdmarkdown4.8 KB
references/information-gathering/tools/h8mail.mdmarkdown3.9 KB
references/information-gathering/tools/hakrawler.mdmarkdown2.3 KB
references/information-gathering/tools/hosthunter.mdmarkdown2.6 KB
references/information-gathering/tools/httprobe.mdmarkdown2.1 KB
references/information-gathering/tools/httpx.mdmarkdown4.6 KB
references/information-gathering/tools/ldeep.mdmarkdown4.9 KB
references/information-gathering/tools/masscan.mdmarkdown3.8 KB
references/information-gathering/tools/massdns.mdmarkdown1.9 KB
references/information-gathering/tools/metagoofil.mdmarkdown3.0 KB
references/information-gathering/tools/naabu.mdmarkdown2.7 KB
references/information-gathering/tools/nbtscan.mdmarkdown2.2 KB
references/information-gathering/tools/netdiscover.mdmarkdown2.6 KB
references/information-gathering/tools/nmap.mdmarkdown8.4 KB
references/information-gathering/tools/p0f.mdmarkdown2.1 KB
references/information-gathering/tools/recon-ng.mdmarkdown6.6 KB
references/information-gathering/tools/sherlock.mdmarkdown3.7 KB
references/information-gathering/tools/shodan.mdmarkdown3.6 KB
references/information-gathering/tools/spiderfoot.mdmarkdown2.7 KB
references/information-gathering/tools/subfinder.mdmarkdown2.5 KB
references/information-gathering/tools/sublist3r.mdmarkdown1.9 KB
references/information-gathering/tools/theHarvester.mdmarkdown2.9 KB
references/information-gathering/tools/trufflehog.mdmarkdown3.1 KB
references/information-gathering/tools/wafw00f.mdmarkdown1.9 KB
references/information-gathering/tools/whatweb.mdmarkdown5.1 KB
references/information-gathering/tools/whois.mdmarkdown2.0 KB
references/password/README.mdmarkdown11.8 KB
references/password/tools/brutespray.mdmarkdown2.8 KB
references/password/tools/cewl.mdmarkdown2.1 KB
references/password/tools/changeme.mdmarkdown3.0 KB
references/password/tools/chntpw.mdmarkdown2.5 KB
references/password/tools/crowbar.mdmarkdown2.6 KB
references/password/tools/crunch.mdmarkdown2.7 KB
references/password/tools/fcrackzip.mdmarkdown2.3 KB
references/password/tools/gpp-decrypt.mdmarkdown2.6 KB
references/password/tools/hashcat.mdmarkdown4.6 KB
references/password/tools/hashid.mdmarkdown2.1 KB
references/password/tools/hydra.mdmarkdown4.4 KB
references/password/tools/john.mdmarkdown3.2 KB
references/password/tools/kerbrute.mdmarkdown2.8 KB
references/password/tools/medusa.mdmarkdown3.3 KB
references/password/tools/name-that-hash.mdmarkdown3.2 KB
references/password/tools/ncrack.mdmarkdown3.3 KB
references/password/tools/netexec.mdmarkdown3.2 KB
references/password/tools/patator.mdmarkdown2.2 KB
references/password/tools/pdfcrack.mdmarkdown2.9 KB
references/password/tools/rainbowcrack.mdmarkdown2.9 KB
references/password/tools/responder.mdmarkdown2.7 KB
references/playbooks/README.mdmarkdown8.1 KB
references/playbooks/active-directory.mdmarkdown14.0 KB
references/playbooks/api-security.mdmarkdown18.6 KB
references/playbooks/cloud-native-assessment.mdmarkdown17.6 KB
references/playbooks/external-attack-surface.mdmarkdown8.1 KB
references/playbooks/forensics-triage.mdmarkdown11.7 KB
references/playbooks/internal-network-protocols.mdmarkdown6.5 KB
references/playbooks/internal-network.mdmarkdown14.4 KB
references/playbooks/mobile-application.mdmarkdown9.8 KB
references/playbooks/password-audit.mdmarkdown9.0 KB
references/playbooks/post-exploitation.mdmarkdown11.4 KB
references/playbooks/reporting-workflow.mdmarkdown6.3 KB
references/playbooks/rfid-nfc.mdmarkdown7.2 KB
references/playbooks/source-code-audit.mdmarkdown8.4 KB
references/playbooks/voip-ics.mdmarkdown17.3 KB
references/playbooks/web-application.mdmarkdown14.7 KB
references/playbooks/wireless-assessment.mdmarkdown9.6 KB
references/post-exploitation/README.mdmarkdown11.0 KB
references/post-exploitation/tools/bloodhound.mdmarkdown4.8 KB
references/post-exploitation/tools/bloodhound.py.mdmarkdown4.0 KB
references/post-exploitation/tools/bloodyad.mdmarkdown4.1 KB
references/post-exploitation/tools/certipy-ad.mdmarkdown3.2 KB
references/post-exploitation/tools/dnscat2.mdmarkdown3.5 KB
references/post-exploitation/tools/dploot.mdmarkdown4.2 KB
references/post-exploitation/tools/havoc.mdmarkdown3.8 KB
references/post-exploitation/tools/hekatomb.mdmarkdown3.0 KB
references/post-exploitation/tools/krbrelayx.mdmarkdown7.3 KB
references/post-exploitation/tools/lapsdumper.mdmarkdown2.4 KB
references/post-exploitation/tools/linpeas.mdmarkdown3.6 KB
references/post-exploitation/tools/linux-exploit-suggester.mdmarkdown2.8 KB
references/post-exploitation/tools/lsassy.mdmarkdown2.8 KB
references/post-exploitation/tools/mimikatz.mdmarkdown4.2 KB
references/post-exploitation/tools/powershell-empire.mdmarkdown4.0 KB
references/post-exploitation/tools/powersploit.mdmarkdown5.5 KB
references/post-exploitation/tools/proxychains.mdmarkdown2.1 KB
references/post-exploitation/tools/pspy.mdmarkdown2.8 KB
references/post-exploitation/tools/pwncat.mdmarkdown6.4 KB
references/post-exploitation/tools/sliver.mdmarkdown1.4 KB
references/post-exploitation/tools/sshuttle.mdmarkdown3.2 KB
references/post-exploitation/tools/winpeas.mdmarkdown3.0 KB
references/reporting/README.mdmarkdown2.5 KB
references/reporting/tools/pandoc.mdmarkdown3.2 KB
references/reporting/tools/report-template.mdmarkdown8.5 KB
references/reverse-engineering/README.mdmarkdown5.6 KB
references/reverse-engineering/tools/apktool.mdmarkdown1.8 KB
references/reverse-engineering/tools/binwalk.mdmarkdown3.0 KB
references/reverse-engineering/tools/checksec.mdmarkdown3.5 KB
references/reverse-engineering/tools/dex2jar.mdmarkdown3.2 KB
references/reverse-engineering/tools/frida.mdmarkdown2.4 KB
references/reverse-engineering/tools/ghidra-headless.mdmarkdown3.0 KB
references/reverse-engineering/tools/jadx.mdmarkdown2.2 KB
references/reverse-engineering/tools/ldd.mdmarkdown1.9 KB
references/reverse-engineering/tools/nm.mdmarkdown2.3 KB
references/reverse-engineering/tools/objdump.mdmarkdown2.5 KB
references/reverse-engineering/tools/objection.mdmarkdown3.0 KB
references/reverse-engineering/tools/rabin2.mdmarkdown2.3 KB
references/reverse-engineering/tools/radare2.mdmarkdown1.3 KB
references/reverse-engineering/tools/readelf.mdmarkdown2.3 KB
references/reverse-engineering/tools/ropper.mdmarkdown4.1 KB
references/reverse-engineering/tools/strings.mdmarkdown2.3 KB
references/reverse-engineering/tools/xxd.mdmarkdown2.3 KB
references/rfid-nfc/README.mdmarkdown2.7 KB
references/rfid-nfc/tools/libnfc.mdmarkdown2.2 KB

references/playbooks/api-security.md

View on GitHub
# API 安全 Playbook

用于授权的 GraphQL、OpenAPI/REST、gRPC、WebSocket 或 API 密集型 Web 应用测试。

## 输入

- API base URL、schema/规范、示例请求、Postman 集合或捕获的流量。
- 认证方式、测试账号、令牌刷新行为,以及租户/角色边界。
- 速率限制、不安全方法、破坏性端点和 fuzzing 授权。

## 流程

1. **清单与分类**
   - 识别 API 类型:OpenAPI/REST、GraphQL、gRPC、WebSocket、SOAP 或混合类型。
   - 收集 schema、端点、认证请求头、角色和代表性请求。
   - 对 API 密集型 Web 应用,将本 playbook 与 `web-application.md` 联合使用。

2. **被动映射**
   - 即使有 API 文档,也要至少捕获一次认证会话并与文档交叉对比。
   - 使用捕获的流量、`mitmproxy`(参见 `../web/tools/mitmproxy.md`)、`mitmproxy2swagger`(参见 `../web/tools/mitmproxy2swagger.md`)、爬虫和现有文档。
   - 仅从有代表性的授权流量中恢复 OpenAPI 定义。

   ```bash
   mitmdump -w /tmp/api.flows
   mitmproxy2swagger -i /tmp/api.flows -o /tmp/openapi.yaml -p https://api.example.com
   ```

3. **协议专项发现**
   - GraphQL:使用 `graphw00f`(参见 `../web/tools/graphw00f.md`)指纹识别;仅在获批时用 `clairvoyance`(参见 `../web/tools/clairvoyance.md`)尝试 schema 恢复。
   - REST/OpenAPI:使用 `kiterunner`(参见 `../web/tools/kiterunner.md`)做 API 路由发现,使用 `schemathesis`(参见 `../web/tools/schemathesis.md`)做 schema 驱动测试。
   - gRPC:使用 `grpcurl`(参见 `../web/tools/grpcurl.md`),配合反射或提供的 `.proto` 文件。
   - WebSocket:捕获有效消息后使用 `websocat`(参见 `../web/tools/websocat.md`)。

   - 如果签名阻止了工具执行,推迟到代理构建完成后再执行。记录到 `todo.txt`:`[DEFER] Phase 3 — resume after proxy`。

   (Web 和 API 工具选择参见 `../web/README.md`。)
   ```bash
   # kiterunner — API 路由发现
   kr scan <target-url> -w /path/to/routes.kite -A=apiroutes-240328

   # schemathesis — schema 驱动测试
   st run https://target/openapi.json --checks all --url https://target

   # grpcurl — 通过反射进行服务枚举
   grpcurl -plaintext <target>:50051 list
   grpcurl -plaintext <target>:50051 describe <service>

   # websocat — WebSocket 测试
   websocat ws://<target>/ws
   ```

4. **API 文档驱动覆盖**(如有 API 规格文档、Swagger/OpenAPI 文档或开发文档)
   - 解析文档提取完整端点列表,包含方法、参数和预期输入类型。
   - 用此列表衡量测试覆盖率——不要仅依赖字典发现。
   - 确保每个有用户可控输入的文档端点都被测试注入、授权和业务逻辑缺陷。
   - 将 ffuf/kiterunner 发现与文档交叉对比,识别未文档化端点(影子 API)。

5. **客户端签名与请求保护**(当直接 API 请求返回签名错误、设备校验失败或不透明拒绝码时执行)
   - **绕过测试**(始终首先执行):测试签名验证能否被绕过——发送畸形、空值或固定的签名值。如果验证较弱,将绕过记录为发现并直接推进,无需构建签名代理。
      - **绕过成功:** 自动化工具可立即使用。执行下方的自动化基线门控,将绕过值作为静态 header 注入(如 `-H "X-Signature: "`)。然后进入第 6 阶段。
      - **绕过失败:** 完成下方所有步骤,然后通过代理执行自动化基线门控,再进入第 6 阶段。记录到 `decisions.txt`:`[PROXY_BUILT] <approach> — verified: yes`。
        - 定位前端应用(SPA JavaScript bundle、移动应用或 SDK),提取:签名算法及输入、必需的自定义请求头、公钥或共享密钥、API 常量。即使有 API 文档,仍需获取并分析前端 JS——文档描述规格,JS 反映实际实现。两者的差异是高价值发现。(二进制/JS 分析工具选择参见 `../reverse-engineering/README.md`。)

          ```bash
          curl -sk https://<frontend-host>/main.js -o /tmp/main.js
          grep -iE '(signature|sign|hmac|sha1|sha256|x-sign|x-timestamp)' /tmp/main.js
          grep -iE '(encrypt|decrypt|aes|rsa|pub.?key|iv|cipher)' /tmp/main.js
          grep -iE '(app.?id|client.?id|api.?key|secret|host|base.?url)' /tmp/main.js
          ```
        - 实现签名脚本,确认签名请求成功后再继续。
        - **加密请求/响应处理**:如果 API 响应为 base64 编码的二进制而非明文 JSON,从前端代码或 API 文档中识别加密方案,构建加密/解密函数,确认解密后的响应与预期 JSON 一致后再继续。后续所有阶段的请求必须经过加密层。
        - **代理成本评估**:构建完整 mitmproxy addon 前,先枚举所有文档端点的用户可控参数。存在以下任一情况则必须构建完整代理:自由文本字段、文件上传、复杂嵌套 JSON body、接受任意字符串的路径参数。仅当所有参数均为枚举类型、数字 ID 或固定格式字符串时,`sqlmap --eval` / 手工测试才足够。将决策记录到 `decisions.txt`:`[PROXY_DECISION] injectable params: <count/types> — decision: <full proxy / sqlmap --eval / manual> — reason: <why>`。
        - 选择代理方案前,查阅 `../web/README.md` 中的决策树——它将常见签名方案映射到具体工具推荐。
        - **代理实现方式**(从轻到重):
          - `sqlmap --eval` 内联签名计算——适合简单签名场景。
          - 本地 HTTP 服务:接收明文请求,用自定义协议包装后转发,返回解密后的响应。
          - `mitmproxy` 插件脚本:双向加密处理。
        - **签名代理快速启动**(根据目标调整算法和请求头):

          ```python
          # /tmp/sign_addon.py
          import hashlib, time, uuid
          from mitmproxy import http

          TOKEN = open("/tmp/access_token.txt").read().strip()

          def request(flow: http.HTTPFlow):
              ts = str(int(time.time()))
              rid = str(uuid.uuid4())
              url = flow.request.pretty_url
              sig = hashlib.sha1((url + " " + ts + " " + rid).encode()).hexdigest()
              flow.request.headers["X-Timestamp"] = ts
              flow.request.headers["X-Request-Id"] = rid
              flow.request.headers["X-Signature"] = sig
              flow.request.headers["Cookie"] = "session_token=" + TOKEN
          ```

          ```bash
          mitmdump -s /tmp/sign_addon.py --listen-port 8080 --set ssl_insecure=true --set http2=false &
          # 验证: curl -sk -x http://127.0.0.1:8080 https://target/endpoint
          ```

          目标验证混合大小写自定义头时必须使用 `--set http2=false`。sqlmap 配合 `--technique=BEUS` 跳过时间盲注(每次请求的时间戳变化会干扰基线)。详见 `../web/tools/mitmproxy.md`。

        - 构建代理后,验证一个请求返回非 401,然后执行自动化基线门控。代理不兼容的工具(nikto)通过工具自身的请求头参数直接注入认证头。

   - **自动化基线门控**(必须执行——无论绕过成功还是代理路径,进入第 6 阶段前必须完成):

     | 工具 | 用途 | 路由方式 |
     |------|------|---------|
     | `nuclei` | 已知 CVE 和配置错误扫描 | 代理或直接注入静态认证头 |
     | `ffuf` | API 路径发现(SecLists `api/endpoints.txt` + `common.txt`) | 代理 |
     | `sqlmap` | 所有带参数端点的注入测试 | 代理;使用 `--technique=BEUS` 跳过时间盲注 |
     | `dalfox` 或 `xsstrike` | 反射参数的 XSS 检测 | 代理 |

     - 绕过成功时:直接注入静态绕过头(如 `-H "X-Signature: <bypass_value>"`)。
     - 代理已构建时:所有工具通过代理路由(`--proxy=http://127.0.0.1:8080`)。
     - 代理不兼容的工具(nikto):通过工具自身参数注入认证头(`-Add-header`)。

     记录到 `decisions.txt`:`[BASELINE_COMPLETE] tools: nuclei/ffuf/sqlmap/dalfox — date: <date>`

6. **认证和授权检查**
   - 测试缺失认证、令牌复用、角色/租户边界、对象级授权和方法限制。
   - 为每个测试角色保留请求/响应证据。
   - 具体检查项和工具:
     - **JWT**:测试 `alg:none`、弱 HS256 密钥、`kid` 请求头注入——使用 `jwt_tool`(参见 `../web/tools/jwt_tool.md`)`<token> -M pb` 进行 playbook 扫描,然后使用 `jwt_tool <token> -M at` 执行所有测试。如果令牌格式不是 JWT(不透明令牌、UUID 格式、会话 ID),记录到 `decisions.txt`:`[N/A] jwt_tool — reason: token format is <format>, not JWT`。
     - **BOLA / IDOR**:用另一测试账号的 ID 替换对象 ID(用户 ID、资源 ID);确认隔离。
     - **功能级授权缺失**:用低权限令牌调用仅管理员可访问的端点(如 `DELETE /users/<id>`、`/admin/*`)。
     - **Mass assignment**:在 POST/PUT 请求体中发送应为只读的额外字段(如 `role`、`is_admin`)。
     - **令牌泄露**:检查错误响应、调试请求头和日志中是否包含凭据材料。
     - 所有跨角色测试均通过 `mitmproxy` 或 ZAP 路由,以捕获完整请求/响应对作为证据。

   **端点 × 角色授权矩阵(必须执行):** 构建每个端点与每个测试角色的显式矩阵。逐项测试——不要假设如果一个管理端点阻止了低权限用户,所有管理端点都会阻止。记录每格的结果(允许 / 拒绝 / 错误)。未测试的格子是覆盖缺口,不是通过。

   **凭据发现处理:** 在 API 测试过程中发现凭据(JWT 密钥、错误响应中的 API Key、调试请求头中的令牌、Schema 示例中的硬编码凭据)时,立即在所有已发现的 API 端点和认证服务上测试,然后再继续下一测试阶段。

   **多平台认证传递方式:** 同一 API 可能对不同客户端平台接受不同的认证传递方式——Web 端使用 Cookie、移动端使用 Authorization 请求头、第三方集成使用 API Key 请求头、回调使用查询参数。当任何认证方式返回 401 或认证错误时,系统性地测试所有备选传递方式,再得出该端点需要特定方式的结论。检查 API 文档、前端代码和 SDK 示例中是否有平台专属的认证说明。

   ```bash
   # JWT 审计 — 先进行 playbook 扫描,再执行所有测试
   jwt_tool <token> -M pb
   jwt_tool <token> -M at
   # 以不同角色重放请求
   mitmdump -s /tmp/swap_auth.py -r /tmp/api.flows
   ```

7. **测试数据准备**(如测试账号缺少行使 API 端点所需的业务对象)
   - 回顾第 1 阶段的 API 清单,识别需要特定资源才能测试的端点(如创建组织、加入群组、发布内容、上传文件、建立账号间关系)。
   - 利用 API 文档或已发现的创建端点,构建扩大可测试面所需的最小业务对象集合。
   - 使用各测试角色创建资源以建立跨角色测试场景(如角色 A 拥有资源,角色 B 尝试访问该资源,用于第 8 阶段的 BOLA 测试)。
   - 记录所有已创建资源(ID、类型、使用的端点),用于测试后清理和第 8 阶段的 IDOR 测试。

8. **主动测试**

   **前置检查(阻断性):**
   1. 确认自动化基线门控已完成——`decisions.txt` 中包含 `[BASELINE_COMPLETE]`。如果没有:立即返回执行。
   2. 如果在第 5 阶段中构建了签名代理或签名脚本,用一个测试请求验证代理返回非 401 响应后再继续。
   3. 本阶段所有自动化工具必须通过代理路由(代理不兼容的工具通过直接注入请求头)。

   主动测试是核心漏洞评估阶段。将其分解为多个专项子阶段。

   8.1. **输入验证与注入**
   - 测试 API 参数的 SQL 注入、NoSQL 注入、命令注入、LDAP 注入和 XML 外部实体(XXE)攻击。
   - 使用 `sqlmap`(参见 `../web/tools/sqlmap.md`)配合 API 专项选项:将代表性请求保存到文件并运行 `sqlmap -r request.txt --batch`;对 JSON 请求体使用 `--data` 并配合正确的 `--headers="Content-Type: application/json"`。
   - 通过 URL 和文件参数测试 SSRF——提供内部地址(`http://169.254.169.254/`、`http://127.0.0.1:<port>`)并观察响应。
   - 对所有输入向量(路径、查询、请求头、请求体)进行 fuzzing,使用类型边界和编码绕过 payload。

   **逐参数注入覆盖:** 不要仅对每个端点测试一个代表性请求。对每个端点,识别所有可注入参数(路径、查询、请求头、请求体字段)并针对适用的注入类型逐一测试。当 sqlmap 在默认设置下报告无发现时,需提升到 `--level=5 --risk=3` 后才可接受阴性结果。

   ```bash
   # API SQL 注入(使用保存的请求)
   sqlmap -r /tmp/api_request.txt --batch --level=3 --risk=2
   # JSON 请求体注入
   sqlmap -u "https://api.example.com/v1/search" --data='{"query":"test"}' --headers="Content-Type: application/json" --batch
   ```

   8.2. **业务逻辑与速率限制**
   - 测试敏感端点的速率限制:登录、密码重置、OTP 验证、账号创建。
   - 测试分页滥用:负偏移量、零或过大页面大小、非数字页面参数。
   - 测试状态变更操作的竞态条件(余额转账、优惠券兑换),通过发送并发请求进行验证。
   - 在所有已识别的对象引用中测试 IDOR——枚举 ID、UUID 和顺序标识符。

   8.3. **GraphQL 专项攻击**(如在第 1 阶段或第 3 阶段检测到 GraphQL)
   - 批量查询滥用:在单个请求中发送查询数组以绕过速率限制。
   - 别名 DoS:在多个别名下重复同一高开销字段。
   - 嵌套查询深度攻击:提交深度嵌套查询(`{a{b{c{d{...}}}}}`)以测试深度限制。
   - 字段建议滥用:使用拼写错误从错误消息中提取有效字段名。
   - 指令注入:测试自定义或重复指令是否引发意外行为。
   - 当自省被禁用时,参考 `clairvoyance` 进行 schema 恢复。

   8.4. **错误处理与信息泄露**
   - 使用畸形输入触发错误:无效类型、超大 payload、空字节、意外编码。
   - 检查响应中是否包含堆栈跟踪、调试端点、内部路径泄露和详细错误消息。
   - 探测请求头、错误响应体和 `/debug` 或 `/status` 端点中的 API 版本信息泄露。
   - 测试已认证与未认证请求之间的不同错误行为。

   报告前手工验证所有发现——API 扫描器经常暴露 schema 不匹配,而不一定是可利用问题。

   8.5. **CORS 错误配置测试**
   - 测试过度宽松的 CORS 策略是否允许任意来源读取 API 响应。
   - 发送带有伪造 `Origin` 请求头的请求,检查响应中的 `Access-Control-Allow-Origin` 和 `Access-Control-Allow-Credentials`。
   - 测试是否接受 null origin 以及带凭据的通配符。
   - 如果预检(OPTIONS)与实际请求的 CORS 行为不一致,记录差异并进一步测试:用触发预检 CORS 头的同一 Origin 发送实际请求、测试不同 HTTP 方法、检查 `Access-Control-Max-Age` 缓存是否导致浏览器使用缓存的预检权限。

   ```bash
   # 使用任意来源测试 CORS
   curl -s -H "Origin: https://evil.com" -I https://api.example.com/v1/endpoint | grep -i "access-control"
   # 测试 null origin
   curl -s -H "Origin: null" -I https://api.example.com/v1/endpoint | grep -i "access-control"
   # 测试带凭据标志
   curl -s -H "Origin: https://evil.com" -H "Cookie: session=TOKEN" -I https://api.example.com/v1/endpoint | grep -i "access-control"
   ```

9. **API 版本控制与弃用端点**
   - 测试旧版 API(`/v1/`、`/v2/`)是否缺少当前版本中存在的安全控制。
   - 检查文档中未列出的影子或僵尸 API 端点——使用 `kiterunner` 配合历史字典。
   - 比较不同 API 版本之间的认证执行、输入验证和速率限制。
   - 记录所有仍可访问且缺乏当前保护的弃用端点。

## 交叉引用

- `internal-network.md` — 当 API 位于需要更广泛评估的内网时。
- `external-attack-surface.md` — 通过子域和端口枚举发现更多 API 端点。
- `password-audit.md` — 用于破解 JWT 密钥、API 密钥或捕获的凭据。
- `source-code-audit.md` — 当 API 源代码可用于端点和认证逻辑静态分析时。
- `web-application.md` — WebSocket 和通用 Web 测试。
- `post-exploitation.md` — 当确认的 API 漏洞导致获取 shell 时;利用路径选择另见 `../exploitation/README.md`。
- `../reverse-engineering/README.md` — 当需要分析前端 JS 以提取签名或加密逻辑时。
- `reporting-workflow.md` — 报告结构和交付。

## 预期产物

- 按协议和 base URL 整理的 API 清单。
- Schema/规范、恢复的规范和代表性请求样本。
- 按角色和端点整理的认证矩阵。
- fuzzing 和路由发现结果,并记录速率限制。
- 测试数据清单:已创建资源、ID、创建端点和清理计划。

## 停止条件

进入报告前,验证每个检查项。任何检查项未通过则返回相关阶段。

1. **端点发现:** 如果有 API 文档,至少 80% 有用户可控输入的文档端点已被探测。列出跳过的端点及理由。

2. **逐端点测试深度:** 对每个可访问端点(非 404),确认以下维度在适用时均已覆盖。端点只有在所有适用维度完成后才算"已测试":
   - 用 API 支持的每种认证方式测试——不是只用第一个成功的方式。
   - 含资源 ID 的端点用其他用户/资源的 ID 测试(IDOR),不仅是测试者自己的。
   - 每个用户可控字段都用注入 payload 测试——不是每个端点只测一个代表性字段。
   - 参数用边界值测试(0、负数、空、超长、null、类型不匹配)。

3. **授权矩阵:** 端点 × 角色矩阵已完成,无未测试的格子。每个格子记录:允许 / 拒绝 / 错误。

4. **横切测试完成:** 认证方式间的交互测试、敏感操作的速率限制测试、旧版 API 与当前版本的安全控制对比。

5. **工具利用:** 所有经过代理/包装器适配的自动化工具已通过适配层重新运行。如果 API 要求自定义签名,确认 nuclei 和 ffuf 已通过签名代理执行,nikto 已通过 `-Add-header` 直接注入认证头运行——对签名 API 的未认证运行不计入覆盖率。此项对应第 5 阶段与第 6 阶段之间的自动化基线门控——如果该门控未执行,此项不通过。

如果某个检查项因范围限制(破坏性操作、缺少测试账号、功能未部署)无法满足,明确记录缺口而非静默通过。
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall