Tushar-Jain21/apistrike
GitHub: Tushar-Jain21/apistrike
一款模块化、AI 辅助的开源 API 自动化渗透测试框架,全面覆盖 OWASP API Top 10 (2023) 并内置带外检测与本地 LLM 分析能力。
Stars: 0 | Forks: 0
# APIStrike ⚔️
[](https://github.com/Tushar-Jain21/apistrike/actions/workflows/ci.yml)
[](https://github.com/Tushar-Jain21/apistrike/releases/latest)
[](LICENSE)
[](https://www.python.org/)
[](tests/)
[-1f6feb.svg)](https://owasp.org/API-Security/editions/2023/en/0x00-introduction/)
## ✨ 为什么选择 APIStrike
- **全面的 OWASP API Top 10 (2023) 覆盖** — 专用的确定性模块涵盖 API1–API5、API7–API9,以及 Injection 和 GraphQL;API6/API10 为 AI 辅助。
- **AI 提出建议,引擎进行确认** — AI 层仅负责*规划、分类和叙述*。每个报告的发现都由**真实的 HTTP 请求**验证;AI 从不创建或修改发现结果。
- **无需付费基础设施** — 内置 **OAST listener** 用于带外 SSRF 检测(无需 Burp Collaborator / interactsh),并内置 **本地 Ollama** LLM(离线、私有),具备优雅的启发式降级方案。
- **证据是安全的** — 密钥、凭证和 PII 在发现结果和报告中会被**掩码/脱敏**处理。
- **可复现且跨平台** — 纯 Python 核心(Linux / macOS / Windows-WSL2),强化的 Docker 镜像,以及用于一键运行的 `Makefile`。
- **经 CI 验证** — 每次推送都会运行完整的测试套件 + 实时的 VAmPI 扫描;可选的工作流可启动整个 crAPI 技术栈。
- **可扩展** — 插件 API 允许第三方将模块作为独立的 pip 包发布,且无需修改核心代码。
## 🧩 OWASP API Security Top 10 (2023) 覆盖范围
| OWASP ID | 风险 | 命令 | 深度 |
|---|---|---|---|
| API1:2023 | Broken Object Level Authorization (BOLA) | `bola` | 深度 |
| API2:2023 | Broken Authentication | `scan -u -p` (broken-auth) | 深度 |
| API3:2023 | Broken Object Property Level Auth (mass assignment) | `massassign` | 深度 |
| API3:2023 | Excessive Data Exposure | `dataexpose` | 深度 |
| API4:2023 | Unrestricted Resource Consumption | `ratelimit` | 深度 |
| API5:2023 | Broken Function Level Authorization (BFLA) | `bfla` | 深度 |
| API6:2023 | Unrestricted Access to Sensitive Business Flows | `ai-plan` (咨询性) | 部分 + AI |
| API7:2023 | Server-Side Request Forgery (SSRF) | `ssrf` | 深度 |
| API8:2023 | Security Misconfiguration | `misconfig` | 深度 |
| API9:2023 | Improper Inventory Management | `inventory`, `crawl` | 深度 |
| API10:2023 | Unsafe Consumption of APIs | `ai-plan` (咨询性) | 部分 + AI |
| — | Injection (SQLi / NoSQLi / OS-command) | `inject` | 深度 |
| — | GraphQL (introspection / batching / …) | `graphql` | 深度 |
## 🚀 安装
### 从源码安装(推荐用于本地运行)
```
git clone https://github.com/Tushar-Jain21/apistrike.git
cd apistrike
python3 -m venv venv && source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python -m apistrike version
```
### 使用 Docker(在任何地方实现一致的运行)
```
make build # build the image
make scan # one-command scan (see Makefile for variables)
```
## ⚡ 快速开始
```
# 1. 创建一个 authorized-scope 文件并对其进行编辑,仅列出你可以测试的目标
python -m apistrike init-scope # writes scope.yaml from scope.example.yaml
# 2. 针对实验环境运行一次 authenticated scan(:5000 端口上的 VAmPI)
python -m apistrike scan http://localhost:5000 --scope scope.yaml -u name1 -p pass1
# 3. 根据 findings 数据库渲染报告
python -m apistrike report -f html # or -f pdf / -f md
# 4. (可选)AI 增强报告 — exec summary、叙述、exploit chains
python -m apistrike ai-report -f html
```
运行单个模块,例如 improper-inventory / 暴露的面:
```
python -m apistrike inventory http://localhost:5000 --scope scope.yaml
```
**crAPI**(identity 字段为 `email`,网关位于 `:8888`):
```
python -m apistrike scan http://localhost:8888 --scope scope.yaml \
-u you@example.com -p 'Str1ke_P@ss' \
--login-path /identity/api/auth/login --login-field email
```
👉 **包含示例的完整命令参考:[docs/CHEATSHEET.md](docs/CHEATSHEET.md)**
## 📄 报告
发现结果存储在本地 SQLite 数据库(`findings.db`)中,包含 OWASP + CWE 映射,然后按需渲染:
- `report` — 基于发现数据库的确定性 Markdown / HTML / PDF。
- `ai-report` — 同上,加上由 LLM 撰写的执行摘要、每个发现的影响叙述以及检测到的利用链(在没有可用模型时降级为模板文本)。
证据值(密钥、令牌、密码、PII)在写入发现或报告之前始终会被掩码处理。
## 🤖 AI 层(模型无关,本地优先)
- **Provider 接口** — 默认使用本地 **Ollama** 模型(`--model`, `--ollama-url`);`NoOp`/启发式降级方案确保每个 AI 命令在离线状态下可用。
- **AI Planner** (`ai-plan`) — 从解析的 OpenAPI spec 中对风险最高的 endpoint 进行排序。
- **AI Analyst** — 对确认的发现进行误报审查 + 利用链分析。
- **AI Reporter** (`ai-report`) — 执行摘要、叙述、修复建议。
- **严格护栏:** AI 提出建议 → 确定性引擎发起真实请求 → 仅报告经确认的结果。
## 🧪 测试、CI 与实验室
- **230 项测试** (`pytest`)。
- **`.github/workflows/ci.yml`** — 每次推送/PR 时:完整的测试套件,真实的 Docker 镜像构建 + entrypoint 冒烟测试,以及针对 VAmPI(`erev0s/vampi`)的**实时扫描**,并将 `report.html`/`report.pdf` + `findings.db` 作为 artifact 上传。
- **`.github/workflows/crapi.yml`** — 可选(手动触发 + 每周定时任务):启动完整的 crAPI 技术栈,植入一个用户,运行未经身份验证的扫描 + 经过身份验证的扫描,并上传报告和发现数据库。
验证亮点:在 crAPI 上,APIStrike 在 `/.env` 处确认了一起**真实的高危 `.env` 凭证泄露**(Postgres + Mongo 凭证)——这是一个经过内容验证的真阳性——且在 SSRF/GraphQL/数据暴露检查中零误报。
## 🔌 插件 API
将您自己的模块作为独立的 pip 包发布 — 无需更改核心代码:
```
python -m apistrike run-module --list # list built-in + plugin modules
python -m apistrike run-module misconfig http://localhost:5000 --scope scope.yaml
python -m apistrike run-module my-module http://localhost:5000 -o key=value -o foo=bar
```
通过 `apistrike.modules` entry-point 组进行注册(参见 `CONTRIBUTING.md`)。
## 📁 项目结构
```
apistrike/
├─ apistrike/ # package: cli.py, core/, recon/, auth/, modules/, ai/, reporting/, plugins/
├─ tests/ # pytest suite (230 tests)
├─ labs/ # docker-compose for crAPI / VAmPI
├─ scripts/ # crAPI seed/scope helpers, SecLists fetch
├─ docs/ # CHEATSHEET.md and design notes
├─ .github/workflows/ # ci.yml, crapi.yml
├─ scope.example.yaml # authorized-targets template
├─ Dockerfile Makefile requirements.txt
└─ README.md CHANGELOG.md CONTRIBUTING.md LICENSE
```
## 🔒 道德与范围
APIStrike 是一款防御/教育工具。强制性的 `scope.yaml` 白名单会限制每一个请求,破坏性动词需要 `--active` 标志,并且该工具会拒绝任何超出您明确授权主机范围的请求。**您有责任确保已获得测试目标的权限。**
## 📜 许可证
[MIT](LICENSE) © Tushar Jain
| ⚠️ **仅限授权使用。** 仅对您拥有或获得明确授权测试的系统(您自己的实验室、允许自动化的范围内的漏洞赏金项目或签署的合同)运行 APIStrike。必需的 `scope.yaml` 白名单会限制**每一个**请求——任何超出范围的请求都会被拒绝,并且破坏性测试受显式 `--active` 标志控制。仅供授权、防御和教育用途。 |
标签:AI辅助, AI风险缓解, API安全, CISA项目, JSON输出, OAST, OWASP API Top 10, Python, 安全规则引擎, 无后门, 渗透测试框架, 请求拦截, 调试插件, 逆向工具, 防御