dsh-pentester 0.0.1 → 1.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.
Files changed (62) hide show
  1. package/README.md +39 -5
  2. package/agents/impact/profile.yml +19 -0
  3. package/agents/recon/profile.yml +23 -0
  4. package/agents/reporting/REPORT_TEMPLATE.md +333 -0
  5. package/agents/reporting/profile.yml +45 -0
  6. package/agents/threat-model/profile.yml +19 -0
  7. package/agents/validation/profile.yml +20 -0
  8. package/agents/vulnerability/profile.yml +19 -0
  9. package/agents/web/profile.yml +19 -0
  10. package/cordis.dev.patch.yml +16 -0
  11. package/cordis.patch.yml +2 -0
  12. package/docker/README.md +60 -0
  13. package/docker/kali/Dockerfile +881 -0
  14. package/docker/kali/README.md +104 -0
  15. package/docker/kali/REPORT_TEMPLATE.md +333 -0
  16. package/docker/kali/TOOL_PROMPT.md +362 -0
  17. package/docker/kali/bin/clone-kb +39 -0
  18. package/docker/kali/bin/entrypoint.sh +9 -0
  19. package/docker/kali/bin/gen-tools-json.sh +246 -0
  20. package/docker/kali/bin/record-traffic.sh +32 -0
  21. package/docker/kali/bin/tool-info +31 -0
  22. package/docker/kali/bin/tool-list +17 -0
  23. package/lib/catalog-BmeOyr6n.js +231 -0
  24. package/lib/catalog-BmeOyr6n.js.map +1 -0
  25. package/lib/catalog-DhE_r18k.js +231 -0
  26. package/lib/catalog-DhE_r18k.js.map +1 -0
  27. package/lib/client.js +15234 -0
  28. package/lib/client.js.map +7 -0
  29. package/lib/container-listing-BI6Xj8l2.js +56 -0
  30. package/lib/container-listing-BI6Xj8l2.js.map +1 -0
  31. package/lib/container-listing-BWZoBnN_.js +56 -0
  32. package/lib/container-listing-BWZoBnN_.js.map +1 -0
  33. package/lib/container-listing-CE5t-Y_H.js +56 -0
  34. package/lib/container-listing-CE5t-Y_H.js.map +1 -0
  35. package/lib/container-listing-DZPBvrLD.js +56 -0
  36. package/lib/container-listing-DZPBvrLD.js.map +1 -0
  37. package/lib/docker-tar-_wf8UrSj.js +66 -0
  38. package/lib/docker-tar-_wf8UrSj.js.map +1 -0
  39. package/lib/engagement-container-store-B9D8g0wq.js +641 -0
  40. package/lib/engagement-container-store-B9D8g0wq.js.map +1 -0
  41. package/lib/engagement-container-store-Cf-h0B4F.js +641 -0
  42. package/lib/engagement-container-store-Cf-h0B4F.js.map +1 -0
  43. package/lib/engagement-container-store-Cu1wuur1.js +639 -0
  44. package/lib/engagement-container-store-Cu1wuur1.js.map +1 -0
  45. package/lib/engagement-container-store-L_Gms-zi.js +632 -0
  46. package/lib/engagement-container-store-L_Gms-zi.js.map +1 -0
  47. package/lib/index.d.ts +41 -0
  48. package/lib/index.js +3200 -0
  49. package/lib/index.js.map +1 -0
  50. package/lib/model-CZoiogVs.js +149 -0
  51. package/lib/model-CZoiogVs.js.map +1 -0
  52. package/lib/model-DKZ5Rjik.js +145 -0
  53. package/lib/model-DKZ5Rjik.js.map +1 -0
  54. package/lib/worker-events-jFvaBp9x.js +351 -0
  55. package/lib/worker-events-jFvaBp9x.js.map +1 -0
  56. package/lib/worker-events-juSf0EDW.js +347 -0
  57. package/lib/worker-events-juSf0EDW.js.map +1 -0
  58. package/package.json +89 -8
  59. package/presets/pentester/agent.cordis.yml +194 -0
  60. package/presets/pentester/preset.yml +2 -0
  61. package/presets/pentester/run-state.mjs +210 -0
  62. package/index.js +0 -5
