opencode-api-security-testing 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -36
- package/package.json +1 -1
- package/src/index.ts +385 -81
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# API Security Testing Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
OpenCode 插件,提供完整的 API 安全测试能力。
|
|
4
4
|
|
|
5
5
|
## 安装
|
|
6
6
|
|
|
@@ -18,51 +18,50 @@ npm install opencode-api-security-testing
|
|
|
18
18
|
}
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Agents (5个)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
| Agent | 角色 | 说明 |
|
|
24
|
+
|-------|------|------|
|
|
25
|
+
| `@api-cyber-supervisor` | 编排者 | 协调完整扫描流程,永不停止 |
|
|
26
|
+
| `@api-probing-miner` | 漏洞挖掘 | 专注发现和验证 API 漏洞 |
|
|
27
|
+
| `@api-resource-specialist` | 资源探测 | 专注采集和发现 API 端点 |
|
|
28
|
+
| `@api-orchestrator` | 测试编排 | 协调完整测试流程 |
|
|
29
|
+
| `@api-vuln-verifier` | 漏洞验证 | 验证和确认安全漏洞 |
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
@cyber-supervisor 对 https://example.com 进行 API 安全测试
|
|
27
|
-
```
|
|
31
|
+
## Tools (9个)
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
| Tool | 功能 |
|
|
34
|
+
|------|------|
|
|
35
|
+
| `api_security_scan` | 完整 API 安全扫描 |
|
|
36
|
+
| `api_fuzz_test` | API 模糊测试 |
|
|
37
|
+
| `vuln_verify` | 漏洞验证 |
|
|
38
|
+
| `browser_collect` | 浏览器采集动态内容 |
|
|
39
|
+
| `js_parse` | JavaScript 文件解析 |
|
|
40
|
+
| `cloud_storage_test` | 云存储安全测试 |
|
|
41
|
+
| `graphql_test` | GraphQL 安全测试 |
|
|
42
|
+
| `idor_test` | IDOR 越权测试 |
|
|
43
|
+
| `sqli_test` | SQL 注入测试 |
|
|
36
44
|
|
|
37
|
-
##
|
|
45
|
+
## 使用方式
|
|
38
46
|
|
|
39
|
-
###
|
|
40
|
-
**赛博监工** - 永不停止任何线索,自动循环执行,遇到失败自动委派 probing-miner 和 resource-specialist 进行探测。
|
|
47
|
+
### 方式一:使用 Agent
|
|
41
48
|
|
|
42
|
-
|
|
43
|
-
|
|
49
|
+
```
|
|
50
|
+
@api-cyber-supervisor 对 https://example.com 进行全面安全测试
|
|
51
|
+
```
|
|
44
52
|
|
|
45
|
-
###
|
|
46
|
-
**资源探测专家** - 专注于采集和发现 API 端点,使用动态和静态分析技术提取所有可能的攻击面。
|
|
53
|
+
### 方式二:直接使用 Tool
|
|
47
54
|
|
|
48
|
-
|
|
55
|
+
```
|
|
56
|
+
api_security_scan target="https://example.com" scan_type="full"
|
|
57
|
+
```
|
|
49
58
|
|
|
50
|
-
|
|
59
|
+
## 依赖
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
| 03-jwt-tests.md | JWT 认证测试 |
|
|
57
|
-
| 04-idor-tests.md | IDOR 越权测试 |
|
|
58
|
-
| 05-sensitive-data-tests.md | 敏感数据泄露 |
|
|
59
|
-
| 06-biz-logic-tests.md | 业务逻辑漏洞 |
|
|
60
|
-
| 07-security-config-tests.md | 安全配置漏洞 |
|
|
61
|
-
| 08-brute-force-tests.md | 暴力破解测试 |
|
|
62
|
-
| 09-vulnerability-chains.md | 漏洞关联联想 |
|
|
63
|
-
| 10-auth-tests.md | 认证漏洞测试 |
|
|
64
|
-
| 11-graphql-tests.md | GraphQL 安全测试 |
|
|
65
|
-
| 12-ssrf-tests.md | SSRF 安全测试 |
|
|
61
|
+
Python 依赖会自动安装(如果需要手动安装):
|
|
62
|
+
```bash
|
|
63
|
+
pip install -r skills/api-security-testing/requirements.txt
|
|
64
|
+
```
|
|
66
65
|
|
|
67
66
|
## 重要
|
|
68
67
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -3,101 +3,333 @@ import { tool } from "@opencode-ai/plugin";
|
|
|
3
3
|
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
4
4
|
import { join } from "path";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
function buildCyberSupervisorPrompt(): string {
|
|
7
|
+
return `你是 API 安全测试的**赛博监工**,代号"P9-渗透测试员"。
|
|
7
8
|
|
|
8
|
-
##
|
|
9
|
+
## 核心原则
|
|
9
10
|
|
|
10
11
|
1. **永不停止** - 任何线索都要追到底
|
|
11
|
-
2.
|
|
12
|
-
3.
|
|
13
|
-
4.
|
|
12
|
+
2. **自动化编排** - 不等待用户,主动推进
|
|
13
|
+
3. **智能委派** - 识别任务类型,委派给最合适的子 agent
|
|
14
|
+
4. **压力升级** - 遇到失败自动换方法 (L1-L4)
|
|
14
15
|
|
|
15
|
-
##
|
|
16
|
+
## 任务分类与委派
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
18
|
+
| 任务类型 | 委派给 | 原因 |
|
|
19
|
+
|---------|--------|------|
|
|
20
|
+
| 端点发现 | @api-resource-specialist | 专注于采集 |
|
|
21
|
+
| 漏洞挖掘 | @api-probing-miner | 专注于测试 |
|
|
22
|
+
| 深度扫描 | @api-orchestrator | 完整流程 |
|
|
23
|
+
| 单一漏洞验证 | @api-vuln-verifier | 快速验证 |
|
|
23
24
|
|
|
24
25
|
## 工作流程
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
### Phase 1: 侦察 (Recon)
|
|
28
|
+
- 使用 browser_collect 采集动态内容
|
|
29
|
+
- 使用 js_parse 分析 JavaScript
|
|
30
|
+
- 使用 url_discover 发现隐藏端点
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
### Phase 2: 分析 (Analysis)
|
|
33
|
+
- 识别 API 技术栈
|
|
34
|
+
- 分析认证机制
|
|
35
|
+
- 识别敏感端点
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
- 认证漏洞: references/vulnerabilities/10-auth-tests.md
|
|
37
|
-
- GraphQL: references/vulnerabilities/11-graphql-tests.md
|
|
38
|
-
- SSRF: references/vulnerabilities/12-ssrf-tests.md`;
|
|
37
|
+
### Phase 3: 挖掘 (Exploitation)
|
|
38
|
+
- 并行测试多种漏洞
|
|
39
|
+
- 使用 api_fuzz 进行模糊测试
|
|
40
|
+
- 使用 vuln_verify 验证发现
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
### Phase 4: 报告 (Reporting)
|
|
43
|
+
- 生成结构化报告
|
|
44
|
+
- 提供 PoC
|
|
45
|
+
- 给出修复建议
|
|
41
46
|
|
|
42
|
-
##
|
|
47
|
+
## 压力升级策略
|
|
48
|
+
|
|
49
|
+
| 失败次数 | 等级 | 行动 |
|
|
50
|
+
|---------|------|------|
|
|
51
|
+
| 2次 | L1 | 换测试方法 |
|
|
52
|
+
| 3次 | L2 | 换子 agent |
|
|
53
|
+
| 5次 | L3 | 并行多种方法 |
|
|
54
|
+
| 7次+ | L4 | 咨询用户 |
|
|
55
|
+
|
|
56
|
+
## 输出格式
|
|
57
|
+
|
|
58
|
+
完成时输出:
|
|
43
59
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
60
|
+
## 安全测试报告
|
|
61
|
+
|
|
62
|
+
### 目标信息
|
|
63
|
+
- URL: {target}
|
|
64
|
+
- 技术栈: {stack}
|
|
65
|
+
- 端点数量: {count}
|
|
66
|
+
|
|
67
|
+
### 发现漏洞
|
|
68
|
+
| # | 漏洞类型 | 端点 | 严重程度 | 状态 |
|
|
69
|
+
|---|---------|------|---------|------|
|
|
70
|
+
| 1 | SQL注入 | /api/user?id=1 | HIGH | 已验证 |
|
|
71
|
+
|
|
72
|
+
### 漏洞详情
|
|
73
|
+
对每个漏洞提供:
|
|
74
|
+
- **类型**:
|
|
75
|
+
- **端点**:
|
|
76
|
+
- **严重程度**:
|
|
77
|
+
- **PoC**:
|
|
78
|
+
- **修复建议**: `
|
|
47
79
|
|
|
48
80
|
## 可用工具
|
|
49
81
|
|
|
50
|
-
-
|
|
51
|
-
-
|
|
82
|
+
- api_security_scan: 完整扫描
|
|
83
|
+
- api_fuzz_test: 模糊测试
|
|
52
84
|
- vuln_verify: 漏洞验证
|
|
85
|
+
- browser_collect: 浏览器采集
|
|
86
|
+
- js_parse: JS 分析
|
|
53
87
|
- cloud_storage_test: 云存储测试
|
|
54
88
|
- graphql_test: GraphQL 测试
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function buildProbingMinerPrompt(): string {
|
|
93
|
+
return `你是**API漏洞挖掘专家**,专注于发现和验证 API 安全漏洞。
|
|
55
94
|
|
|
56
|
-
##
|
|
95
|
+
## 职责
|
|
96
|
+
|
|
97
|
+
1. **针对性测试** - 根据端点特征选择最佳测试方法
|
|
98
|
+
2. **漏洞验证** - 快速验证漏洞,提供 PoC
|
|
99
|
+
3. **结果记录** - 结构化输出,便于后续报告
|
|
100
|
+
|
|
101
|
+
## 漏洞类型与测试方法
|
|
102
|
+
|
|
103
|
+
### SQL 注入 (SQLi)
|
|
104
|
+
- 布尔盲注: ' OR 1=1 --
|
|
105
|
+
- 联合查询: ' UNION SELECT NULL--
|
|
106
|
+
- 错误注入: ' AND 1=CONVERT(int,...)--
|
|
107
|
+
- 时间盲注: '; WAITFOR DELAY '00:00:05'--
|
|
108
|
+
|
|
109
|
+
### IDOR (越权)
|
|
110
|
+
- 替换用户 ID
|
|
111
|
+
- 测试水平越权
|
|
112
|
+
- 测试垂直越权
|
|
113
|
+
- 检查直接对象引用
|
|
114
|
+
|
|
115
|
+
### JWT 安全
|
|
116
|
+
- 空签名算法: alg: none
|
|
117
|
+
- 密钥混淆: HS256 → HS512
|
|
118
|
+
- 无签名验证
|
|
119
|
+
- 敏感信息泄露
|
|
120
|
+
|
|
121
|
+
### 敏感数据泄露
|
|
122
|
+
- 响应中的密码
|
|
123
|
+
- API 密钥
|
|
124
|
+
- PII 信息
|
|
125
|
+
- 调试信息
|
|
126
|
+
|
|
127
|
+
### GraphQL 安全
|
|
128
|
+
- 嵌套查询: { users { posts { comments { ... } } } }
|
|
129
|
+
- introspectionQuery
|
|
130
|
+
- 批量查询绕过限速
|
|
131
|
+
|
|
132
|
+
## 输出格式
|
|
133
|
+
|
|
134
|
+
### 发现漏洞
|
|
135
|
+
|
|
136
|
+
\`\`\`
|
|
137
|
+
类型: SQL注入
|
|
138
|
+
端点: /api/user?id=1
|
|
139
|
+
方法: GET
|
|
140
|
+
参数: id=1' OR 1=1 --
|
|
141
|
+
状态: 已验证
|
|
142
|
+
严重程度: HIGH
|
|
143
|
+
PoC: curl -X GET "http://target/api/user?id=1'%20OR%201=1--"
|
|
144
|
+
\`\`\`
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function buildResourceSpecialistPrompt(): string {
|
|
149
|
+
return `你是**API资源探测专家**,专注于发现和采集 API 端点。
|
|
57
150
|
|
|
58
|
-
|
|
59
|
-
- 用户枚举: references/vulnerabilities/02-user-enum-tests.md
|
|
60
|
-
- JWT 安全: references/vulnerabilities/03-jwt-tests.md
|
|
61
|
-
- IDOR: references/vulnerabilities/04-idor-tests.md
|
|
62
|
-
- 敏感数据: references/vulnerabilities/05-sensitive-data-tests.md`;
|
|
151
|
+
## 职责
|
|
63
152
|
|
|
64
|
-
|
|
153
|
+
1. **全面发现** - 不遗漏任何端点
|
|
154
|
+
2. **动态采集** - 使用浏览器拦截真实请求
|
|
155
|
+
3. **静态分析** - 从 JS 文件提取 API 模式
|
|
156
|
+
|
|
157
|
+
## 采集技术
|
|
158
|
+
|
|
159
|
+
### 1. 浏览器动态采集
|
|
160
|
+
\`\`\`javascript
|
|
161
|
+
// 使用 browser_collect 工具
|
|
162
|
+
browser_collect(url="https://target.com")
|
|
163
|
+
// 拦截所有 XHR/Fetch 请求
|
|
164
|
+
// 触发用户交互(点击、滚动等)
|
|
165
|
+
\`\`\`
|
|
166
|
+
|
|
167
|
+
### 2. JavaScript 静态分析
|
|
168
|
+
- 解析 JS 文件
|
|
169
|
+
- 提取 API 路径模式
|
|
170
|
+
- 识别参数命名约定
|
|
171
|
+
|
|
172
|
+
### 3. 目录探测
|
|
173
|
+
常见路径:
|
|
174
|
+
- /api/v1/*, /api/v2/*
|
|
175
|
+
- /graphql, /api/graphql
|
|
176
|
+
- /swagger, /api-docs, /docs
|
|
177
|
+
- /.well-known/security.txt
|
|
178
|
+
|
|
179
|
+
### 4. 响应分析
|
|
180
|
+
- HATEOAS 链接
|
|
181
|
+
- 分页参数
|
|
182
|
+
- 错误信息中的路径
|
|
183
|
+
|
|
184
|
+
## 端点分类
|
|
185
|
+
|
|
186
|
+
| 类型 | 风险 | 示例 |
|
|
187
|
+
|------|------|------|
|
|
188
|
+
| 认证 | 高 | /login, /oauth/* |
|
|
189
|
+
| 用户 | 中 | /users, /profile |
|
|
190
|
+
| 数据 | 高 | /api/*/list, /search |
|
|
191
|
+
| 管理 | 极高 | /admin, /manage |
|
|
192
|
+
| 敏感 | 高 | /config, /internal |
|
|
193
|
+
|
|
194
|
+
## 输出格式
|
|
195
|
+
|
|
196
|
+
\`\`\`
|
|
197
|
+
端点发现报告:
|
|
198
|
+
- 总数: 42
|
|
199
|
+
- 高风险: 8
|
|
200
|
+
- 中风险: 15
|
|
201
|
+
- 低风险: 19
|
|
202
|
+
|
|
203
|
+
高风险端点:
|
|
204
|
+
1. POST /api/login - 认证绕过测试点
|
|
205
|
+
2. GET /api/users/:id - IDOR 测试点
|
|
206
|
+
3. POST /api/upload - 文件上传测试点
|
|
207
|
+
\`\`\`
|
|
208
|
+
`;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function buildOrchestratorPrompt(): string {
|
|
212
|
+
return `你是**API安全测试编排器**,负责协调完整的扫描流程。
|
|
65
213
|
|
|
66
214
|
## 职责
|
|
67
215
|
|
|
68
|
-
1.
|
|
69
|
-
2.
|
|
70
|
-
3.
|
|
216
|
+
1. **流程编排** - 按照科学顺序执行测试
|
|
217
|
+
2. **结果整合** - 汇总所有子任务结果
|
|
218
|
+
3. **报告生成** - 输出完整的测试报告
|
|
71
219
|
|
|
72
|
-
##
|
|
220
|
+
## 测试流程
|
|
73
221
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
222
|
+
### Phase 0: 前置检查
|
|
223
|
+
1. 检查依赖 (playwright, requests 等)
|
|
224
|
+
2. 验证目标可达性
|
|
225
|
+
3. 识别技术栈
|
|
77
226
|
|
|
78
|
-
|
|
227
|
+
### Phase 1: 资产发现
|
|
228
|
+
1. 端点采集 (browser_collect)
|
|
229
|
+
2. JS 分析 (js_parse)
|
|
230
|
+
3. 目录探测 (url_discover)
|
|
231
|
+
|
|
232
|
+
### Phase 2: 漏洞扫描
|
|
233
|
+
1. SQL 注入测试
|
|
234
|
+
2. IDOR 测试
|
|
235
|
+
3. JWT 测试
|
|
236
|
+
4. 敏感数据测试
|
|
237
|
+
5. GraphQL 测试
|
|
238
|
+
6. 云存储测试
|
|
79
239
|
|
|
80
|
-
###
|
|
81
|
-
|
|
240
|
+
### Phase 3: 漏洞验证
|
|
241
|
+
对每个发现进行验证
|
|
242
|
+
生成 PoC
|
|
82
243
|
|
|
83
|
-
###
|
|
84
|
-
|
|
244
|
+
### Phase 4: 报告生成
|
|
245
|
+
输出 Markdown 报告
|
|
85
246
|
|
|
86
|
-
|
|
87
|
-
|
|
247
|
+
## 报告模板
|
|
248
|
+
|
|
249
|
+
\`\`\`markdown
|
|
250
|
+
# API 安全测试报告
|
|
251
|
+
|
|
252
|
+
## 目标信息
|
|
253
|
+
- URL: {target}
|
|
254
|
+
- 日期: {date}
|
|
255
|
+
- 测试人员: Cyber Supervisor
|
|
256
|
+
|
|
257
|
+
## 执行摘要
|
|
258
|
+
- 端点数量: {count}
|
|
259
|
+
- 发现漏洞: {vuln_count}
|
|
260
|
+
- 高危: {high}
|
|
261
|
+
- 中危: {medium}
|
|
262
|
+
- 低危: {low}
|
|
263
|
+
|
|
264
|
+
## 漏洞详情
|
|
265
|
+
...
|
|
266
|
+
\`\`\`
|
|
267
|
+
`;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function buildVulnVerifierPrompt(): string {
|
|
271
|
+
return `你是**漏洞验证专家**,专注于验证和确认安全漏洞。
|
|
272
|
+
|
|
273
|
+
## 职责
|
|
274
|
+
|
|
275
|
+
1. **快速验证** - 确认漏洞是否存在
|
|
276
|
+
2. **生成 PoC** - 提供可执行的测试命令
|
|
277
|
+
3. **风险评估** - 判断实际影响
|
|
278
|
+
|
|
279
|
+
## 验证流程
|
|
280
|
+
|
|
281
|
+
1. 构造 payload
|
|
282
|
+
2. 发送测试请求
|
|
283
|
+
3. 分析响应
|
|
284
|
+
4. 判断是否成功
|
|
285
|
+
5. 生成 PoC
|
|
286
|
+
|
|
287
|
+
## 输出格式
|
|
288
|
+
|
|
289
|
+
\`\`\`
|
|
290
|
+
验证结果: [CONFIRMED/INVALID/UNCERTAIN]
|
|
291
|
+
漏洞类型: {type}
|
|
292
|
+
端点: {endpoint}
|
|
293
|
+
Payload: {payload}
|
|
294
|
+
响应: {response}
|
|
295
|
+
严重程度: {severity}
|
|
296
|
+
PoC: {poc_command}
|
|
297
|
+
修复建议: {remediation}
|
|
298
|
+
\`\`\`
|
|
299
|
+
`;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function createApiSecurityAgent(
|
|
303
|
+
name: string,
|
|
304
|
+
description: string,
|
|
305
|
+
promptBuilder: () => string,
|
|
306
|
+
mode: "primary" | "subagent" = "subagent"
|
|
307
|
+
): AgentConfig {
|
|
308
|
+
return {
|
|
309
|
+
description,
|
|
310
|
+
mode,
|
|
311
|
+
prompt: promptBuilder(),
|
|
312
|
+
permission: {
|
|
313
|
+
bash: "*",
|
|
314
|
+
edit: "ask",
|
|
315
|
+
webfetch: "allow",
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
}
|
|
88
319
|
|
|
89
320
|
const ApiSecurityTestingPlugin: Plugin = async (ctx) => {
|
|
321
|
+
const skillPath = join(ctx.directory, "skills/api-security-testing");
|
|
322
|
+
|
|
90
323
|
return {
|
|
91
324
|
tool: {
|
|
92
325
|
api_security_scan: tool({
|
|
93
|
-
description: "
|
|
326
|
+
description: "完整 API 安全扫描。参数: target(必填), scan_type(full/quick/targeted), vulnerabilities(可选漏洞类型数组)",
|
|
94
327
|
args: {
|
|
95
328
|
target: tool.schema.string(),
|
|
96
329
|
scan_type: tool.schema.enum(["full", "quick", "targeted"]).optional(),
|
|
97
330
|
vulnerabilities: tool.schema.array(tool.schema.string()).optional(),
|
|
98
331
|
},
|
|
99
332
|
async execute(args, context) {
|
|
100
|
-
const skillPath = join(context.directory, "skills/api-security-testing");
|
|
101
333
|
const cmd = `cd ${skillPath} && pip install -q -r requirements.txt 2>/dev/null; python3 -c "
|
|
102
334
|
import sys
|
|
103
335
|
sys.path.insert(0, 'core')
|
|
@@ -112,13 +344,12 @@ print(results)
|
|
|
112
344
|
}),
|
|
113
345
|
|
|
114
346
|
api_fuzz_test: tool({
|
|
115
|
-
description: "
|
|
347
|
+
description: "API 模糊测试。参数: endpoint(必填), method(HTTP方法)",
|
|
116
348
|
args: {
|
|
117
349
|
endpoint: tool.schema.string(),
|
|
118
350
|
method: tool.schema.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).optional(),
|
|
119
351
|
},
|
|
120
352
|
async execute(args, context) {
|
|
121
|
-
const skillPath = join(context.directory, "skills/api-security-testing");
|
|
122
353
|
const cmd = `cd ${skillPath} && python3 -c "
|
|
123
354
|
import sys
|
|
124
355
|
sys.path.insert(0, 'core')
|
|
@@ -133,14 +364,13 @@ print(results)
|
|
|
133
364
|
}),
|
|
134
365
|
|
|
135
366
|
vuln_verify: tool({
|
|
136
|
-
description: "
|
|
367
|
+
description: "漏洞验证。参数: vuln_type(漏洞类型), endpoint(端点), evidence(可选)",
|
|
137
368
|
args: {
|
|
138
369
|
vuln_type: tool.schema.string(),
|
|
139
370
|
endpoint: tool.schema.string(),
|
|
140
371
|
evidence: tool.schema.string().optional(),
|
|
141
372
|
},
|
|
142
373
|
async execute(args, context) {
|
|
143
|
-
const skillPath = join(context.directory, "skills/api-security-testing");
|
|
144
374
|
const cmd = `cd ${skillPath} && python3 -c "
|
|
145
375
|
import sys
|
|
146
376
|
sys.path.insert(0, 'core')
|
|
@@ -155,13 +385,12 @@ print(result)
|
|
|
155
385
|
}),
|
|
156
386
|
|
|
157
387
|
browser_collect: tool({
|
|
158
|
-
description: "
|
|
388
|
+
description: "浏览器采集。参数: url(必填), wait_for(可选)",
|
|
159
389
|
args: {
|
|
160
390
|
url: tool.schema.string(),
|
|
161
391
|
wait_for: tool.schema.string().optional(),
|
|
162
392
|
},
|
|
163
393
|
async execute(args, context) {
|
|
164
|
-
const skillPath = join(context.directory, "skills/api-security-testing");
|
|
165
394
|
const cmd = `cd ${skillPath} && python3 -c "
|
|
166
395
|
import sys
|
|
167
396
|
sys.path.insert(0, 'core')
|
|
@@ -177,13 +406,31 @@ for ep in endpoints:
|
|
|
177
406
|
},
|
|
178
407
|
}),
|
|
179
408
|
|
|
409
|
+
js_parse: tool({
|
|
410
|
+
description: "JavaScript 文件解析。参数: file_path(文件路径)",
|
|
411
|
+
args: {
|
|
412
|
+
file_path: tool.schema.string(),
|
|
413
|
+
},
|
|
414
|
+
async execute(args, context) {
|
|
415
|
+
const cmd = `cd ${skillPath} && python3 -c "
|
|
416
|
+
import sys
|
|
417
|
+
sys.path.insert(0, 'core')
|
|
418
|
+
from collectors.js_parser import JSParser
|
|
419
|
+
parser = JSParser()
|
|
420
|
+
endpoints = parser.parse_file('${args.file_path}')
|
|
421
|
+
print(f'发现 {len(endpoints)} 个 API 端点')
|
|
422
|
+
"`;
|
|
423
|
+
const result = await ctx.$`${cmd}`;
|
|
424
|
+
return result.toString();
|
|
425
|
+
},
|
|
426
|
+
}),
|
|
427
|
+
|
|
180
428
|
cloud_storage_test: tool({
|
|
181
|
-
description: "
|
|
429
|
+
description: "云存储安全测试。参数: bucket_url(存储桶URL)",
|
|
182
430
|
args: {
|
|
183
431
|
bucket_url: tool.schema.string(),
|
|
184
432
|
},
|
|
185
433
|
async execute(args, context) {
|
|
186
|
-
const skillPath = join(context.directory, "skills/api-security-testing");
|
|
187
434
|
const cmd = `cd ${skillPath} && python3 -c "
|
|
188
435
|
import sys
|
|
189
436
|
sys.path.insert(0, 'core')
|
|
@@ -197,13 +444,12 @@ print(result)
|
|
|
197
444
|
},
|
|
198
445
|
}),
|
|
199
446
|
|
|
200
|
-
|
|
201
|
-
description: "
|
|
447
|
+
graphql_test: tool({
|
|
448
|
+
description: "GraphQL 安全测试。参数: endpoint(GraphQL端点)",
|
|
202
449
|
args: {
|
|
203
450
|
endpoint: tool.schema.string(),
|
|
204
451
|
},
|
|
205
452
|
async execute(args, context) {
|
|
206
|
-
const skillPath = join(context.directory, "skills/api-security-testing");
|
|
207
453
|
const cmd = `cd ${skillPath} && python3 -c "
|
|
208
454
|
import sys
|
|
209
455
|
sys.path.insert(0, 'core')
|
|
@@ -211,6 +457,47 @@ from smart_analyzer import SmartAnalyzer
|
|
|
211
457
|
analyzer = SmartAnalyzer()
|
|
212
458
|
result = analyzer.graphql_test('${args.endpoint}')
|
|
213
459
|
print(result)
|
|
460
|
+
"`;
|
|
461
|
+
const result = await ctx.$`${cmd}`;
|
|
462
|
+
return result.toString();
|
|
463
|
+
},
|
|
464
|
+
}),
|
|
465
|
+
|
|
466
|
+
idor_test: tool({
|
|
467
|
+
description: "IDOR 越权测试。参数: endpoint, resource_id, target_user_id",
|
|
468
|
+
args: {
|
|
469
|
+
endpoint: tool.schema.string(),
|
|
470
|
+
resource_id: tool.schema.string(),
|
|
471
|
+
target_user_id: tool.schema.string().optional(),
|
|
472
|
+
},
|
|
473
|
+
async execute(args, context) {
|
|
474
|
+
const cmd = `cd ${skillPath} && python3 -c "
|
|
475
|
+
import sys
|
|
476
|
+
sys.path.insert(0, 'core')
|
|
477
|
+
from testers.idor_tester import IDORTester
|
|
478
|
+
tester = IDORTester()
|
|
479
|
+
result = tester.test('${args.endpoint}', '${args.resource_id}')
|
|
480
|
+
print(result)
|
|
481
|
+
"`;
|
|
482
|
+
const result = await ctx.$`${cmd}`;
|
|
483
|
+
return result.toString();
|
|
484
|
+
},
|
|
485
|
+
}),
|
|
486
|
+
|
|
487
|
+
sqli_test: tool({
|
|
488
|
+
description: "SQL 注入测试。参数: endpoint, param",
|
|
489
|
+
args: {
|
|
490
|
+
endpoint: tool.schema.string(),
|
|
491
|
+
param: tool.schema.string(),
|
|
492
|
+
},
|
|
493
|
+
async execute(args, context) {
|
|
494
|
+
const cmd = `cd ${skillPath} && python3 -c "
|
|
495
|
+
import sys
|
|
496
|
+
sys.path.insert(0, 'core')
|
|
497
|
+
from testers.sqli_tester import SQLiTester
|
|
498
|
+
tester = SQLiTester()
|
|
499
|
+
result = tester.test('${args.endpoint}', '${args.param}')
|
|
500
|
+
print(result)
|
|
214
501
|
"`;
|
|
215
502
|
const result = await ctx.$`${cmd}`;
|
|
216
503
|
return result.toString();
|
|
@@ -225,23 +512,40 @@ print(result)
|
|
|
225
512
|
config.agent = {};
|
|
226
513
|
}
|
|
227
514
|
|
|
228
|
-
(config.agent as Record<string, AgentConfig>)["cyber-supervisor"] =
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
515
|
+
(config.agent as Record<string, AgentConfig>)["api-cyber-supervisor"] = createApiSecurityAgent(
|
|
516
|
+
"api-cyber-supervisor",
|
|
517
|
+
"API安全测试编排者。协调完整扫描流程,永不停止,主动推进。",
|
|
518
|
+
buildCyberSupervisorPrompt,
|
|
519
|
+
"primary"
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
(config.agent as Record<string, AgentConfig>)["api-probing-miner"] = createApiSecurityAgent(
|
|
523
|
+
"api-probing-miner",
|
|
524
|
+
"漏洞挖掘专家。专注发现和验证 API 漏洞。",
|
|
525
|
+
buildProbingMinerPrompt,
|
|
526
|
+
"subagent"
|
|
527
|
+
);
|
|
528
|
+
|
|
529
|
+
(config.agent as Record<string, AgentConfig>)["api-resource-specialist"] = createApiSecurityAgent(
|
|
530
|
+
"api-resource-specialist",
|
|
531
|
+
"资源探测专家。专注采集和发现 API 端点。",
|
|
532
|
+
buildResourceSpecialistPrompt,
|
|
533
|
+
"subagent"
|
|
534
|
+
);
|
|
535
|
+
|
|
536
|
+
(config.agent as Record<string, AgentConfig>)["api-orchestrator"] = createApiSecurityAgent(
|
|
537
|
+
"api-orchestrator",
|
|
538
|
+
"测试编排器。协调完整测试流程。",
|
|
539
|
+
buildOrchestratorPrompt,
|
|
540
|
+
"subagent"
|
|
541
|
+
);
|
|
542
|
+
|
|
543
|
+
(config.agent as Record<string, AgentConfig>)["api-vuln-verifier"] = createApiSecurityAgent(
|
|
544
|
+
"api-vuln-verifier",
|
|
545
|
+
"漏洞验证专家。验证和确认安全漏洞。",
|
|
546
|
+
buildVulnVerifierPrompt,
|
|
547
|
+
"subagent"
|
|
548
|
+
);
|
|
245
549
|
},
|
|
246
550
|
};
|
|
247
551
|
};
|