dsh-blue-team-mode 1.1.0 → 1.1.1

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/DISCLOSURE CHANGED
@@ -19,3 +19,11 @@
19
19
 
20
20
  ## 无担保
21
21
  本插件按 MIT 许可“原样”提供,不附带任何明示或暗示担保。使用者对自身行为及后果负责。
22
+
23
+ ## 生产使用与责任边界
24
+ - 本插件是**蓝队编排与事实记录工具**,不是 EDR、IPS、WAF、防火墙或备份系统;不承诺拦截、阻断或恢复任何攻击。
25
+ - 真实服务器使用前,必须自行完成授权、变更评审、备份、回滚演练和独立安全评估;不要把本插件当作唯一防线。
26
+ - 诱饵能力默认只登记、不自动部署;部署位置、合成数据、日志留存和隐私合规由使用者负责。
27
+ - 在适用法律允许的范围内,作者与贡献者不对因使用或无法使用本插件造成的直接、间接、附带或后果性损失承担责任;法律不允许排除的责任除外。
28
+ - 若用于商业产品或对客服务,请自行咨询律师,并评估产品责任、数据处理与网络安全合规义务。
29
+
package/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
  > ⚠️ **仅限已获授权的 CTF 靶场 / 攻防演练 / 自有资产防守使用。**
6
6
  > 本插件只做防守侧的采集、比对、编排、取证与记录,**不包含任何攻击、漏洞利用或未授权探测代码**。
7
7
  > 使用者必须确保对目标拥有书面授权,并遵守比赛规则。
8
+ >
9
+ > **本插件不是 EDR/IPS/WAF/防火墙/备份系统,不承诺拦截或恢复攻击。** 真实服务器使用前请自行完成授权、备份、回滚演练与独立安全评估;不要把它当作唯一防线。详见 `DISCLOSURE`。
8
10
 
9
11
  ---
10
12
 
@@ -50,13 +52,13 @@ dsh plugin --profile desktop add dsh-blue-team-mode
50
52
  plugin_manager action=install_bundle target="dsh-blue-team-mode"
51
53
  ```
52
54
 
53
- 包名 `dsh-blue-team-mode`,当前版本 `1.1.0`;`dsh.bundle` 指向包内的 `cordis.patch.yml`。npm 安装不需要 `allowBuilds`,也不依赖本机源码目录。
55
+ 包名 `dsh-blue-team-mode`,当前版本 `1.1.1`;`dsh.bundle` 指向包内的 `cordis.patch.yml`。npm 安装不需要 `allowBuilds`,也不依赖本机源码目录。
54
56
 
55
57
  ### 从本地 tarball 安装
56
58
 
57
59
  ```sh
58
60
  npm pack --pack-destination dist
