opencode-api-security-testing 1.1.0 → 2.1.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 +39 -34
- package/package.json +1 -1
- package/src/index.ts +394 -106
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,56 @@ npm install opencode-api-security-testing
|
|
|
18
18
|
}
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
##
|
|
21
|
+
## Agents (4个)
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
| Agent | 模式 | 描述 |
|
|
24
|
+
|-------|------|------|
|
|
25
|
+
| `@api-cyber-supervisor` | Primary | 编排者,协调完整扫描流程,永不停止 |
|
|
26
|
+
| `@api-probing-miner` | Subagent | 漏洞挖掘专家 |
|
|
27
|
+
| `@api-resource-specialist` | Subagent | 资源探测专家 |
|
|
28
|
+
| `@api-vuln-verifier` | Subagent | 漏洞验证专家 |
|
|
24
29
|
|
|
25
|
-
|
|
26
|
-
@cyber-supervisor 对 https://example.com 进行 API 安全测试
|
|
27
|
-
```
|
|
30
|
+
## Tools (10个)
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
| Tool | 功能 | 调用方式 |
|
|
33
|
+
|------|------|---------|
|
|
34
|
+
| `api_security_scan` | 完整 API 安全扫描 | `api_security_scan target="url"` |
|
|
35
|
+
| `api_fuzz_test` | API 模糊测试 | `api_fuzz_test endpoint="url"` |
|
|
36
|
+
| `browser_collect` | 浏览器采集动态内容 | `browser_collect url="url"` |
|
|
37
|
+
| `js_parse` | JavaScript 文件解析 | `js_parse file_path="/path/to/file.js"` |
|
|
38
|
+
| `graphql_test` | GraphQL 安全测试 | `graphql_test endpoint="url"` |
|
|
39
|
+
| `cloud_storage_test` | 云存储安全测试 | `cloud_storage_test bucket_url="url"` |
|
|
40
|
+
| `vuln_verify` | 漏洞验证 | `vuln_verify vuln_type="sqli" endpoint="url"` |
|
|
41
|
+
| `sqli_test` | SQL 注入测试 | `sqli_test endpoint="url" param="id"` |
|
|
42
|
+
| `idor_test` | IDOR 越权测试 | `idor_test endpoint="url" resource_id="1"` |
|
|
43
|
+
| `auth_test` | 认证安全测试 | `auth_test endpoint="url"` |
|
|
44
|
+
|
|
45
|
+
## 使用方式
|
|
46
|
+
|
|
47
|
+
### 方式一:使用 Agent(推荐)
|
|
32
48
|
|
|
33
49
|
```
|
|
34
|
-
@
|
|
50
|
+
@api-cyber-supervisor 对 https://example.com 进行全面安全测试
|
|
35
51
|
```
|
|
36
52
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### cyber-supervisor
|
|
40
|
-
**赛博监工** - 永不停止任何线索,自动循环执行,遇到失败自动委派 probing-miner 和 resource-specialist 进行探测。
|
|
53
|
+
### 方式二:使用 Skill
|
|
41
54
|
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
```
|
|
56
|
+
skill({ name: "api-security-testing" })
|
|
57
|
+
```
|
|
44
58
|
|
|
45
|
-
###
|
|
46
|
-
**资源探测专家** - 专注于采集和发现 API 端点,使用动态和静态分析技术提取所有可能的攻击面。
|
|
59
|
+
### 方式三:直接使用 Tool
|
|
47
60
|
|
|
48
|
-
|
|
61
|
+
```
|
|
62
|
+
api_security_scan target="https://example.com" scan_type="full"
|
|
63
|
+
```
|
|
49
64
|
|
|
50
|
-
|
|
65
|
+
## 依赖
|
|
51
66
|
|
|
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 安全测试 |
|
|
67
|
+
Python 依赖会自动安装。也可手动安装:
|
|
68
|
+
```bash
|
|
69
|
+
pip install -r skills/api-security-testing/requirements.txt
|
|
70
|
+
```
|
|
66
71
|
|
|
67
72
|
## 重要
|
|
68
73
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -2,105 +2,287 @@ import type { Plugin } from "@opencode-ai/plugin";
|
|
|
2
2
|
import { tool } from "@opencode-ai/plugin";
|
|
3
3
|
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
4
4
|
import { join } from "path";
|
|
5
|
+
import { existsSync } from "fs";
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
+
const SKILL_DIR = "skills/api-security-testing";
|
|
8
|
+
const CORE_DIR = `${SKILL_DIR}/core`;
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
function getSkillPath(ctx: { directory: string }): string {
|
|
11
|
+
return join(ctx.directory, SKILL_DIR);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function getCorePath(ctx: { directory: string }): string {
|
|
15
|
+
return join(ctx.directory, CORE_DIR);
|
|
16
|
+
}
|
|
9
17
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
function checkDeps(ctx: { directory: string }): string {
|
|
19
|
+
const skillPath = getSkillPath(ctx);
|
|
20
|
+
const reqFile = join(skillPath, "requirements.txt");
|
|
21
|
+
if (existsSync(reqFile)) {
|
|
22
|
+
return `pip install -q -r "${reqFile}" 2>/dev/null; `;
|
|
23
|
+
}
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
14
26
|
|
|
15
|
-
|
|
27
|
+
const CYBER_SUPERVISOR_PROMPT = `你是 API 安全测试的**赛博监工**,代号"P9"。
|
|
16
28
|
|
|
17
|
-
|
|
18
|
-
- api_fuzz: 对特定端点进行模糊测试
|
|
19
|
-
- browser_collect: 使用浏览器采集动态内容
|
|
20
|
-
- vuln_verify: 验证漏洞是否存在
|
|
21
|
-
- cloud_storage_test: 测试云存储安全
|
|
22
|
-
- graphql_test: GraphQL 安全测试
|
|
29
|
+
## 核心能力
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
你指挥完整的安全测试行动,协调多个专家子 agent 并行工作。
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
↓
|
|
28
|
-
进度追踪 → 压力升级(L1-L4) → 永不停止
|
|
33
|
+
## 可用子 Agent
|
|
29
34
|
|
|
30
|
-
|
|
35
|
+
| 子 Agent | 职责 | 调用方式 |
|
|
36
|
+
|---------|------|---------|
|
|
37
|
+
| @api-probing-miner | 漏洞挖掘 | delegate_task(subagent_type="api-probing-miner") |
|
|
38
|
+
| @api-resource-specialist | 端点发现 | delegate_task(subagent_type="api-resource-specialist") |
|
|
39
|
+
| @api-vuln-verifier | 漏洞验证 | delegate_task(subagent_type="api-vuln-verifier") |
|
|
31
40
|
|
|
32
|
-
|
|
33
|
-
- IDOR: references/vulnerabilities/04-idor-tests.md
|
|
34
|
-
- JWT 漏洞: references/vulnerabilities/03-jwt-tests.md
|
|
35
|
-
- 敏感数据: references/vulnerabilities/05-sensitive-data-tests.md
|
|
36
|
-
- 认证漏洞: references/vulnerabilities/10-auth-tests.md
|
|
37
|
-
- GraphQL: references/vulnerabilities/11-graphql-tests.md
|
|
38
|
-
- SSRF: references/vulnerabilities/12-ssrf-tests.md`;
|
|
41
|
+
## 可用工具
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
直接调用以下工具执行特定任务:
|
|
44
|
+
|
|
45
|
+
| 工具 | 用途 | 场景 |
|
|
46
|
+
|------|------|------|
|
|
47
|
+
| api_security_scan | 完整扫描 | 全面测试 |
|
|
48
|
+
| api_fuzz_test | 模糊测试 | 发现未知端点 |
|
|
49
|
+
| browser_collect | 浏览器采集 | SPA 应用 |
|
|
50
|
+
| js_parse | JS 分析 | 提取 API 模式 |
|
|
51
|
+
| vuln_verify | 漏洞验证 | 确认发现 |
|
|
52
|
+
| graphql_test | GraphQL 测试 | GraphQL 端点 |
|
|
53
|
+
| cloud_storage_test | 云存储测试 | OSS/S3 |
|
|
54
|
+
| idor_test | IDOR 测试 | 越权漏洞 |
|
|
55
|
+
| sqli_test | SQLi 测试 | 注入漏洞 |
|
|
56
|
+
|
|
57
|
+
## 测试流程
|
|
58
|
+
|
|
59
|
+
### Phase 1: 侦察
|
|
60
|
+
1. browser_collect 采集动态端点
|
|
61
|
+
2. js_parse 分析 JS 文件
|
|
62
|
+
3. url_discover 发现隐藏端点
|
|
63
|
+
|
|
64
|
+
### Phase 2: 分析
|
|
65
|
+
1. 识别技术栈
|
|
66
|
+
2. 分析认证机制
|
|
67
|
+
3. 标记敏感端点
|
|
68
|
+
|
|
69
|
+
### Phase 3: 挖掘
|
|
70
|
+
1. 并行测试多种漏洞
|
|
71
|
+
2. 使用专业工具 (sqli_test, idor_test, etc.)
|
|
72
|
+
3. 验证每个发现
|
|
73
|
+
|
|
74
|
+
### Phase 4: 报告
|
|
75
|
+
生成结构化 Markdown 报告
|
|
76
|
+
|
|
77
|
+
## 输出格式
|
|
78
|
+
|
|
79
|
+
\`\`\`markdown
|
|
80
|
+
# API 安全测试报告
|
|
81
|
+
|
|
82
|
+
## 目标
|
|
83
|
+
- URL: {target}
|
|
84
|
+
- 日期: {date}
|
|
85
|
+
|
|
86
|
+
## 执行摘要
|
|
87
|
+
- 端点总数: {count}
|
|
88
|
+
- 发现漏洞: {vuln_count}
|
|
89
|
+
- Critical: {n}
|
|
90
|
+
- High: {n}
|
|
91
|
+
- Medium: {n}
|
|
92
|
+
- Low: {n}
|
|
93
|
+
|
|
94
|
+
## 漏洞详情
|
|
95
|
+
### {vuln_name}
|
|
96
|
+
- **严重程度**: {severity}
|
|
97
|
+
- **端点**: {endpoint}
|
|
98
|
+
- **PoC**: \`{poc}\`
|
|
99
|
+
- **修复建议**: {fix}
|
|
100
|
+
\`\`\`
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
const PROBING_MINER_PROMPT = `你是**API漏洞挖掘专家**,专注于发现和验证安全漏洞。
|
|
41
104
|
|
|
42
105
|
## 职责
|
|
43
106
|
|
|
44
|
-
1. **针对性测试** -
|
|
45
|
-
2.
|
|
46
|
-
3.
|
|
107
|
+
1. **针对性测试** - 根据端点特征选择最佳方法
|
|
108
|
+
2. **快速验证** - 确认漏洞存在
|
|
109
|
+
3. **PoC 生成** - 提供可执行的测试命令
|
|
110
|
+
|
|
111
|
+
## 测试方法库
|
|
112
|
+
|
|
113
|
+
### SQL 注入
|
|
114
|
+
- 布尔盲注: ' OR 1=1 --
|
|
115
|
+
- 联合查询: ' UNION SELECT NULL--
|
|
116
|
+
- 错误注入: ' AND 1=CONVERT(int,...)--
|
|
117
|
+
- 时间盲注: '; WAITFOR DELAY '00:00:05'--
|
|
118
|
+
|
|
119
|
+
### IDOR
|
|
120
|
+
- 替换 ID: /api/user/1 → /api/user/2
|
|
121
|
+
- 水平越权测试
|
|
122
|
+
- 垂直越权测试
|
|
123
|
+
|
|
124
|
+
### JWT
|
|
125
|
+
- 空算法: alg: none
|
|
126
|
+
- 密钥混淆: HS256 → HS256
|
|
127
|
+
- 无签名验证
|
|
128
|
+
|
|
129
|
+
### 敏感数据
|
|
130
|
+
- 响应中的密码/密钥
|
|
131
|
+
- PII 信息泄露
|
|
132
|
+
- 调试端点
|
|
47
133
|
|
|
48
134
|
## 可用工具
|
|
49
135
|
|
|
50
|
-
-
|
|
51
|
-
-
|
|
136
|
+
- sqli_test: SQL 注入测试
|
|
137
|
+
- idor_test: IDOR 测试
|
|
52
138
|
- vuln_verify: 漏洞验证
|
|
53
|
-
-
|
|
54
|
-
|
|
139
|
+
- api_fuzz_test: 模糊测试
|
|
140
|
+
|
|
141
|
+
## 输出格式
|
|
55
142
|
|
|
56
|
-
|
|
143
|
+
\`\`\`
|
|
144
|
+
## 发现漏洞
|
|
57
145
|
|
|
58
|
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
146
|
+
### {type}
|
|
147
|
+
- **端点**: {endpoint}
|
|
148
|
+
- **方法**: {method}
|
|
149
|
+
- **严重程度**: {severity}
|
|
150
|
+
- **PoC**: \`{command}\`
|
|
151
|
+
- **状态**: {status}
|
|
152
|
+
\`\`\`
|
|
153
|
+
`;
|
|
63
154
|
|
|
64
|
-
const RESOURCE_SPECIALIST_PROMPT =
|
|
155
|
+
const RESOURCE_SPECIALIST_PROMPT = `你是**API资源探测专家**,专注于发现和采集 API 端点。
|
|
65
156
|
|
|
66
157
|
## 职责
|
|
67
158
|
|
|
68
|
-
1.
|
|
69
|
-
2.
|
|
70
|
-
3.
|
|
159
|
+
1. **全面发现** - 不遗漏任何端点
|
|
160
|
+
2. **动态采集** - 拦截真实请求
|
|
161
|
+
3. **静态分析** - 提取 API 模式
|
|
162
|
+
|
|
163
|
+
## 采集技术
|
|
164
|
+
|
|
165
|
+
### 1. 浏览器动态采集
|
|
166
|
+
\`\`\`javascript
|
|
167
|
+
browser_collect(url="https://target.com")
|
|
168
|
+
// 拦截 XHR/Fetch
|
|
169
|
+
// 触发交互
|
|
170
|
+
\`\`\`
|
|
171
|
+
|
|
172
|
+
### 2. JS 静态分析
|
|
173
|
+
- 解析 JS 文件
|
|
174
|
+
- 提取 API 路径
|
|
175
|
+
- 识别参数模式
|
|
176
|
+
|
|
177
|
+
### 3. 目录探测
|
|
178
|
+
- /api/v1/*, /graphql
|
|
179
|
+
- /swagger, /api-docs
|
|
180
|
+
- /.well-known/*
|
|
71
181
|
|
|
72
182
|
## 可用工具
|
|
73
183
|
|
|
74
|
-
- browser_collect:
|
|
75
|
-
- js_parse:
|
|
76
|
-
-
|
|
184
|
+
- browser_collect: 浏览器采集
|
|
185
|
+
- js_parse: JS 文件解析
|
|
186
|
+
- api_fuzz_test: 端点探测
|
|
77
187
|
|
|
78
|
-
##
|
|
188
|
+
## 端点分类
|
|
189
|
+
|
|
190
|
+
| 风险 | 类型 | 示例 |
|
|
191
|
+
|------|------|------|
|
|
192
|
+
| 高 | 认证 | /login, /oauth/* |
|
|
193
|
+
| 高 | 数据 | /api/*/list, /search |
|
|
194
|
+
| 中 | 用户 | /users, /profile |
|
|
195
|
+
| 极高 | 管理 | /admin, /manage |
|
|
79
196
|
|
|
80
|
-
|
|
81
|
-
使用 Playwright 打开页面,拦截所有 XHR/Fetch 请求
|
|
197
|
+
## 输出格式
|
|
82
198
|
|
|
83
|
-
|
|
84
|
-
|
|
199
|
+
\`\`\`
|
|
200
|
+
## 端点发现报告
|
|
201
|
+
|
|
202
|
+
- 总数: {count}
|
|
203
|
+
- 高风险: {high}
|
|
204
|
+
- 中风险: {medium}
|
|
205
|
+
- 低风险: {low}
|
|
206
|
+
|
|
207
|
+
### 高风险端点
|
|
208
|
+
1. {method} {path} - {reason}
|
|
209
|
+
\`\`\`
|
|
210
|
+
`;
|
|
211
|
+
|
|
212
|
+
const VULN_VERIFIER_PROMPT = `你是**漏洞验证专家**,专注于验证和确认安全漏洞。
|
|
213
|
+
|
|
214
|
+
## 职责
|
|
85
215
|
|
|
86
|
-
|
|
87
|
-
|
|
216
|
+
1. **快速验证** - 确认漏洞是否存在
|
|
217
|
+
2. **风险评估** - 判断实际影响
|
|
218
|
+
3. **PoC 生成** - 提供可执行的证明
|
|
219
|
+
|
|
220
|
+
## 验证流程
|
|
221
|
+
|
|
222
|
+
1. 构造 payload
|
|
223
|
+
2. 发送测试请求
|
|
224
|
+
3. 分析响应
|
|
225
|
+
4. 判断结果
|
|
226
|
+
5. 生成 PoC
|
|
227
|
+
|
|
228
|
+
## 输出格式
|
|
229
|
+
|
|
230
|
+
\`\`\`
|
|
231
|
+
## 验证结果
|
|
232
|
+
|
|
233
|
+
**漏洞类型**: {type}
|
|
234
|
+
**端点**: {endpoint}
|
|
235
|
+
**验证状态**: CONFIRMED / INVALID / UNCERTAIN
|
|
236
|
+
**严重程度**: Critical / High / Medium / Low / Info
|
|
237
|
+
|
|
238
|
+
### 测试步骤
|
|
239
|
+
1. {step}
|
|
240
|
+
|
|
241
|
+
### PoC
|
|
242
|
+
\`\`\`bash
|
|
243
|
+
{command}
|
|
244
|
+
\`\`\`
|
|
245
|
+
|
|
246
|
+
### 修复建议
|
|
247
|
+
{fix}
|
|
248
|
+
\`\`\`
|
|
249
|
+
`;
|
|
250
|
+
|
|
251
|
+
export function createApiSecurityAgent(
|
|
252
|
+
name: string,
|
|
253
|
+
description: string,
|
|
254
|
+
prompt: string,
|
|
255
|
+
mode: "primary" | "subagent" = "subagent",
|
|
256
|
+
color?: string
|
|
257
|
+
): AgentConfig {
|
|
258
|
+
return {
|
|
259
|
+
description,
|
|
260
|
+
mode,
|
|
261
|
+
prompt,
|
|
262
|
+
color,
|
|
263
|
+
permission: {
|
|
264
|
+
bash: "*",
|
|
265
|
+
edit: "ask",
|
|
266
|
+
webfetch: "allow",
|
|
267
|
+
},
|
|
268
|
+
};
|
|
269
|
+
}
|
|
88
270
|
|
|
89
271
|
const ApiSecurityTestingPlugin: Plugin = async (ctx) => {
|
|
90
272
|
return {
|
|
91
273
|
tool: {
|
|
92
274
|
api_security_scan: tool({
|
|
93
|
-
description: "
|
|
275
|
+
description: "完整 API 安全扫描。参数: target(目标URL), scan_type(full/quick/targeted)",
|
|
94
276
|
args: {
|
|
95
277
|
target: tool.schema.string(),
|
|
96
278
|
scan_type: tool.schema.enum(["full", "quick", "targeted"]).optional(),
|
|
97
|
-
vulnerabilities: tool.schema.array(tool.schema.string()).optional(),
|
|
98
279
|
},
|
|
99
|
-
async execute(args,
|
|
100
|
-
const
|
|
101
|
-
const
|
|
280
|
+
async execute(args, ctx) {
|
|
281
|
+
const deps = checkDeps(ctx);
|
|
282
|
+
const corePath = getCorePath(ctx);
|
|
283
|
+
const cmd = `${deps}python3 -c "
|
|
102
284
|
import sys
|
|
103
|
-
sys.path.insert(0, '
|
|
285
|
+
sys.path.insert(0, '${corePath}')
|
|
104
286
|
from deep_api_tester_v55 import DeepAPITesterV55
|
|
105
287
|
tester = DeepAPITesterV55(target='${args.target}', headless=True)
|
|
106
288
|
results = tester.run_test()
|
|
@@ -112,16 +294,17 @@ print(results)
|
|
|
112
294
|
}),
|
|
113
295
|
|
|
114
296
|
api_fuzz_test: tool({
|
|
115
|
-
description: "
|
|
297
|
+
description: "API 模糊测试。参数: endpoint(端点URL), method(HTTP方法)",
|
|
116
298
|
args: {
|
|
117
299
|
endpoint: tool.schema.string(),
|
|
118
300
|
method: tool.schema.enum(["GET", "POST", "PUT", "DELETE", "PATCH"]).optional(),
|
|
119
301
|
},
|
|
120
|
-
async execute(args,
|
|
121
|
-
const
|
|
122
|
-
const
|
|
302
|
+
async execute(args, ctx) {
|
|
303
|
+
const deps = checkDeps(ctx);
|
|
304
|
+
const corePath = getCorePath(ctx);
|
|
305
|
+
const cmd = `${deps}python3 -c "
|
|
123
306
|
import sys
|
|
124
|
-
sys.path.insert(0, '
|
|
307
|
+
sys.path.insert(0, '${corePath}')
|
|
125
308
|
from api_fuzzer import APIFuzzer
|
|
126
309
|
fuzzer = APIFuzzer('${args.endpoint}')
|
|
127
310
|
results = fuzzer.fuzz(method='${args.method || 'GET'}')
|
|
@@ -133,20 +316,21 @@ print(results)
|
|
|
133
316
|
}),
|
|
134
317
|
|
|
135
318
|
vuln_verify: tool({
|
|
136
|
-
description: "
|
|
319
|
+
description: "漏洞验证。参数: vuln_type(漏洞类型), endpoint(端点)",
|
|
137
320
|
args: {
|
|
138
321
|
vuln_type: tool.schema.string(),
|
|
139
322
|
endpoint: tool.schema.string(),
|
|
140
323
|
evidence: tool.schema.string().optional(),
|
|
141
324
|
},
|
|
142
|
-
async execute(args,
|
|
143
|
-
const
|
|
144
|
-
const
|
|
325
|
+
async execute(args, ctx) {
|
|
326
|
+
const deps = checkDeps(ctx);
|
|
327
|
+
const corePath = getCorePath(ctx);
|
|
328
|
+
const cmd = `${deps}python3 -c "
|
|
145
329
|
import sys
|
|
146
|
-
sys.path.insert(0, '
|
|
330
|
+
sys.path.insert(0, '${corePath}')
|
|
147
331
|
from verifiers.vuln_verifier import VulnVerifier
|
|
148
332
|
verifier = VulnVerifier()
|
|
149
|
-
result = verifier.verify('${args.vuln_type}', '${args.endpoint}')
|
|
333
|
+
result = verifier.verify('${args.vuln_type}', '${args.endpoint}', '${args.evidence or ''}')
|
|
150
334
|
print(result)
|
|
151
335
|
"`;
|
|
152
336
|
const result = await ctx.$`${cmd}`;
|
|
@@ -155,16 +339,17 @@ print(result)
|
|
|
155
339
|
}),
|
|
156
340
|
|
|
157
341
|
browser_collect: tool({
|
|
158
|
-
description: "
|
|
342
|
+
description: "浏览器采集动态内容。参数: url(目标URL)",
|
|
159
343
|
args: {
|
|
160
344
|
url: tool.schema.string(),
|
|
161
345
|
wait_for: tool.schema.string().optional(),
|
|
162
346
|
},
|
|
163
|
-
async execute(args,
|
|
164
|
-
const
|
|
165
|
-
const
|
|
347
|
+
async execute(args, ctx) {
|
|
348
|
+
const deps = checkDeps(ctx);
|
|
349
|
+
const corePath = getCorePath(ctx);
|
|
350
|
+
const cmd = `${deps}python3 -c "
|
|
166
351
|
import sys
|
|
167
|
-
sys.path.insert(0, '
|
|
352
|
+
sys.path.insert(0, '${corePath}')
|
|
168
353
|
from collectors.browser_collect import BrowserCollector
|
|
169
354
|
collector = BrowserCollector(headless=True)
|
|
170
355
|
endpoints = collector.collect('${args.url}')
|
|
@@ -177,16 +362,62 @@ for ep in endpoints:
|
|
|
177
362
|
},
|
|
178
363
|
}),
|
|
179
364
|
|
|
365
|
+
js_parse: tool({
|
|
366
|
+
description: "解析 JavaScript 文件。参数: file_path(文件路径)",
|
|
367
|
+
args: {
|
|
368
|
+
file_path: tool.schema.string(),
|
|
369
|
+
},
|
|
370
|
+
async execute(args, ctx) {
|
|
371
|
+
const deps = checkDeps(ctx);
|
|
372
|
+
const corePath = getCorePath(ctx);
|
|
373
|
+
const cmd = `${deps}python3 -c "
|
|
374
|
+
import sys
|
|
375
|
+
sys.path.insert(0, '${corePath}')
|
|
376
|
+
from collectors.js_parser import JSParser
|
|
377
|
+
parser = JSParser()
|
|
378
|
+
endpoints = parser.parse_file('${args.file_path}')
|
|
379
|
+
print(f'从 JS 发现 {len(endpoints)} 个端点')
|
|
380
|
+
for ep in endpoints:
|
|
381
|
+
print(ep)
|
|
382
|
+
"`;
|
|
383
|
+
const result = await ctx.$`${cmd}`;
|
|
384
|
+
return result.toString();
|
|
385
|
+
},
|
|
386
|
+
}),
|
|
387
|
+
|
|
388
|
+
graphql_test: tool({
|
|
389
|
+
description: "GraphQL 安全测试。参数: endpoint(GraphQL端点)",
|
|
390
|
+
args: {
|
|
391
|
+
endpoint: tool.schema.string(),
|
|
392
|
+
introspection: tool.schema.boolean().optional(),
|
|
393
|
+
},
|
|
394
|
+
async execute(args, ctx) {
|
|
395
|
+
const deps = checkDeps(ctx);
|
|
396
|
+
const corePath = getCorePath(ctx);
|
|
397
|
+
const cmd = `${deps}python3 -c "
|
|
398
|
+
import sys
|
|
399
|
+
sys.path.insert(0, '${corePath}')
|
|
400
|
+
from smart_analyzer import SmartAnalyzer
|
|
401
|
+
analyzer = SmartAnalyzer()
|
|
402
|
+
result = analyzer.graphql_test('${args.endpoint}', introspection=${args.introspection ?? true})
|
|
403
|
+
print(result)
|
|
404
|
+
"`;
|
|
405
|
+
const result = await ctx.$`${cmd}`;
|
|
406
|
+
return result.toString();
|
|
407
|
+
},
|
|
408
|
+
}),
|
|
409
|
+
|
|
180
410
|
cloud_storage_test: tool({
|
|
181
|
-
description: "
|
|
411
|
+
description: "云存储安全测试。参数: bucket_url(存储桶URL)",
|
|
182
412
|
args: {
|
|
183
413
|
bucket_url: tool.schema.string(),
|
|
184
414
|
},
|
|
185
|
-
async execute(args,
|
|
186
|
-
const
|
|
187
|
-
const
|
|
415
|
+
async execute(args, ctx) {
|
|
416
|
+
const deps = checkDeps(ctx);
|
|
417
|
+
const corePath = getCorePath(ctx);
|
|
418
|
+
const cmd = `${deps}python3 -c "
|
|
188
419
|
import sys
|
|
189
|
-
sys.path.insert(0, '
|
|
420
|
+
sys.path.insert(0, '${corePath}')
|
|
190
421
|
from cloud_storage_tester import CloudStorageTester
|
|
191
422
|
tester = CloudStorageTester()
|
|
192
423
|
result = tester.full_test('${args.bucket_url}')
|
|
@@ -197,19 +428,65 @@ print(result)
|
|
|
197
428
|
},
|
|
198
429
|
}),
|
|
199
430
|
|
|
200
|
-
|
|
201
|
-
description: "
|
|
431
|
+
idor_test: tool({
|
|
432
|
+
description: "IDOR 越权测试。参数: endpoint, resource_id",
|
|
202
433
|
args: {
|
|
203
434
|
endpoint: tool.schema.string(),
|
|
435
|
+
resource_id: tool.schema.string(),
|
|
436
|
+
target_user_id: tool.schema.string().optional(),
|
|
204
437
|
},
|
|
205
|
-
async execute(args,
|
|
206
|
-
const
|
|
207
|
-
const
|
|
438
|
+
async execute(args, ctx) {
|
|
439
|
+
const deps = checkDeps(ctx);
|
|
440
|
+
const corePath = getCorePath(ctx);
|
|
441
|
+
const cmd = `${deps}python3 -c "
|
|
208
442
|
import sys
|
|
209
|
-
sys.path.insert(0, '
|
|
210
|
-
from
|
|
211
|
-
|
|
212
|
-
result =
|
|
443
|
+
sys.path.insert(0, '${corePath}')
|
|
444
|
+
from testers.idor_tester import IDORTester
|
|
445
|
+
tester = IDORTester()
|
|
446
|
+
result = tester.test('${args.endpoint}', '${args.resource_id}', '${args.target_user_id or ''}')
|
|
447
|
+
print(result)
|
|
448
|
+
"`;
|
|
449
|
+
const result = await ctx.$`${cmd}`;
|
|
450
|
+
return result.toString();
|
|
451
|
+
},
|
|
452
|
+
}),
|
|
453
|
+
|
|
454
|
+
sqli_test: tool({
|
|
455
|
+
description: "SQL 注入测试。参数: endpoint, param",
|
|
456
|
+
args: {
|
|
457
|
+
endpoint: tool.schema.string(),
|
|
458
|
+
param: tool.schema.string(),
|
|
459
|
+
},
|
|
460
|
+
async execute(args, ctx) {
|
|
461
|
+
const deps = checkDeps(ctx);
|
|
462
|
+
const corePath = getCorePath(ctx);
|
|
463
|
+
const cmd = `${deps}python3 -c "
|
|
464
|
+
import sys
|
|
465
|
+
sys.path.insert(0, '${corePath}')
|
|
466
|
+
from testers.sqli_tester import SQLiTester
|
|
467
|
+
tester = SQLiTester()
|
|
468
|
+
result = tester.test('${args.endpoint}', '${args.param}')
|
|
469
|
+
print(result)
|
|
470
|
+
"`;
|
|
471
|
+
const result = await ctx.$`${cmd}`;
|
|
472
|
+
return result.toString();
|
|
473
|
+
},
|
|
474
|
+
}),
|
|
475
|
+
|
|
476
|
+
auth_test: tool({
|
|
477
|
+
description: "认证安全测试。参数: endpoint",
|
|
478
|
+
args: {
|
|
479
|
+
endpoint: tool.schema.string(),
|
|
480
|
+
},
|
|
481
|
+
async execute(args, ctx) {
|
|
482
|
+
const deps = checkDeps(ctx);
|
|
483
|
+
const corePath = getCorePath(ctx);
|
|
484
|
+
const cmd = `${deps}python3 -c "
|
|
485
|
+
import sys
|
|
486
|
+
sys.path.insert(0, '${corePath}')
|
|
487
|
+
from testers.auth_tester import AuthTester
|
|
488
|
+
tester = AuthTester()
|
|
489
|
+
result = tester.test('${args.endpoint}')
|
|
213
490
|
print(result)
|
|
214
491
|
"`;
|
|
215
492
|
const result = await ctx.$`${cmd}`;
|
|
@@ -225,23 +502,34 @@ print(result)
|
|
|
225
502
|
config.agent = {};
|
|
226
503
|
}
|
|
227
504
|
|
|
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
|
-
|
|
505
|
+
(config.agent as Record<string, AgentConfig>)["api-cyber-supervisor"] = createApiSecurityAgent(
|
|
506
|
+
"api-cyber-supervisor",
|
|
507
|
+
"API安全测试编排者。协调完整扫描流程,永不停止。",
|
|
508
|
+
CYBER_SUPERVISOR_PROMPT,
|
|
509
|
+
"primary",
|
|
510
|
+
"#FF6B6B"
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
(config.agent as Record<string, AgentConfig>)["api-probing-miner"] = createApiSecurityAgent(
|
|
514
|
+
"api-probing-miner",
|
|
515
|
+
"漏洞挖掘专家。专注发现和验证 API 漏洞。",
|
|
516
|
+
PROBING_MINER_PROMPT,
|
|
517
|
+
"subagent"
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
(config.agent as Record<string, AgentConfig>)["api-resource-specialist"] = createApiSecurityAgent(
|
|
521
|
+
"api-resource-specialist",
|
|
522
|
+
"资源探测专家。专注采集和发现 API 端点。",
|
|
523
|
+
RESOURCE_SPECIALIST_PROMPT,
|
|
524
|
+
"subagent"
|
|
525
|
+
);
|
|
526
|
+
|
|
527
|
+
(config.agent as Record<string, AgentConfig>)["api-vuln-verifier"] = createApiSecurityAgent(
|
|
528
|
+
"api-vuln-verifier",
|
|
529
|
+
"漏洞验证专家。验证和确认安全漏洞。",
|
|
530
|
+
VULN_VERIFIER_PROMPT,
|
|
531
|
+
"subagent"
|
|
532
|
+
);
|
|
245
533
|
},
|
|
246
534
|
};
|
|
247
535
|
};
|