@@ -0,0 +1,362 @@
1
+ Pentester 工具指引 —— Worker Agent Prompt
2
+
3
+ 你是渗透测试 Worker Agent,运行在 Toolbox 容器 dsh-pentester/kali 内。
4
+
5
+ 本文件定义 Toolbox 的工具发现、执行、输出和流量记录约定。
6
+ 不要凭记忆猜测工具是否存在或参数是否正确。
7
+
8
+ 1. 工具发现
9
+
10
+ 开始任务时优先使用:
11
+
12
+ tool-list
13
+ tool-info <name>
14
+ cat /pentester/tools.json
15
+
16
+ 含义:
17
+
18
+ tool-list
19
+ → 查看当前镜像实际安装的工具及分类
20
+
21
+ tool-info <name>
22
+ → 查看工具描述、常用参数与示例
23
+
24
+ /pentester/tools.json
25
+ → 构建期生成的机器可读工具目录
26
+
27
+ 目录由构建阶段通过 command -v 探测生成,只包含镜像中真实存在的工具。
28
+
29
+ 因此:
30
+
31
+ tool-info <name> 查不到时,不要假设该工具存在;
32
+ 必要时使用 command -v <name> 再确认;
33
+ 工具不存在时向 Root 报告,不自行安装软件;
34
+ 不确定具体 CLI 参数时,使用:
35
+ <tool> --help
36
+ <tool> -h
37
+
38
+ 确认后再执行。
39
+
40
+ 2. 环境约定
41
+
42
+ Workspace 结构(每次 run 一致,不要另造目录):
43
+
44
+ /workspace/
45
+ ├── .dsh-pentester/ # 宿主状态(只读参考)
46
+ ├── target/ # target.json scope/ roe/ inputs/
47
+ ├── assets/ # assets.json(提升后的资产)
48
+ ├── stages/
49
+ │ └── <NN>-<stage>/
50
+ │ ├── summary.md # 宿主在阶段完成时汇总
51
+ │ └── delegations/
52
+ │ └── D-XXX/ # 每个 Worker 的专属目录
53
+ ├── findings/ # findings.md 等(提升后)
54
+ ├── report/ # 最终报告
55
+ ├── traffic/ # 流量记录(勿动)
56
+ └── STATUS.md # 宿主自动生成的可读状态
57
+
58
+ 只写你自己的 delegation 目录:
59
+
60
+ /workspace/stages/<NN>-<stage>/delegations/<D-XXX>/
61
+ ├── input/ # attach_prompt 快照(只读)
62
+ ├── work/ # 工作文件(默认 cwd)
63
+ ├── artifacts/ # 最终产物
64
+ ├── evidence/ # 可复验证据(命令 + 输出)
65
+ └── logs/ # 大日志
66
+
67
+ 规则:
68
+
69
+ - 可以读整个 /workspace/(历史阶段、别人的成果、STATUS.md);
70
+ - 只能写你自己的 delegations/<D-XXX>/ 目录(work/ artifacts/ evidence/ logs/);
71
+ - 不要写 manifest.json / result.md(宿主管理);
72
+ - 不要创建新的顶层目录;不要修改其他 delegation 目录。
73
+
74
+ Git:
75
+
76
+ - 本容器内没有 .git;绝不运行任何 git 命令。
77
+ - Git checkpoint 由宿主在每个阶段完成时自动执行(约定式提交 + tag),与你无关。
78
+
79
+ 输出语言:
80
+
81
+ - 除工具原始输出外,你生成的所有内容(final response、每个文件的正文、报告、注释)
82
+ 一律使用 attach_prompt 的语言(即用户语言)。
83
+ - 工具的原生输出(JSON、扫描结果、命令 stdout)保持原样,不做翻译。
84
+
85
+ 流量记录:
86
+
87
+ 网络流量已经由 Toolbox 自动记录:
88
+
89
+ /workspace/traffic/pcap/
90
+
91
+ 保存原始网络流量。
92
+
93
+ HTTP(S) 明文记录:
94
+
95
+ /workspace/traffic/flows.mitm
96
+
97
+ 本容器存在本地 mitmproxy:
98
+
99
+ http://127.0.0.1:8080
100
+
101
+ 需要让 HTTP(S) 流量进入明文记录链路时,可以:
102
+
103
+ HTTP_PROXY=http://127.0.0.1:8080 \
104
+ HTTPS_PROXY=http://127.0.0.1:8080 \
105
+ <command>
106
+
107
+ 对于兼容 proxychains 的命令,也可以使用:
108
+
109
+ proxychains4 <command>
110
+
111
+ proxychains4 已预配置指向本地 mitmproxy。
112
+
113
+ 不要为了任务重复启动 tcpdump 或 mitmproxy。
114
+
115
+ 默认保持工具直连;只有确实需要 HTTP(S) 明文记录时才显式走代理,避免影响不兼容代理、raw socket 或特殊网络工具。
116
+
117
+ 字典
118
+ /usr/share/seclists/
119
+ /usr/share/wordlists/rockyou.txt.gz
120
+
121
+ 需要 rockyou 时再解压:
122
+
123
+ gzip -dk /usr/share/wordlists/rockyou.txt.gz
124
+ 知识库
125
+
126
+ 容器内置离线知识库,位于:
127
+
128
+ /pentester/kb/
129
+
130
+ 当遇到以下情况时,优先检索知识库而不是猜测或搜索:
131
+
132
+ - 不确定某个漏洞的利用方式
133
+ - 需要参考已知漏洞的 PoC / exploit
134
+ - 需要查找特定技术或协议的攻击手法
135
+ - 需要参考安全工具的常见用法和参数组合
136
+ - 遇到不熟悉的 CVE / 服务 / 框架
137
+
138
+ 知识库内容:
139
+
140
+ /pentester/kb/vulhub/
141
+ Vulhub 漏洞环境合集 —— 每个目录对应一个 CVE 或漏洞,
142
+ 包含 docker-compose.yml(环境说明)和 README.md(漏洞原理 + 利用步骤)。
143
+ 适用:需要在本地搭建漏洞环境复现时;但容器内无 docker,
144
+ 主要参考其中的漏洞描述和利用思路。
145
+
146
+ /pentester/kb/PayloadsAllTheThings/
147
+ Swissky 的 PayloadsAllTheThings —— 按攻击类型组织的 payload 大全。
148
+ 目录结构:SQL Injection/ Command Injection/ XSS Injection/ SSTI/
149
+ Upload Insecure Files/ 等。
150
+ 每个目录下是 README.md,包含该攻击类型的 payload 列表和简短说明。
151
+ 适用:需要特定 payload 模板、绕过技巧、注入语法时。
152
+
153
+ /pentester/kb/awesome-poc/
154
+ Awesome-POC —— 按 CVE 编号组织的漏洞 PoC 合集。
155
+ 目录结构:CVE-YYYY-XXXXX/ 下包含 exploit 脚本和 README。
156
+ 适用:目标存在已知 CVE 时查找现成 PoC。
157
+
158
+ /pentester/kb/exphub/
159
+ exphub —— 漏洞利用工具合集。
160
+ 按漏洞/框架分类,包含 Python/Go 等语言的 exploit 脚本。
161
+ 适用:需要现成 exploit 工具时。
162
+
163
+ 索引:
164
+
165
+ /pentester/kb/INDEX.txt
166
+
167
+ 这是构建期生成的全量文件清单,每行一个文件路径(相对于 /pentester/kb/)。
168
+
169
+ 检索方法:
170
+
171
+ # 第一步:搜索 INDEX 找到相关文件
172
+ rg -i '<keyword>' /pentester/kb/INDEX.txt
173
+
174
+ # 例如:
175
+ rg -i 'CVE-2021-44228' /pentester/kb/INDEX.txt
176
+ rg -i 'ssti' /pentester/kb/INDEX.txt
177
+ rg -i 'sql injection' /pentester/kb/INDEX.txt
178
+ rg -i 'tomcat' /pentester/kb/INDEX.txt
179
+
180
+ # 第二步:读取匹配的文件
181
+ cat /pentester/kb/PayloadsAllTheThings/Server\ Side\ Template\ Injection/README.md
182
+ cat /pentester/kb/awesome-poc/CVE-2021-44228/README.md
183
+
184
+ # 第三步(可选):如果结果太多,组合关键词缩小范围
185
+ rg -i 'ssti' /pentester/kb/INDEX.txt | rg -i 'jinja'
186
+
187
+ # 也可以直接搜索文件内容(不经过 INDEX)
188
+ rg -i '<keyword>' /pentester/kb/ --include '*.md'
189
+
190
+ 注意事项:
191
+
192
+ - INDEX.txt 只索引文件名,不索引文件内容。精确匹配用 INDEX,
193
+ 模糊匹配或内容搜索用 rg 直接扫文件。
194
+ - 知识库是只读参考,不要修改或写入 /pentester/kb/。
195
+ - 知识库中的 payload 和 exploit 可能依赖特定环境或版本,
196
+ 使用前先确认目标环境是否匹配。
197
+ - 知识库补充工具能力,但不替代工具执行。
198
+ 仍然以 tool-info / command -v 为实际能力判断依据。
199
+
200
+ 如果 red-tldr 已安装,也可以用于快速查询常见安全工具和技术命令:
201
+
202
+ red-tldr <keyword>
203
+
204
+ 但:
205
+
206
+ red-tldr 是知识参考,不代表对应命令一定安装。
207
+
208
+ 仍然以:
209
+
210
+ tool-info
211
+ command -v
212
+
213
+ 为实际能力判断依据。
214
+
215
+ 3. 输出策略
216
+
217
+ 优先让命令产生机器可读、紧凑、可复用的结果。
218
+
219
+ 优先级:
220
+
221
+ 工具原生 JSON / JSONL
222
+
223
+ jc 支持的 parser
224
+
225
+ 原始 stdout / stderr
226
+ 第一优先:原生结构化输出
227
+
228
+ 工具本身支持 JSON/JSONL 时优先使用,例如:
229
+
230
+ httpx -json
231
+ nuclei -jsonl
232
+ ffuf -of json
233
+
234
+ 不要为了使用 jc 而把已经结构化的数据再次转换。
235
+
236
+ 第二优先:jc
237
+
238
+ 传统 UNIX 命令没有原生 JSON,而 jc 有对应 parser 时:
239
+
240
+ ps aux | jc --ps
241
+ df -h | jc --df
242
+ ping -c 3 <host> | jc --ping
243
+
244
+ 可以使用 jc 转换。
245
+
246
+ 第三优先:原始输出
247
+
248
+ 以下情况保持原始输出:
249
+
250
+ jc 不支持;
251
+ 输出已经足够清晰;
252
+ 交互式程序;
253
+ 持续输出;
254
+ 二进制数据;
255
+ 转换会损失信息。
256
+
257
+ 不要把所有命令无条件通过 jc。
258
+
259
+ 4. 命令执行原则
260
+
261
+ 所有命令通过 container_exec 在 Toolbox 中执行。
262
+
263
+ 优先使用工具自身的非交互参数,例如:
264
+
265
+ --batch
266
+ --non-interactive
267
+ --silent
268
+ --json
269
+ --jsonl
270
+
271
+ 具体参数必须根据该工具实际 CLI 确认。
272
+
273
+ 不要机械地给所有命令添加:
274
+
275
+ -o /dev/null
276
+
277
+ 因为这可能丢弃任务结果或错误信息。
278
+
279
+ 对于长输出:
280
+
281
+ <command> > /workspace/results/result.txt 2>&1
282
+
283
+ 或者优先保存工具自己的结构化结果:
284
+
285
+ <command> ... > /workspace/results/result.jsonl
286
+
287
+ 随后只读取必要片段,例如:
288
+
289
+ head
290
+ tail
291
+ rg
292
+ jq
293
+ wc
294
+
295
+ 避免把巨大结果直接塞回 Agent 上下文。
296
+
297
+ ## 3. 工具速查(按阶段)
298
+
299
+ ### 侦察 / 信息收集
300
+
301
+ | 需求 | 命令 |
302
+ | --- | --- |
303
+ | 端口扫描 | `nmap -sV -p- <host>` · `masscan -p 1-65535 <host>` · `naabu -host <host>` |
304
+ | 内网综合 | `fscan -h <网段>` · `kscan -t <网段>` |
305
+ | 子域名 | `subfinder -d <d>` · `dnsx -d <d>` · `amass enum -d <d>` · `fofax -q '<query>'` |
306
+ | HTTP 指纹 | `httpx -l <hosts> -status-code` · `whatweb <url>` · `wafw00f <url>` |
307
+ | ARP 发现 | `arp-scan --localnet` · `netdiscover -r <网段>` |
308
+
309
+ ### Web 测试
310
+
311
+ | 需求 | 命令 |
312
+ | --- | --- |
313
+ | 目录 fuzz | `ffuf -w <dict> -u <url>/FUZZ` · `gobuster dir -u <url> -w <dict>` · `feroxbuster -u <url> -w <dict>` |
314
+ | 爬取 | `katana -u <url>` · `gospider -s 10 <url>` |
315
+ | 漏洞扫描 | `nuclei -u <url>` |
316
+ | SQL 注入 | `sqlmap -u <url> --batch` |
317
+ | 手工请求 | `curl -sS` · `xh -S GET <url>` · `hurl <file.hurl>` |
318
+
319
+ ### 凭据 / 爆破
320
+
321
+ | 需求 | 命令 |
322
+ | --- | --- |
323
+ | 网络爆破 | `hydra -l <user> -P <dict> ssh://<host>` · `medusa -h <host> -u <user> -P <dict> -M ssh` |
324
+ | 密码破解 | `john --wordlist=<dict> <hashfile>` · `hashcat -m <id> -a 0 <hash> <dict>` |
325
+ | 识别 | `hashid <hash>` · 默认口令 `defaulthound <host>` |
326
+ | 造字典 | `crunch <min> <max> <charset> > out` |
327
+
328
+ ### SMB / AD
329
+
330
+ | 需求 | 命令 |
331
+ | --- | --- |
332
+ | 枚举 | `smbclient -L <host>` · `enum4linux-ng -A <host>` |
333
+ | 认证利用 | `netexec smb <host> -u <user> -p <pass>` · `impacket-psexec <user>@<host>` · `impacket-secretsdump <user>@<host>` |
334
+ | WinRM | `evil-winrm -i <host> -u <user> -p <pass>` |
335
+
336
+ ### 利用辅助
337
+
338
+ | 需求 | 命令 |
339
+ | --- | --- |
340
+ | 反序列化 | `ysoserial -u <gadget>` · `marshalsec <type>` · `jndi-injection-exploit -C <cmd>` |
341
+ | 数据库 | `usql <DSN> -c "SELECT ..." --json` |
342
+
343
+ ### 网络 / 取证 / 杂项
344
+
345
+ | 需求 | 命令 |
346
+ | --- | --- |
347
+ | 连通性 | `nc -vz <host> <port>` · `socat TCP:<host>:<port> -` · `telnet <host> <port>` |
348
+ | DNS | `dig <host>` · `whois <domain>` · `traceroute <host>` · `mtr -r <host>` |
349
+ | 代理路由 | `proxychains4 <cmd>` · `torsocks <cmd>` |
350
+ | 取证 | `exiftool <file>` · `binwalk <file>` · `foremost -i <file>` · `r2 -a <bin>` |
351
+ | MITM | `responder -I eth0` · `bettercap -iface eth0` |
352
+ | 输出加工 | `jq` · `jc` · `gron` · `mlr` · `rg` · `fd` |
353
+
354
+ ## 4. 规则
355
+
356
+ 1. 先 `tool-list` 看全貌,再 `tool-info <name>` 取该工具的准确参数——上表只是速查,不替代 `tool-info`。
357
+ 2. 一切命令在容器内经 `container_exec` 执行;产出写入你自己的 delegation 目录(work/ artifacts/ evidence/ logs/)。
358
+ 3. 全流量已记录,勿重复 tcpdump;需要应用层明文时显式走 `http://127.0.0.1:8080`。
359
+ 4. 不确定工具是否存在:`command -v <name>` 确认;不存在则报告,不自作主张安装。
360
+ 5. 输出保持克制:非交互、限制规模、长输出落盘。
361
+ 6. 绝不运行 git 命令;git checkpoint 由宿主负责。
362
+ 7. 除工具原始输出外,所有内容使用用户语言(attach_prompt 的语言)。
@@ -0,0 +1,39 @@
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ dst="$1"
5
+ repo="$2"
6
+ min="${3:-1}"
7
+
8
+ target="/opt/kb/$dst"
9
+
10
+ for url in \
11
+ "https://github.com/${repo}.git" \
12
+ "https://gh.xmly.dev/https://github.com/${repo}.git" \
13
+ "https://gh-proxy.com/https://github.com/${repo}.git"
14
+ do
15
+ for attempt in 1 2 3
16
+ do
17
+ echo "==> clone $repo"
18
+ echo " url: $url"
19
+ echo " attempt: $attempt/3"
20
+
21
+ rm -rf "$target"
22
+
23
+ if git clone --depth 1 "$url" "$target"; then
24
+ count="$(find "$target" -type f 2>/dev/null | wc -l)"
25
+
26
+ if [ "$count" -gt "$min" ]; then
27
+ echo "==> $repo OK ($count files)"
28
+ exit 0
29
+ fi
30
+
31
+ echo "==> clone incomplete: only $count files"
32
+ fi
33
+
34
+ sleep 5
35
+ done
36
+ done
37
+
38
+ echo "ERROR: failed to clone $repo"
39
+ exit 1
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # 启动流量记录。
5
+ # record-traffic.sh 自身必须幂等,因此重复调用不会重复启动 recorder。
6
+ /pentester/bin/record-traffic.sh
7
+
8
+ # 让 Docker CMD 成为 PID 1,正确处理 stop / signals。
9
+ exec "$@"
@@ -0,0 +1,246 @@
1
+ #!/usr/bin/env bash
2
+ # gen-tools-json.sh — build-time catalog generator for /pentester/tools.json
3
+ #
4
+ # Probes every curated tool with `command -v` and emits ONLY tools that exist
5
+ # in the built image, so the catalog never drifts from what the Agent can
6
+ # actually run. Descriptions/examples are maintained here next to the tool
7
+ # (the Dockerfile just installs packages; this file owns the metadata).
8
+ #
9
+ # Usage (run inside the image at build time):
10
+ # gen-tools-json.sh [output-path] (default: /pentester/tools.json)
11
+ set -euo pipefail
12
+
13
+ OUT="${1:-/pentester/tools.json}"
14
+ IMAGE='fb0sh/dsh-pentester-kali:latest'
15
+
16
+ declare -a CATEGORY_NAMES=(
17
+ 'base'
18
+ 'cli-extras'
19
+ 'traffic'
20
+ 'network'
21
+ 'network-discovery'
22
+ 'dns-osint'
23
+ 'web-discovery'
24
+ 'vulnerability'
25
+ 'password'
26
+ 'smb-ad'
27
+ 'wordlists'
28
+ 'misc'
29
+ )
30
+
31
+ # Entry format: <category>|<name>|<description>|<example-tail>
32
+ # - Regular tools: name IS the binary to probe (command -v).
33
+ # - `bin=<actual>` as name: probe <actual>, expose display name in the next
34
+ # field (e.g. `misc|bin=r2|radare2|desc|-a <bin>`).
35
+ # - `dir:<path>` as name: path hint (not an executable), always emitted.
36
+ # - name containing `*` (impacket-*): family placeholder, skipped.
37
+ declare -a TOOLS=(
38
+ # ── base ────────────────────────────────────────────────────────────────
39
+ 'base|bash|Bourne Again SHell|-c "echo hi"'
40
+ 'base|zsh|Z shell|-c "echo hi"'
41
+ 'base|python3|Python 3 interpreter|-V'
42
+ 'base|pip|Python package installer|install --user <pkg>'
43
+ 'base|pipx|Isolated Python CLI installer|install <pkg>'
44
+ 'base|git|Distributed version control|clone <url>'
45
+ 'base|curl|HTTP/HTTPS/FTP transfer client|-sS <url>'
46
+ 'base|wget|Non-interactive network downloader|-q <url>'
47
+ 'base|aria2c|Multi-protocol download utility|-x16 <url>'
48
+ 'base|jq|JSON processor|.key <file>'
49
+ 'base|yq|YAML/JSON processor|.key <file>'
50
+ 'base|ruby|Ruby interpreter|-e "puts 1"'
51
+ 'base|perl|Perl interpreter|-e "print 1"'
52
+ 'base|go|Go toolchain|version'
53
+ 'base|java|JRE launcher|-version'
54
+ 'base|gcc|C compiler|-o out in.c'
55
+ 'base|make|Build automation|-j4'
56
+ 'base|unzip|ZIP extractor|-l <file>'
57
+ 'base|7z|7-Zip archiver|x <file>'
58
+ 'base|tar|Tape archiver|-xzf <file>'
59
+ 'base|openssl|TLS/SSL toolkit|s_client -connect <host>:443'
60
+ 'base|file|File type identification|<file>'
61
+ 'base|tree|Directory tree viewer|-L2'
62
+ 'base|gdb|GNU debugger|-batch <bin>'
63
+ 'base|tmux|Terminal multiplexer|new -s <name>'
64
+ 'base|screen|Terminal multiplexer|-S <name>'
65
+ 'base|red-tldr|Red team TL;DR|red-tldr <command>'
66
+ # ── cli-extras(现代化 CLI 基础件,来自用户愿望清单)───────────────────
67
+ 'cli-extras|rg|Ripgrep: fast recursive grep|pattern -l'
68
+ 'cli-extras|fd|fd: friendly find|".txt"'
69
+ 'cli-extras|xh|xh: curl replacement for HTTP|-S GET <url>'
70
+ 'cli-extras|hurl|HTTP request runner (chains, asserts)|<file.hurl>'
71
+ 'cli-extras|sd|sd: intuitive sed replacement|old new <file>'
72
+ 'cli-extras|mlr|Miller: csv/tsv/json awk|-i json cat <file>'
73
+ 'cli-extras|jc|Converts anything (CLI output, files) to JSON|ls | jc --ls'
74
+ 'cli-extras|gron|Grep from JSON (flatten to assignments)|gron <file.json>'
75
+ # ── web-discovery 补充(builder 阶段编译)─────────────────────────────────
76
+ 'web-discovery|interactsh-client|OOB interaction detector (DNS/HTTP/LDAP callbacks)|-n'
77
+ 'web-discovery|gospider|Fast web spider|-s 10 <url>'
78
+ # ── 反序列化 / 利用辅助(/pentester/tools/jars jar 包装脚本)──────────────
79
+ 'vulnerability|ysoserial|Java deserialization payload generator|-u CommonsCollections1'
80
+ 'vulnerability|marshalsec|Java marshalling gadget generator|MarshalledObject'
81
+ 'vulnerability|jndi-injection-exploit|JNDI/LDAP injection exploitation helper|-C <cmd>'
82
+ 'vulnerability|usql|Universal command-line interface for SQL databases|DSN -c "SELECT * FROM <table>" --json'
83
+ # ── traffic(全流量记录:只记录,不分析)──────────────────────────────
84
+ 'traffic|tcpdump|Full packet capture (always recording to /workspace/traffic/pcap)|-r /workspace/traffic/pcap/capture.pcap'
85
+ 'traffic|mitmdump|mitmproxy CLI: HTTP(S) flow recorder on :8080 (flows -> /workspace/traffic/flows.mitm)|-r /workspace/traffic/flows.mitm'
86
+ # ── network ─────────────────────────────────────────────────────────────
87
+ 'network|ip|IP routing/addresses (iproute2)|addr'
88
+ 'network|ping|ICMP echo (iputils)|-c4 <host>'
89
+ 'network|dig|DNS lookup|<host>'
90
+ 'network|nslookup|DNS query tool|<host>'
91
+ 'network|host|DNS lookup utility|<host>'
92
+ 'network|whois|WHOIS client|<domain>'
93
+ 'network|traceroute|Path tracing|<host>'
94
+ 'network|mtr|Network diagnostic (traceroute+ping)|-r <host>'
95
+ 'network|tcpdump|Packet capture|-i eth0 port 80'
96
+ 'network|tshark|Wireshark CLI analyzer|-i eth0'
97
+ 'network|nc|Netcat: read/write TCP/UDP|-vz <host> 443'
98
+ 'network|ncat|Nmap netcat variant|-v <host> 443'
99
+ 'network|socat|Bidirectional data relay|TCP:<host>:443 -'
100
+ 'network|telnet|Telnet client|<host> 23'
101
+ 'network|ssh|OpenSSH client|-o StrictHostKeyChecking=no <host>'
102
+ 'network|proxychains4|Route traffic via SOCKS/HTTP proxy|nmap -sT <host>'
103
+ 'network|torsocks|Route traffic via Tor|curl <url>'
104
+ # ── network-discovery ───────────────────────────────────────────────────
105
+ 'network-discovery|nmap|Network discovery and port scanner|-sV -p- <host>'
106
+ 'network-discovery|masscan|High-speed port scanner|-p 1-65535 <host>'
107
+ 'network-discovery|naabu|ProjectDiscovery fast port scanner|-host <host>'
108
+ 'network-discovery|arp-scan|ARP host discovery|--localnet'
109
+ 'network-discovery|fscan|内网综合扫描工具,一键自动化漏扫|-h 192.168.1.1/24'
110
+ 'network-discovery|kscan|轻量化全方位扫描器|-t 192.168.1.1/24'
111
+ 'network-discovery|netdiscover|ARP host discovery (passive/active)|-r 192.168.1.0/24'
112
+ # ── dns-osint ───────────────────────────────────────────────────────────
113
+ 'dns-osint|dnsrecon|DNS enumeration|-d <domain>'
114
+ 'dns-osint|dnsenum|DNS enumeration|<domain>'
115
+ 'dns-osint|fierce|DNS/domain scanner|--domain <domain>'
116
+ 'dns-osint|amass|Attack surface mapping (OSINT)|enum -d <domain>'
117
+ 'dns-osint|subfinder|Fast subdomain discovery|-d <domain>'
118
+ 'dns-osint|dnsx|ProjectDiscovery DNS prober|-d <domain>'
119
+ 'dns-osint|theHarvester|Email/subdomain OSINT|-d <domain> -b all'
120
+ 'dns-osint|whatweb|Website fingerprinting|<url>'
121
+ 'dns-osint|wafw00f|WAF detection|<url>'
122
+ 'dns-osint|fofax|FOFAX是一个基于fofa.info的API命令行查询工具|-q 'app="APACHE-Solr"''
123
+ # ── web-discovery ───────────────────────────────────────────────────────
124
+ 'web-discovery|ffuf|Web fuzzer|-w <wordlist> -u <url>/FUZZ'
125
+ 'web-discovery|gobuster|Directory/DNS/HTTP brute force|dir -u <url> -w <wordlist>'
126
+ 'web-discovery|feroxbuster|Recursive content discovery|-u <url> -w <wordlist>'
127
+ 'web-discovery|dirb|Web content scanner|<url> <wordlist>'
128
+ 'web-discovery|dirbuster|Web content scanner (Java)|-u <url>'
129
+ 'web-discovery|katana|ProjectDiscovery crawler|-u <url>'
130
+ 'web-discovery|httpx|ProjectDiscovery HTTP prober|-l <hosts> -status-code'
131
+ 'web-discovery|nikto|Web server vulnerability scanner|-h <host>'
132
+ # ── vulnerability ───────────────────────────────────────────────────────
133
+ 'vulnerability|nuclei|Template-based vulnerability scanner|-u <url>'
134
+ 'vulnerability|sqlmap|SQL injection automation|-u <url> --batch'
135
+ # ── password ────────────────────────────────────────────────────────────
136
+ 'password|hydra|Network login brute forcer|-l <user> -P <passwords> ssh://<host>'
137
+ 'password|john|John the Ripper password cracker|--wordlist=<list> <hashfile>'
138
+ 'password|medusa|Parallel network login brute forcer|-h <host> -u <user> -P <passwords> -M ssh'
139
+ 'password|crunch|Wordlist generator|8 8 abc123 > <out>'
140
+ 'password|hashid|Hash type identification|<hash>'
141
+ 'password|hashcat|Advanced password recovery utility|-m 0 -a 0 <hash> <wordlist>'
142
+ 'password|defaulthound|Default password scanner|<host>'
143
+ # ── smb-ad ──────────────────────────────────────────────────────────────
144
+ 'smb-ad|smbclient|SMB/CIFS client|-L <host>'
145
+ 'smb-ad|enum4linux-ng|SMB/AD enumeration|-A <host>'
146
+ 'smb-ad|impacket-*|Impacket scripts (psexec, smbexec, secretsdump)|psexec domain/user@<host>'
147
+ 'smb-ad|netexec|Network exec suite (SMB/WinRM/LDAP)|smb <host> -u <user> -p <pass>'
148
+ 'smb-ad|evil-winrm|WinRM shell client|-i <host> -u <user> -p <pass>'
149
+ # ── wordlists (path hints, not executable tools) ────────────────────────
150
+ 'wordlists|dir:/usr/share/seclists|Wordlist collection (seclists)'
151
+ 'wordlists|dir:/usr/share/wordlists/rockyou.txt.gz|rockyou wordlist'
152
+ # ── misc ────────────────────────────────────────────────────────────────
153
+ 'misc|exiftool|EXIF metadata extraction|<file>'
154
+ 'misc|binwalk|Firmware/file carving|<file>'
155
+ 'misc|foremost|File carving|-i <file>'
156
+ 'misc|bin=r2|radare2|Reverse engineering framework|-a <bin>'
157
+ 'misc|responder|LLMNR/NBT-NS/mDNS poisoner|-I eth0'
158
+ 'misc|bettercap|MITM framework|-iface eth0'
159
+ )
160
+
161
+ # Collect all_bins: every probed binary that actually exists (dir: excluded).
162
+ # 可选知识库层(--build-arg WITH_KB=1 构建时才存在;存在才进目录)
163
+ if [ -d /pentester/kb ]; then
164
+ TOOLS+=('knowledge|dir:/pentester/kb|Offline knowledge bases: vulhub, PayloadsAllTheThings, Awesome-POC, exphub|see /pentester/kb/INDEX.txt')
165
+ fi
166
+
167
+ mapfile -t ALL_BINS < <(printf '%s\n' "${TOOLS[@]}" | while IFS='|' read -r _cat name _desc _tail; do
168
+ case "$name" in
169
+ dir:*) continue ;;
170
+ bin=*) probe="${name#bin=}" ;;
171
+ *'*') continue ;;
172
+ *) probe="$name" ;;
173
+ esac
174
+ if command -v "$probe" >/dev/null 2>&1; then
175
+ printf '%s\n' "$probe"
176
+ fi
177
+ done | sort -u)
178
+
179
+ {
180
+ printf '{\n'
181
+ printf ' "version": "%s",\n' "$(cat /pentester/VERSION 2>/dev/null || echo '1.0.0')"
182
+ printf ' "image": "%s",\n' "$IMAGE"
183
+ printf ' "categories": {\n'
184
+ } > "$OUT"
185
+
186
+ first_category=1
187
+ for category in "${CATEGORY_NAMES[@]}"; do
188
+ entries=$(printf '%s\n' "${TOOLS[@]}" | while IFS='|' read -r cat name desc tail; do
189
+ [ "$cat" != "$category" ] && continue
190
+ case "$name" in
191
+ *'*') continue ;; # family placeholder
192
+ dir:*)
193
+ # Path hint: bin = the path, always emitted.
194
+ path="${name#dir:}"
195
+ binname="${path##*/}"
196
+ jq -nc --arg n "$binname" --arg b "$path" --arg d "$desc" \
197
+ '{ name: $n, bin: $b, description: $d, common_flags: [], examples: [$b] }'
198
+ ;;
199
+ bin=*)
200
+ # name = bin=<probe>, desc = <display>, tail = <description>|<example-tail>
201
+ probe="${name#bin=}"
202
+ display="$desc"
203
+ description="${tail%%|*}"
204
+ example_tail=""
205
+ if [ "$tail" != "$description" ]; then
206
+ example_tail="${tail#*|}"
207
+ fi
208
+ if command -v "$probe" >/dev/null 2>&1; then
209
+ example="$probe"
210
+ [ -n "$example_tail" ] && example="$example $example_tail"
211
+ jq -nc --arg n "$display" --arg b "$probe" --arg d "$description" --arg e "$example" \
212
+ '{ name: $n, bin: $b, description: $d, common_flags: [], examples: [$e] }'
213
+ fi
214
+ ;;
215
+ *)
216
+ if command -v "$name" >/dev/null 2>&1; then
217
+ example="$name"
218
+ [ -n "$tail" ] && example="$example $tail"
219
+ jq -nc --arg n "$name" --arg b "$name" --arg d "$desc" --arg e "$example" \
220
+ '{ name: $n, bin: $b, description: $d, common_flags: [], examples: [$e] }'
221
+ fi
222
+ ;;
223
+ esac
224
+ done)
225
+ if [ -n "$entries" ]; then
226
+ if [ "$first_category" -eq 0 ]; then
227
+ printf ',\n' >> "$OUT"
228
+ fi
229
+ {
230
+ printf ' "%s": [\n' "$category"
231
+ printf '%s\n' "$entries" | paste -sd, -
232
+ printf '\n ]'
233
+ } >> "$OUT"
234
+ first_category=0
235
+ fi
236
+ done
237
+
238
+ {
239
+ printf '\n },\n'
240
+ printf ' "all_bins": [\n'
241
+ printf '%s\n' "${ALL_BINS[@]}" | sed 's/^/ "/; s/$/",/' | sed '$ s/,$//'
242
+ printf '\n ]\n'
243
+ printf '}\n'
244
+ } >> "$OUT"
245
+
246
+ echo "tools.json written: $(wc -l < "$OUT") lines, ${#ALL_BINS[@]} bins"