59
- dsh plugin --profile desktop add .\dist\dsh-blue-team-mode-1.1.0.tgz
61
+ dsh plugin --profile desktop add .\dist\dsh-blue-team-mode-1.1.1.tgz
60
62
  ```
61
63
 
62
64
  ### 从本地目录安装
@@ -161,7 +163,7 @@ blue_defense_selfcheck phrase="防御自检"
161
163
  蓝队模式内置一层**克制的诱饵能力**,用于授权靶场和自有资产:
162
164
 
163
165
  - `blue_deception_plan`:生成金丝雀文件/URL、假管理入口、假凭据、低交互 tarpit 方案。
164
- - `blue_decoy_create`:登记诱饵并生成唯一 token;必须 `authorized=true`,目标必须在 `engagement.scope` 内。
166
+ - `blue_decoy_create`:登记诱饵并生成唯一 token;必须 `authorized=true`,目标必须在 `engagement.scope` 内;默认 24 小时、最大 168 小时后自动取消/标记 retired。
165
167
  - `blue_decoy_hit`:记录命中并生成 `deception` 来源告警,不自动反击。
166
168
  - `blue_decoy_list`:查看状态、命中次数、最近命中时间。
167
169
 
@@ -171,6 +173,7 @@ blue_defense_selfcheck phrase="防御自检"
171
173
  - 不收集 WebRTC 真实 IP、Canvas/硬件指纹、浏览器历史。
172
174
  - 不做全屏锁定、无限弹窗、无法退出或心理恐吓。
173
175
  - 不自动部署、不自动封禁/删除;命中只作为证据和告警。
176
+ - 到期后插件只把事实库状态改为 `retired`,不会操作真实部署;真实诱饵必须由部署者自行下线。
174
177
 
175
178
  详见 `skills/deception-defense.md`。
176
179
 
package/lib/client.js CHANGED
@@ -125,6 +125,7 @@ window.__ModuleLoader__.load({
125
125
  "noIocs": "暂无 IOC",
126
126
  "noDecoys": "暂无诱饵。用 blue_decoy_create 登记后再部署。",
127
127
  "hits": "命中",
128
+ "expires": "到期",
128
129
  "decoyHitRate": "命中率 {rate}%",
129
130
  "decoySources": "来源分布",
130
131
  "decoySourceHint": "按命中记录的服务端来源聚合",
@@ -300,6 +301,7 @@ window.__ModuleLoader__.load({
300
301
  "noIocs": "No IOC",
301
302
  "noDecoys": "No decoys. Register one with blue_decoy_create before deployment.",
302
303
  "hits": "Hits",
304
+ "expires": "Expires",
303
305
  "decoyHitRate": "Hit rate {rate}%",
304
306
  "decoySources": "Source breakdown",
305
307
  "decoySourceHint": "Aggregated from server-side hit records",
@@ -1391,12 +1393,13 @@ div:has(> [data-shell-overlay] .bt-dock[data-open="1"])[data-rightbar-fullscreen
1391
1393
  decoys.length === 0
1392
1394
  ? h(Empty, { title: t("noDecoys"), icon: h(ShieldIcon, { size: 20 }) })
1393
1395
  : h("div", { className: "bt-table-wrap" }, h("table", { className: "bt-table" },
1394
- h("thead", null, h("tr", null, h("th", null, t("name")), h("th", null, t("kind")), h("th", null, t("target")), h("th", null, t("status")), h("th", null, t("hits")))),
1396
+ h("thead", null, h("tr", null, h("th", null, t("name")), h("th", null, t("kind")), h("th", null, t("target")), h("th", null, t("status")), h("th", null, t("expires")), h("th", null, t("hits")))),
1395
1397
  h("tbody", null, decoys.map((decoy) => h("tr", { key: decoy.id },
1396
1398
  h("td", null, h("div", { className: "bt-cell-title" }, decoy.name), h("div", { className: "bt-cell-meta" }, decoy.id)),
1397
1399
  h("td", null, decoy.kind),
1398
1400
  h("td", null, h("span", { style: { fontFamily: "ui-monospace, Menlo, monospace", fontSize: 10.5 } }, decoy.target)),
1399
1401
  h("td", null, h(Badge, { tone: decoy.status === "active" ? "ok" : decoy.status === "retired" ? "muted" : "warn" }, decoy.status)),
1402
+ h("td", null, decoy.expires_at ? timeText(decoy.expires_at) : "—"),
1400
1403
  h("td", null, String(decoy.hit_count || 0), decoy.last_hit_at ? h("div", { className: "bt-cell-meta" }, timeText(decoy.last_hit_at)) : null)))))));
1401
1404
  };
1402
1405
 
package/lib/store.js CHANGED
@@ -108,6 +108,7 @@ CREATE TABLE IF NOT EXISTS decoys (
108
108
  note TEXT NOT NULL DEFAULT '',
109
109
  hit_count INTEGER NOT NULL DEFAULT 0,
110
110
  last_hit_at TEXT,
111
+ expires_at TEXT,
111
112
  created_at TEXT NOT NULL,
112
113
  updated_at TEXT NOT NULL,
113
114
  UNIQUE (engagement_id, token)
@@ -299,6 +300,9 @@ export class BlueStore {
299
300
  ['first_seen', "TEXT NOT NULL DEFAULT ''"],
300
301
  ['last_seen', "TEXT NOT NULL DEFAULT ''"],
301
302
  ])
303
+ add('decoys', [
304
+ ['expires_at', 'TEXT'],
305
+ ])
302
306
  this.db.exec("UPDATE iocs SET first_seen = COALESCE(NULLIF(first_seen, ''), created_at), last_seen = COALESCE(NULLIF(last_seen, ''), created_at)")
303
307
  this.db.exec('CREATE INDEX IF NOT EXISTS idx_tasks_approval ON tasks (engagement_id, status, risk_level)')
304
308
  }
@@ -631,12 +635,15 @@ export class BlueStore {
631
635
  if (target === '') throw new Error('诱饵目标不能为空')
632
636
  const status = DECOY_STATUSES.includes(asText(input.status)) ? asText(input.status) : 'planned'
633
637
  const token = asText(input.token).trim() || `DECOY-${randomUUID().replace(/-/g, '')}`
638
+ const ttlHours = Math.min(Math.max(Number(input.ttl_hours) || 24, 1), 168)
639
+ const expiresAt = asText(input.expires_at).trim()
640
+ || new Date(Date.now() + ttlHours * 3600 * 1000).toISOString()
634
641
  const id = newId('DEC')
635
642
  const at = now()
636
643
  this.sql(`INSERT INTO decoys
