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,881 @@
1
+ # dsh-pentester/kali —— 唯一工厂 Toolbox 镜像。
2
+ #
3
+ # Kali Linux(rolling)+ 精选渗透测试工具集。Agent 从不指定镜像名:
4
+ # 经 /pentester/tools.json 发现工具,一切执行走 pentester_container_exec
5
+ # (契约见 docs/architecture.md)。
6
+ #
7
+ # 构建(仓库根目录,或直接运行 bash scripts/build-docker-image.sh):
8
+ # docker build -t fb0sh/dsh-pentester-kali:latest docker/kali
9
+ #
10
+ # 工具契约:
11
+ # /pentester/tools.json — 构建期由 bin/gen-tools-json.sh 探测生成
12
+ # (command -v 探测,装漏的工具不会进目录)
13
+ # /pentester/bin/tool-list — 分类清单
14
+ # /pentester/bin/tool-info — 单工具详情
15
+ # /pentester/VERSION — dsh-pentester-kali 镜像版本
16
+ # /workspace — 项目共享 docker volume(该项目所有容器
17
+ # 共同挂载)
18
+ # /workspace/traffic/ — 全流量记录(只记录,不分析):
19
+ # pcap/(tcpdump 常开)+ flows.mitm
20
+ # (mitmproxy :8080,agent 走它可得明文 HTTP)
21
+
22
+
23
+ # =============================================================================
24
+ # Kali 基础层
25
+ #
26
+ # Builder / Runtime / KB Builder 共用这一层:
27
+ # - Kali sources
28
+ # - CA
29
+ # - archive keyring
30
+ #
31
+ # http_proxy / https_proxy / no_proxy 不通过 ARG/ENV 显式声明。
32
+ # Docker/BuildKit 原生提供这些 proxy build args;构建工具通过 buildargs 传入即可。
33
+ # =============================================================================
34
+
35
+ FROM kalilinux/kali-rolling:latest AS kali-base
36
+
37
+ SHELL ["/bin/bash", "-euxo", "pipefail", "-c"]
38
+
39
+ ARG DEBIAN_FRONTEND=noninteractive
40
+
41
+ # KALI_SOURCES:自定义 sources.list 全文(构建脚本传入);
42
+ # 为空时走官方源 http 引导装 CA → 切 https 的默认流程。
43
+ ARG KALI_SOURCES=""
44
+
45
+ # 基础 Kali 镜像可能没有完整 CA。
46
+ # 自定义 https 源先临时转换为 http,引导安装 CA 后再恢复用户原文。
47
+ RUN --mount=type=cache,id=dsh-kali-apt-lists,target=/var/lib/apt/lists,sharing=locked \
48
+ --mount=type=cache,id=dsh-kali-apt-cache,target=/var/cache/apt,sharing=locked \
49
+ rm -f /etc/apt/sources.list.d/*.list \
50
+ /etc/apt/sources.list.d/*.sources; \
51
+ \
52
+ if [[ -n "${KALI_SOURCES}" ]]; then \
53
+ printf '%s\n' "${KALI_SOURCES}" \
54
+ | sed 's|https://|http://|g' \
55
+ > /etc/apt/sources.list; \
56
+ \
57
+ apt-get update; \
58
+ apt-get install -y --no-install-recommends \
59
+ ca-certificates \
60
+ kali-archive-keyring; \
61
+ \
62
+ printf '%s\n' "${KALI_SOURCES}" \
63
+ > /etc/apt/sources.list; \
64
+ else \
65
+ printf '%s\n' \
66
+ 'deb http://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware' \
67
+ > /etc/apt/sources.list; \
68
+ \
69
+ apt-get update; \
70
+ apt-get install -y --no-install-recommends \
71
+ ca-certificates \
72
+ kali-archive-keyring; \
73
+ \
74
+ printf '%s\n' \
75
+ 'deb https://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware' \
76
+ 'deb-src https://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware' \
77
+ > /etc/apt/sources.list; \
78
+ fi
79
+
80
+
81
+ # =============================================================================
82
+ # Builder 阶段:编译 Go 工具族(strix 多阶段模式)
83
+ #
84
+ # 编译缓存和 module cache 均使用 BuildKit cache mount,
85
+ # 不进入最终 Runtime 镜像。
86
+ # =============================================================================
87
+
88
+ FROM kali-base AS gobuilder
89
+
90
+ ENV GOBIN=/out/bin
91
+
92
+ RUN --mount=type=cache,id=dsh-kali-apt-lists,target=/var/lib/apt/lists,sharing=locked \
93
+ --mount=type=cache,id=dsh-kali-apt-cache,target=/var/cache/apt,sharing=locked \
94
+ apt-get update && \
95
+ apt-get install -y --no-install-recommends \
96
+ golang-go \
97
+ git \
98
+ build-essential \
99
+ pkg-config
100
+
101
+ RUN mkdir -p /out/bin
102
+
103
+
104
+ # 去掉 Go 二进制的调试信息,减小体积
105
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
106
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
107
+ go install -ldflags="-s -w" \
108
+ github.com/projectdiscovery/httpx/cmd/httpx@latest
109
+
110
+
111
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
112
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
113
+ go install -ldflags="-s -w" \
114
+ github.com/projectdiscovery/katana/cmd/katana@latest
115
+
116
+
117
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
118
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
119
+ go install -ldflags="-s -w" \
120
+ github.com/projectdiscovery/naabu/v2/cmd/naabu@latest
121
+
122
+
123
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
124
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
125
+ go install -ldflags="-s -w" \
126
+ github.com/projectdiscovery/dnsx/cmd/dnsx@latest
127
+
128
+
129
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
130
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
131
+ go install -ldflags="-s -w" \
132
+ github.com/projectdiscovery/interactsh/cmd/interactsh-client@latest
133
+
134
+
135
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
136
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
137
+ go install -ldflags="-s -w" \
138
+ github.com/jaeles-project/gospider@latest
139
+
140
+
141
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
142
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
143
+ go install -ldflags="-s -w" \
144
+ github.com/tomnomnom/gron@latest
145
+
146
+
147
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
148
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
149
+ CGO_ENABLED=1 \
150
+ go install -ldflags="-s -w" \
151
+ github.com/xo/usql@latest
152
+
153
+
154
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
155
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
156
+ go install -ldflags="-s -w" \
157
+ github.com/xiecat/fofax/cmd/fofax@latest
158
+
159
+ RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
160
+ --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
161
+ git clone --depth=1 \
162
+ https://github.com/Rvn0xsy/red-tldr.git \
163
+ /tmp/red-tldr && \
164
+ cd /tmp/red-tldr && \
165
+ go build -ldflags="-s -w" \
166
+ -o /out/bin/red-tldr . && \
167
+ rm -rf /tmp/red-tldr
168
+
169
+ # ── Go 增量工具区 ────────────────────────────────────────────────────────────
170
+ #
171
+ # 后续新增 Go 工具只向下追加新的 RUN。
172
+ # 不要修改上面的已有 RUN,这样已有 Go 工具层继续命中缓存。
173
+ #
174
+ # 示例:
175
+ #
176
+ # RUN --mount=type=cache,id=dsh-go-mod,target=/root/go/pkg/mod \
177
+ # --mount=type=cache,id=dsh-go-build,target=/root/.cache/go-build \
178
+ # go install -ldflags="-s -w" \
179
+ # github.com/tomnomnom/assetfinder@latest
180
+
181
+
182
+
183
+ # =============================================================================
184
+ # KB Builder
185
+ #
186
+ # 知识库与 Runtime 完全分离构建:
187
+ # - 修改 Runtime 工具不会重新 clone KB
188
+ # - clone 产生的 Git 元数据可以在进入最终镜像前剥离
189
+ #
190
+ # KEEP_KB_GIT=0:
191
+ # 默认删除每个 KB 顶层 .git,显著降低最终镜像体积。
192
+ #
193
+ # 如果确实需要在容器内对 KB 使用 git history:
194
+ # --build-arg KEEP_KB_GIT=1
195
+ # =============================================================================
196
+
197
+ FROM kali-base AS kb-builder
198
+
199
+ ARG WITH_KB=1
200
+ ARG KEEP_KB_GIT=0
201
+
202
+ RUN --mount=type=cache,id=dsh-kali-apt-lists,target=/var/lib/apt/lists,sharing=locked \
203
+ --mount=type=cache,id=dsh-kali-apt-cache,target=/var/cache/apt,sharing=locked \
204
+ apt-get update && \
205
+ apt-get install -y --no-install-recommends \
206
+ git
207
+
208
+ COPY bin/clone-kb /usr/local/bin/clone-kb
209
+
210
+ RUN chmod +x /usr/local/bin/clone-kb && \
211
+ mkdir -p /opt/kb && \
212
+ git config --global http.version HTTP/1.1 && \
213
+ git config --global http.lowSpeedLimit 1000 && \
214
+ git config --global http.lowSpeedTime 60
215
+
216
+
217
+ # ── 知识库层(默认打包;--build-arg WITH_KB=0 可裁剪减小体积)────────────────
218
+
219
+ RUN if [[ "${WITH_KB}" == "1" ]]; then \
220
+ clone-kb vulhub vulhub/vulhub 500; \
221
+ if [[ "${KEEP_KB_GIT}" != "1" ]]; then \
222
+ rm -rf /opt/kb/vulhub/.git; \
223
+ fi; \
224
+ fi
225
+
226
+
227
+ RUN if [[ "${WITH_KB}" == "1" ]]; then \
228
+ clone-kb PayloadsAllTheThings swisskyrepo/PayloadsAllTheThings 400; \
229
+ if [[ "${KEEP_KB_GIT}" != "1" ]]; then \
230
+ rm -rf /opt/kb/PayloadsAllTheThings/.git; \
231
+ fi; \
232
+ fi
233
+
234
+
235
+ RUN if [[ "${WITH_KB}" == "1" ]]; then \
236
+ clone-kb awesome-poc Threekiii/Awesome-POC 300; \
237
+ if [[ "${KEEP_KB_GIT}" != "1" ]]; then \
238
+ rm -rf /opt/kb/awesome-poc/.git; \
239
+ fi; \
240
+ fi
241
+
242
+
243
+ RUN if [[ "${WITH_KB}" == "1" ]]; then \
244
+ clone-kb exphub zhzyker/exphub 60; \
245
+ if [[ "${KEEP_KB_GIT}" != "1" ]]; then \
246
+ rm -rf /opt/kb/exphub/.git; \
247
+ fi; \
248
+ fi
249
+
250
+
251
+ RUN if [[ "${WITH_KB}" == "1" ]]; then \
252
+ find /opt/kb -type f \( \
253
+ -name '*.md' -o \
254
+ -name '*.py' -o \
255
+ -name '*.txt' -o \
256
+ -name '*.yaml' \
257
+ \) \
258
+ | sed 's|^/opt/kb/||' \
259
+ | sort \
260
+ > /opt/kb/INDEX.txt; \
261
+ fi
262
+
263
+
264
+
265
+ # =============================================================================
266
+ # Runtime 阶段
267
+ # =============================================================================
268
+
269
+ FROM kali-base AS runtime
270
+
271
+ # /pentester 是最终镜像中 dsh-pentester-kali 的产品根目录。
272
+ #
273
+ # /pentester/bin/ — dsh-pentester 自身脚本 / Agent 接口
274
+ # /pentester/tools/bin/ — Go 与其他自定义可执行工具
275
+ # /pentester/tools/jars/ — Java JAR 工具资产
276
+ # /pentester/tools/pipx/ — pipx 隔离环境
277
+ # /pentester/kb/ — 知识库
278
+ #
279
+ # 自定义工具不再散落到 /usr/local/bin 和 /root/.local/bin。
280
+ ENV PIPX_HOME="/pentester/tools/pipx" \
281
+ PIPX_BIN_DIR="/pentester/tools/bin" \
282
+ PATH="/pentester/bin:/pentester/tools/bin:${PATH}"
283
+
284
+
285
+ # =============================================================================
286
+ # STABLE APT AREA
287
+ #
288
+ # 下面 1~9 类工具属于稳定工具集,但统一在一个 APT transaction 中安装:
289
+ # - 只执行一次 apt-get update
290
+ # - 减少重复网络请求和构建时间
291
+ # - 分类仍完整保留,RUN 内使用对应的 Bash 数组组织
292
+ #
293
+ # 分类:
294
+ # 1. 基础 / UNIX / 开发运行时(agent 脚本 + 输出解析)
295
+ # 2. 网络 / 诊断
296
+ # 3. 网络发现 / 端口扫描
297
+ # 4. DNS / 子域名 / OSINT
298
+ # 5. Web 发现 / fuzz / 爬取 + 漏洞扫描
299
+ # 6. 密码 / 爆破 / 凭据
300
+ # 7. SMB / Windows / AD
301
+ # 8. 字典(rockyou + seclists)
302
+ # 9. 杂项取证 / 逆向 / 响应
303
+ #
304
+ # 后续新增工具不要再修改这里。
305
+ # 新工具统一追加到后面的 EXTRA TOOLS 区域,
306
+ # 避免破坏这个已经很重、但稳定的缓存层。
307
+ #
308
+ # APT lists/cache 使用 BuildKit cache mount,不写入最终镜像层。
309
+ # =============================================================================
310
+
311
+ RUN --mount=type=cache,id=dsh-kali-apt-lists,target=/var/lib/apt/lists,sharing=locked \
312
+ --mount=type=cache,id=dsh-kali-apt-cache,target=/var/cache/apt,sharing=locked \
313
+ base_tools=( \
314
+ zsh \
315
+ tmux \
316
+ screen \
317
+ vim \
318
+ nano \
319
+ tree \
320
+ file \
321
+ less \
322
+ gawk \
323
+ ripgrep \
324
+ fd-find \
325
+ xh \
326
+ sd \
327
+ miller \
328
+ hurl \
329
+ git \
330
+ curl \
331
+ wget \
332
+ aria2 \
333
+ jq \
334
+ yq \
335
+ python3 \
336
+ python3-pip \
337
+ python3-venv \
338
+ pipx \
339
+ ruby \
340
+ perl \
341
+ default-jre \
342
+ unzip \
343
+ zip \
344
+ p7zip-full \
345
+ tar \
346
+ gzip \
347
+ bzip2 \
348
+ xz-utils \
349
+ build-essential \
350
+ pkg-config \
351
+ openssl \
352
+ golang-go \
353
+ ); \
354
+ network_tools=( \
355
+ iproute2 \
356
+ iputils-ping \
357
+ net-tools \
358
+ dnsutils \
359
+ whois \
360
+ traceroute \
361
+ mtr-tiny \
362
+ tcpdump \
363
+ tshark \
364
+ netcat-openbsd \
365
+ socat \
366
+ ncat \
367
+ telnet \
368
+ openssh-client \
369
+ proxychains4 \
370
+ torsocks \
371
+ ); \
372
+ discovery_tools=( \
373
+ nmap \
374
+ masscan \
375
+ arp-scan \
376
+ netdiscover \
377
+ ); \
378
+ osint_tools=( \
379
+ dnsrecon \
380
+ dnsenum \
381
+ fierce \
382
+ amass \
383
+ subfinder \
384
+ theharvester \
385
+ whatweb \
386
+ wafw00f \
387
+ ); \
388
+ web_tools=( \
389
+ ffuf \
390
+ gobuster \
391
+ feroxbuster \
392
+ dirb \
393
+ dirbuster \
394
+ nikto \
395
+ nuclei \
396
+ sqlmap \
397
+ ); \
398
+ credential_tools=( \
399
+ hydra \
400
+ john \
401
+ medusa \
402
+ crunch \
403
+ hashid \
404
+ hashcat \
405
+ ); \
406
+ windows_ad_tools=( \
407
+ smbclient \
408
+ enum4linux-ng \
409
+ impacket-scripts \
410
+ netexec \
411
+ evil-winrm \
412
+ ); \
413
+ wordlist_tools=( \
414
+ seclists \
415
+ wordlists \
416
+ ); \
417
+ analysis_tools=( \
418
+ exiftool \
419
+ binwalk \
420
+ foremost \
421
+ radare2 \
422
+ gdb \
423
+ responder \
424
+ bettercap \
425
+ ); \
426
+ apt-get update && \
427
+ apt-get install -y --no-install-recommends \
428
+ "${base_tools[@]}" \
429
+ "${network_tools[@]}" \
430
+ "${discovery_tools[@]}" \
431
+ "${osint_tools[@]}" \
432
+ "${web_tools[@]}" \
433
+ "${credential_tools[@]}" \
434
+ "${windows_ad_tools[@]}" \
435
+ "${wordlist_tools[@]}" \
436
+ "${analysis_tools[@]}" && \
437
+ ln -sf /usr/bin/fdfind /usr/local/bin/fd
438
+
439
+
440
+
441
+ # =============================================================================
442
+ # Stable Custom Tools
443
+ # =============================================================================
444
+
445
+
446
+ # ── jc(anything→JSON)+ Java 反序列化三件套(gh-proxy 回退,hxbai 模式)────
447
+
448
+ RUN --mount=type=cache,id=dsh-pip-cache,target=/root/.cache/pip \
449
+ mkdir -p \
450
+ /pentester/tools/bin \
451
+ /pentester/tools/jars \
452
+ /pentester/tools/pipx && \
453
+ pipx install jc
454
+
455
+
456
+ RUN \
457
+ for jar in \
458
+ "ysoserial|https://github.com/frohoff/ysoserial/releases/latest/download/ysoserial-all.jar" \
459
+ "marshalsec|https://github.com/0ofo/marshalsec.jar/releases/download/0.0.3/marshalsec-0.0.3-SNAPSHOT-all.jar" \
460
+ "JNDI-Injection-Exploit|https://github.com/welk1n/JNDI-Injection-Exploit/releases/download/v1.0/JNDI-Injection-Exploit-1.0-SNAPSHOT-all.jar"; \
461
+ do \
462
+ name="${jar%%|*}"; \
463
+ url="${jar#*|}"; \
464
+ ok=0; \
465
+ \
466
+ for u in \
467
+ "https://gh-proxy.com/${url}" \
468
+ "https://ghproxy.net/${url}" \
469
+ "${url}"; \
470
+ do \
471
+ if curl \
472
+ -fL \
473
+ --retry 2 \
474
+ --retry-delay 1 \
475
+ --connect-timeout 10 \
476
+ --max-time 120 \
477
+ -o "/pentester/tools/jars/${name}.jar" \
478
+ "${u}"; \
479
+ then \
480
+ if [[ -s "/pentester/tools/jars/${name}.jar" ]]; then \
481
+ ok=1; \
482
+ break; \
483
+ fi; \
484
+ fi; \
485
+ \
486
+ rm -f "/pentester/tools/jars/${name}.jar"; \
487
+ done; \
488
+ \
489
+ if [[ "${ok}" != "1" ]]; then \
490
+ echo "ERROR: ${name} jar download failed" >&2; \
491
+ exit 1; \
492
+ fi; \
493
+ \
494
+ bin_name="$(printf '%s' "${name}" | tr 'A-Z' 'a-z')"; \
495
+ printf '#!/bin/sh\nexec java -jar /pentester/tools/jars/%s.jar "$@"\n' \
496
+ "${name}" \
497
+ > "/pentester/tools/bin/${bin_name}"; \
498
+ chmod +x "/pentester/tools/bin/${bin_name}"; \
499
+ done
500
+
501
+
502
+ # ── mitmproxy(全流量记录的 HTTP 层;pipx 隔离安装)──────────────────────
503
+
504
+ RUN --mount=type=cache,id=dsh-pip-cache,target=/root/.cache/pip \
505
+ pipx install mitmproxy && \
506
+ /pentester/tools/bin/mitmdump --version
507
+
508
+
509
+ # ── fscan(内网综合扫描工具)──────────────────────────────────────────────
510
+
511
+ RUN \
512
+ wget \
513
+ -q \
514
+ -T 20 \
515
+ -O /pentester/tools/bin/fscan \
516
+ "https://github.com/shadow1ng/fscan/releases/download/v2.2.0/fscan_2.2.0_linux_x64" && \
517
+ test -s /pentester/tools/bin/fscan && \
518
+ chmod +x /pentester/tools/bin/fscan
519
+
520
+
521
+ # ── kscan(内网综合扫描工具)──────────────────────────────────────────────
522
+
523
+ RUN \
524
+ wget \
525
+ -q \
526
+ -T 20 \
527
+ -O /tmp/kscan.zip \
528
+ "https://github.com/lcvvvv/kscan/releases/download/v1.85/kscan_linux_amd64.zip" && \
529
+ unzip \
530
+ -q \
531
+ /tmp/kscan.zip \
532
+ -d /tmp/kscan_extract && \
533
+ mv \
534
+ /tmp/kscan_extract/kscan_linux_amd64 \
535
+ /pentester/tools/bin/kscan && \
536
+ chmod +x /pentester/tools/bin/kscan && \
537
+ rm -rf \
538
+ /tmp/kscan.zip \
539
+ /tmp/kscan_extract
540
+
541
+
542
+ # ── defaulthound(默认口令扫描工具)────────────────────────────────────────
543
+
544
+ RUN \
545
+ wget \
546
+ -q \
547
+ -T 20 \
548
+ -O /tmp/defaulthound.tar.gz \
549
+ "https://github.com/fb0sh/DefaultHound/releases/download/v2.12.0/defaulthound-x86_64-unknown-linux-gnu-v2.12.0.tar.gz" && \
550
+ tar \
551
+ -xzf /tmp/defaulthound.tar.gz \
552
+ -C /tmp && \
553
+ mv \
554
+ /tmp/defaulthound \
555
+ /pentester/tools/bin/defaulthound && \
556
+ chmod +x /pentester/tools/bin/defaulthound && \
557
+ rm -f /tmp/defaulthound.tar.gz
558
+
559
+
560
+
561
+ # =============================================================================
562
+ # Knowledge Base
563
+ #
564
+ # KB 从独立 stage 复制到 /pentester/kb。
565
+ # kb-builder 内部仍使用 /opt/kb 作为构建暂存路径,避免改变 clone-kb 的既有契约。
566
+ # 修改下面的 Go/EXTRA/bin 不会重新执行 clone。
567
+ # =============================================================================
568
+
569
+ COPY --from=kb-builder /opt/kb/ /pentester/kb/
570
+
571
+ # 保留原先对 Git 的网络稳定性配置。
572
+ COPY --from=kb-builder \
573
+ /root/.gitconfig \
574
+ /root/.gitconfig
575
+
576
+
577
+
578
+ # =============================================================================
579
+ # Go 工具族(builder 阶段产物:PD 家族 + interactsh/gospider/gron)
580
+ #
581
+ # 故意位于 KB 后面。
582
+ # 新增 Go 工具只影响 gobuilder 后部以及这里之后的最终层。
583
+ # =============================================================================
584
+
585
+ COPY --from=gobuilder /out/bin/ /pentester/tools/bin/
586
+
587
+
588
+
589
+ # =============================================================================
590
+ # EXTRA TOOLS —— 后续新增工具统一放这里
591
+ #
592
+ # 这是以后最常修改的区域。
593
+ #
594
+ # 原则:
595
+ #
596
+ # Go 新工具
597
+ # → gobuilder 最后的“Go 增量工具区”
598
+ #
599
+ # apt 新工具
600
+ # → EXTRA APT 继续向下追加独立 RUN
601
+ #
602
+ # GitHub / wget / curl 二进制
603
+ # → EXTRA CUSTOM 继续向下追加独立 RUN
604
+ #
605
+ # pipx 工具
606
+ # → EXTRA PIPX 继续向下追加独立 RUN
607
+ #
608
+ # 不要为了新增工具回头修改 STABLE APT / Stable Custom Tools。
609
+ # =============================================================================
610
+
611
+
612
+ # ── EXTRA APT ────────────────────────────────────────────────────────────────
613
+ #
614
+ # 示例:
615
+ #
616
+ # RUN --mount=type=cache,id=dsh-kali-apt-lists,target=/var/lib/apt/lists,sharing=locked \
617
+ # --mount=type=cache,id=dsh-kali-apt-cache,target=/var/cache/apt,sharing=locked \
618
+ # apt-get update && \
619
+ # apt-get install -y --no-install-recommends \
620
+ # wpscan
621
+ #
622
+ #
623
+ # 再增加第二个:
624
+ #
625
+ # RUN --mount=type=cache,id=dsh-kali-apt-lists,target=/var/lib/apt/lists,sharing=locked \
626
+ # --mount=type=cache,id=dsh-kali-apt-cache,target=/var/cache/apt,sharing=locked \
627
+ # apt-get update && \
628
+ # apt-get install -y --no-install-recommends \
629
+ # another-tool
630
+
631
+
632
+
633
+ # ── EXTRA CUSTOM ─────────────────────────────────────────────────────────────
634
+ #
635
+ # 示例:
636
+ #
637
+ # RUN \
638
+ # wget \
639
+ # -q \
640
+ # -O /pentester/tools/bin/some-tool \
641
+ # "https://github.com/example/some-tool/releases/download/v1.0/some-tool_linux_amd64" && \
642
+ # chmod +x /pentester/tools/bin/some-tool
643
+
644
+
645
+
646
+ # ── EXTRA PIPX ───────────────────────────────────────────────────────────────
647
+ #
648
+ # 示例:
649
+ #
650
+ # RUN --mount=type=cache,id=dsh-pip-cache,target=/root/.cache/pip \
651
+ # pipx install some-tool
652
+
653
+
654
+
655
+ # =============================================================================
656
+ # Agent Toolbox Interface
657
+ #
658
+ # /pentester 是 dsh-pentester-kali 的产品根目录:
659
+ # /pentester/VERSION
660
+ # /pentester/tools.json
661
+ # /pentester/bin/ — dsh-pentester 自身脚本 / Agent 接口
662
+ # /pentester/tools/bin/ — Go / 自定义可执行工具
663
+ # /pentester/tools/jars/ — Java JAR 工具资产
664
+ # /pentester/tools/pipx/ — pipx 隔离环境
665
+ # /pentester/kb/ — 知识库
666
+ #
667
+ # bin/ 是开发过程中最容易变化的部分,因此故意放到整个 Dockerfile 最后。
668
+ #
669
+ # 修改:
670
+ # tool-list
671
+ # tool-info
672
+ # gen-tools-json.sh
673
+ # 其他 toolbox scripts
674
+ #
675
+ # 不会再导致前面的 KB / Go / Stable Tools 重新构建。
676
+ # =============================================================================
677
+
678
+
679
+ # =============================================================================
680
+ # Image Version
681
+ #
682
+ # 版本唯一来源:docker/kali/VERSION
683
+ #
684
+ # 构建 CLI 读取 VERSION,并通过
685
+ # DSH_PENTESTER_KALI_VERSION build arg 注入镜像元数据;
686
+ # 同一值写入 OCI label、ENV 和 /pentester/VERSION。
687
+ #
688
+ # 故意放在 Dockerfile 后部:
689
+ # 单纯修改版本号不会使 APT / KB / Go 等昂贵层失效。
690
+ # =============================================================================
691
+
692
+ ARG DSH_PENTESTER_KALI_VERSION
693
+
694
+ LABEL org.opencontainers.image.title="dsh-pentester-kali" \
695
+ org.opencontainers.image.version="${DSH_PENTESTER_KALI_VERSION}"
696
+
697
+ ENV DSH_PENTESTER_KALI_VERSION="${DSH_PENTESTER_KALI_VERSION}"
698
+
699
+ COPY bin/ /pentester/bin/
700
+
701
+
702
+ # ── 工具目录生成 + 版本写入 + 清理 ───────────────────────────────────────────
703
+
704
+ RUN \
705
+ test -n "${DSH_PENTESTER_KALI_VERSION}" && \
706
+ chmod +x /pentester/bin/* && \
707
+ printf '%s\n' "${DSH_PENTESTER_KALI_VERSION}" \
708
+ > /pentester/VERSION && \
709
+ /pentester/bin/gen-tools-json.sh \
710
+ /pentester/tools.json && \
711
+ rm -rf \
712
+ /root/.cache \
713
+ /tmp/*
714
+
715
+
716
+ # ── proxychains → local mitmproxy :8080 ───────────────────────────────────────
717
+ #
718
+ # 默认不强制任何工具走代理。
719
+ # Agent 需要记录 HTTP(S) 明文流量时显式使用:
720
+ #
721
+ # proxychains curl https://example.com
722
+ # proxychains wget https://example.com
723
+ #
724
+ # proxychains 将 TCP 连接交给本容器 mitmproxy regular HTTP proxy :8080。
725
+ # -----------------------------------------------------------------------------
726
+
727
+ RUN \
728
+ printf '%s\n' \
729
+ 'strict_chain' \
730
+ 'proxy_dns' \
731
+ 'quiet_mode' \
732
+ 'tcp_read_time_out 15000' \
733
+ 'tcp_connect_time_out 8000' \
734
+ '' \
735
+ '[ProxyList]' \
736
+ 'http 127.0.0.1 8080' \
737
+ > /etc/proxychains4.conf && \
738
+ ln -sf /usr/bin/proxychains4 /usr/local/bin/proxychains
739
+
740
+ # =============================================================================
741
+ # 构建期自检
742
+ #
743
+ # 目的不是替代 tools.json,而是保证:
744
+ # - 核心 APT 工具真的可执行
745
+ # - Go Builder 产物真的被 COPY
746
+ # - pipx 工具 PATH 正确
747
+ # - 自定义二进制位置正确
748
+ # - Java JAR/wrapper 正确
749
+ # - 数据包存在
750
+ # - Agent toolbox catalog 可以正常工作
751
+ #
752
+ # 任一关键项缺失,镜像直接 build fail。
753
+ # =============================================================================
754
+
755
+ RUN \
756
+ test -d /pentester/tools/bin; \
757
+ test -d /pentester/tools/jars; \
758
+ test -d /pentester/tools/pipx; \
759
+ test -x /pentester/tools/bin/httpx; \
760
+ test -x /pentester/tools/bin/fscan; \
761
+ test -x /pentester/tools/bin/kscan; \
762
+ test -x /pentester/tools/bin/defaulthound; \
763
+ test -x /pentester/tools/bin/jc; \
764
+ test -x /pentester/tools/bin/mitmdump; \
765
+ \
766
+ required_commands=( \
767
+ git \
768
+ curl \
769
+ wget \
770
+ jq \
771
+ yq \
772
+ python3 \
773
+ pipx \
774
+ java \
775
+ go \
776
+ nmap \
777
+ masscan \
778
+ arp-scan \
779
+ ffuf \
780
+ gobuster \
781
+ feroxbuster \
782
+ nikto \
783
+ nuclei \
784
+ sqlmap \
785
+ hydra \
786
+ john \
787
+ hashcat \
788
+ smbclient \
789
+ evil-winrm \
790
+ exiftool \
791
+ binwalk \
792
+ radare2 \
793
+ gdb \
794
+ bettercap \
795
+ httpx \
796
+ katana \
797
+ naabu \
798
+ dnsx \
799
+ interactsh-client \
800
+ gospider \
801
+ gron \
802
+ usql \
803
+ fofax \
804
+ jc \
805
+ mitmdump \
806
+ fscan \
807
+ kscan \
808
+ defaulthound \
809
+ ysoserial \
810
+ marshalsec \
811
+ jndi-injection-exploit \
812
+ tool-list \
813
+ tool-info \
814
+ ); \
815
+ \
816
+ for cmd in "${required_commands[@]}"; do \
817
+ if ! command -v "${cmd}" >/dev/null 2>&1; then \
818
+ echo "ERROR: required command missing: ${cmd}" >&2; \
819
+ exit 1; \
820
+ fi; \
821
+ done; \
822
+ \
823
+ for jar in \
824
+ /pentester/tools/jars/ysoserial.jar \
825
+ /pentester/tools/jars/marshalsec.jar \
826
+ /pentester/tools/jars/JNDI-Injection-Exploit.jar; \
827
+ do \
828
+ if [[ ! -s "${jar}" ]]; then \
829
+ echo "ERROR: required jar missing: ${jar}" >&2; \
830
+ exit 1; \
831
+ fi; \
832
+ done; \
833
+ \
834
+ for pkg in \
835
+ seclists \
836
+ wordlists \
837
+ impacket-scripts \
838
+ netexec \
839
+ responder; \
840
+ do \
841
+ if ! dpkg-query \
842
+ -W \
843
+ -f='${Status}' \
844
+ "${pkg}" \
845
+ 2>/dev/null \
846
+ | grep -q '^install ok installed$'; \
847
+ then \
848
+ echo "ERROR: required package missing: ${pkg}" >&2; \
849
+ exit 1; \
850
+ fi; \
851
+ done; \
852
+ \
853
+ test -s /pentester/tools.json; \
854
+ test -x /pentester/bin/tool-list; \
855
+ test -x /pentester/bin/tool-info; \
856
+ test -s /pentester/VERSION; \
857
+ test "$(cat /pentester/VERSION)" = "${DSH_PENTESTER_KALI_VERSION}"; \
858
+ \
859
+ tool-list >/dev/null; \
860
+ tool-info nmap >/dev/null; \
861
+ tool-info httpx >/dev/null; \
862
+ \
863
+ echo "Toolbox self-check: OK"
864
+
865
+
866
+
867
+ # 构建代理不泄漏进成品镜像。
868
+ #
869
+ # 本版本没有通过 ENV 写入构建代理,因此这里无需再显式清空
870
+ # http_proxy / https_proxy / no_proxy。
871
+
872
+
873
+ # PROMPT and some skills
874
+ COPY TOOL_PROMPT.md /pentester/PROMPT.md
875
+ COPY REPORT_TEMPLATE.md /pentester/REPORT_TEMPLATE.md
876
+
877
+ WORKDIR /workspace
878
+
879
+ ENTRYPOINT ["/pentester/bin/entrypoint.sh"]
880
+
881
+ CMD ["sleep", "infinity"]