637
- (id, engagement_id, kind, name, target, token, status, note, hit_count, last_hit_at, created_at, updated_at)
638
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, NULL, ?, ?)`)
639
- .run(id, engagementId, kind, name, target, token, status, asText(input.note), at, at)
644
+ (id, engagement_id, kind, name, target, token, status, note, hit_count, last_hit_at, expires_at, created_at, updated_at)
645
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, NULL, ?, ?, ?)`)
646
+ .run(id, engagementId, kind, name, target, token, status, asText(input.note), expiresAt, at, at)
640
647
  this.addTimeline(engagementId, {
641
648
  actor: asText(input.actor, 'commander'),
642
649
  action: 'decoy_create',
@@ -650,7 +657,26 @@ export class BlueStore {
650
657
  return this.sql('SELECT * FROM decoys WHERE id = ?').get(id) ?? null
651
658
  }
652
659
 
660
+ /** 到期的诱饵自动取消/下线;只改事实库状态,不会操作真实部署。 */
661
+ expireDecoys(engagementId) {
662
+ const at = now()
663
+ const expired = this.sql(`SELECT id, name FROM decoys
664
+ WHERE engagement_id = ? AND status <> 'retired'
665
+ AND expires_at IS NOT NULL AND expires_at <= ?`).all(engagementId, at)
666
+ for (const decoy of expired) {
667
+ this.sql("UPDATE decoys SET status = 'retired', updated_at = ? WHERE id = ?").run(at, decoy.id)
668
+ this.addTimeline(engagementId, {
669
+ actor: 'system',
670
+ action: 'decoy_expire',
671
+ target: decoy.name,
672
+ detail: `decoy=${decoy.id} 自动取消(到期)`,
673
+ })
674
+ }
675
+ return expired.length
676
+ }
677
+
653
678
  listDecoys(engagementId, filters = {}) {
679
+ this.expireDecoys(engagementId)
654
680
  const clauses = ['engagement_id = ?']
655
681
  const params = [engagementId]
656
682
  for (const field of ['status', 'kind']) {
@@ -927,6 +953,7 @@ export class BlueStore {
927
953
  }
928
954
 
929
955
  stats(engagementId) {
956
+ this.expireDecoys(engagementId)
930
957
  const stats = {
931
958
  assets: this.count('SELECT COUNT(*) AS n FROM assets WHERE engagement_id = ?', engagementId),
932
959
  assets_critical: this.count(
package/lib/tools.js CHANGED
@@ -683,6 +683,7 @@ export function apply(ctx, config = {}) {
683
683
  name: { type: 'string', required: true },
684
684
  target: { type: 'string', required: true, description: '授权范围内的目标主机/URL' },
685
685
  note: { type: 'string' },
686
+ ttl_hours: { type: 'number', description: '自动取消/下线时限,默认 24,最大 168 小时' },
686
687
  authorized: { type: 'boolean', required: true, description: '必须为 true:确认目标已授权且在本场 scope 内' },
687
688
  },
688
689
  output: STRING_OUTPUT,
@@ -701,6 +702,7 @@ export function apply(ctx, config = {}) {
701
702
  name: asText(args.name),
702
703
  target,
703
704
  note: asText(args.note),
705
+ ttl_hours: asInt(args.ttl_hours, 24),
704
706
  status: 'planned',
705
707
  actor: 'commander',
706
708
  })
@@ -708,7 +710,7 @@ export function apply(ctx, config = {}) {
708
710
  ok: true,
709
711
  decoy,
710
712
  deployment: DECOY_TEMPLATES.find((item) => item.kind === kind),
711
- safety: '只登记,不自动部署;使用合成数据;命中只告警,不自动反击。',
713
+ safety: `只登记,不自动部署;${decoy.expires_at} 到期后事实库会自动取消/标记 retired;使用合成数据;命中只告警,不自动反击。`,
712
714
  })
713
715
  }),
714
716
  }))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-blue-team-mode",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "CTF 网络攻防蓝队防御模式:资产盘点、告警研判、威胁狩猎、应急响应、取证分析与加固修复,内置 SQLite 事实库、独立右侧栏控制台与自主任务派发队列。",
5
5
  "license": "MIT",
6
6
  "author": "FGCGDroid",
@@ -233,8 +233,13 @@ const hit = await call('blue_decoy_hit', {
233
233
  if (!hit.ok || hit.decoy.hit_count !== 1 || hit.alert.source !== 'deception') throw new Error('诱饵命中未落库')
234
234
  const decoys = await call('blue_decoy_list', {})
235
235
  if (decoys.decoys.length !== 1) throw new Error('诱饵列表异常')
236
+ if (!decoys.decoys[0].expires_at) throw new Error('诱饵缺少 expires_at')
236
237
  const defenseWithDecoy = await call('blue_defense_status', {})
237
238
  if (defenseWithDecoy.stats.decoys !== 1 || defenseWithDecoy.stats.decoy_hits !== 1) throw new Error('诱饵统计异常')
239
+ store.sql('UPDATE decoys SET expires_at = ? WHERE id = ?').run(new Date(Date.now() - 1000).toISOString(), decoy.decoy.id)
240
+ const expired = await call('blue_decoy_list', {})
241
+ if (expired.decoys[0].status !== 'retired') throw new Error('到期诱饵未自动取消')
242
+ if (expired.decoys[0].expires_at === null) throw new Error('到期诱饵丢失 expires_at')
238
243
 
239
244
  // bug 回归:控制台只写 JSON 绑定,工具侧内存 Map 过期时也要从磁盘同步。
240
245
  const second = store.openEngagement('第二目标', ['10.20.0.0/24'])
@@ -16,8 +16,8 @@ description: 授权范围内的欺骗防御:金丝雀文件/URL、假管理入
16
16
  ## 工作流
17
17
 
18
18
  1. `blue_deception_plan`:查看可用的诱饵模板与安全边界。
19
- 2. `blue_decoy_create`:登记诱饵;必须 `authorized=true`,且目标在 scope 内。
20
- 3. 人工在授权资产上部署;工具不会自动部署,也不会开启监听端口。
19
+ 2. `blue_decoy_create`:登记诱饵;必须 `authorized=true`,且目标在 scope 内;默认 24 小时、最大 168 小时后自动取消/标记 retired。
20
+ 3. 人工在授权资产上部署;工具不会自动部署,也不会开启监听端口;到期只改事实库状态,真实部署需人工下线。
21
21
  4. `blue_decoy_hit`:把访问记录、来源 IP、请求行作为证据落库;自动生成 `deception` 来源告警。
22
22
  5. `blue_decoy_list`:查看状态、命中次数、最近命中时间。
23
23
  6. 命中后按告警研判流程处理;需要隔离/封禁时先建 high 风险任务并走人工审批。