ccgx-workflow 1.0.0 → 1.0.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.
Files changed (60) hide show
  1. package/README.md +37 -5
  2. package/README.zh-CN.md +35 -5
  3. package/dist/cli.mjs +1 -1
  4. package/dist/index.mjs +2 -2
  5. package/dist/shared/{ccgx-workflow.WgUzkiC3.mjs → ccgx-workflow.SJPbUy5_.mjs} +17 -110
  6. package/package.json +2 -1
  7. package/templates/commands/agents/phase-runner.md +321 -321
  8. package/templates/commands/autonomous.md +792 -792
  9. package/templates/commands/cancel.md +132 -132
  10. package/templates/commands/debug.md +226 -226
  11. package/templates/commands/status.md +206 -206
  12. package/templates/commands/team.md +484 -0
  13. package/templates/hooks/ccg-session-state.cjs +510 -510
  14. package/templates/scripts/ccg-phase-runner-launcher.mjs +467 -467
  15. package/templates/scripts/invoke-model.mjs +64 -0
  16. package/templates/skills/domains/ai/SKILL.md +35 -35
  17. package/templates/skills/domains/ai/agent-dev.md +242 -242
  18. package/templates/skills/domains/ai/llm-security.md +288 -288
  19. package/templates/skills/domains/ai/rag-system.md +542 -542
  20. package/templates/skills/domains/architecture/SKILL.md +43 -43
  21. package/templates/skills/domains/architecture/api-design.md +225 -225
  22. package/templates/skills/domains/architecture/cloud-native.md +285 -285
  23. package/templates/skills/domains/architecture/security-arch.md +297 -297
  24. package/templates/skills/domains/data-engineering/SKILL.md +208 -208
  25. package/templates/skills/domains/development/SKILL.md +47 -47
  26. package/templates/skills/domains/development/cpp.md +246 -246
  27. package/templates/skills/domains/development/go.md +323 -323
  28. package/templates/skills/domains/development/java.md +277 -277
  29. package/templates/skills/domains/development/python.md +288 -288
  30. package/templates/skills/domains/development/rust.md +313 -313
  31. package/templates/skills/domains/development/shell.md +313 -313
  32. package/templates/skills/domains/development/typescript.md +277 -277
  33. package/templates/skills/domains/devops/SKILL.md +40 -40
  34. package/templates/skills/domains/devops/database.md +217 -217
  35. package/templates/skills/domains/devops/devsecops.md +198 -198
  36. package/templates/skills/domains/devops/git-workflow.md +181 -181
  37. package/templates/skills/domains/devops/testing.md +283 -283
  38. package/templates/skills/domains/frontend-design/SKILL.md +244 -244
  39. package/templates/skills/domains/frontend-design/claymorphism/SKILL.md +121 -121
  40. package/templates/skills/domains/frontend-design/component-patterns.md +202 -202
  41. package/templates/skills/domains/frontend-design/glassmorphism/SKILL.md +142 -142
  42. package/templates/skills/domains/frontend-design/liquid-glass/SKILL.md +139 -139
  43. package/templates/skills/domains/frontend-design/neubrutalism/SKILL.md +145 -145
  44. package/templates/skills/domains/frontend-design/state-management.md +680 -680
  45. package/templates/skills/domains/frontend-design/ui-aesthetics.md +110 -110
  46. package/templates/skills/domains/frontend-design/ux-principles.md +156 -156
  47. package/templates/skills/domains/infrastructure/SKILL.md +201 -201
  48. package/templates/skills/domains/mobile/SKILL.md +225 -225
  49. package/templates/skills/domains/orchestration/SKILL.md +30 -30
  50. package/templates/skills/domains/orchestration/multi-agent.md +228 -228
  51. package/templates/skills/domains/security/SKILL.md +73 -73
  52. package/templates/skills/domains/security/blue-team.md +436 -436
  53. package/templates/skills/domains/security/code-audit.md +265 -265
  54. package/templates/skills/domains/security/pentest.md +226 -226
  55. package/templates/skills/domains/security/red-team.md +374 -374
  56. package/templates/skills/domains/security/threat-intel.md +372 -372
  57. package/templates/skills/domains/security/vuln-research.md +369 -369
  58. package/templates/skills/tools/lib/shared.js +98 -98
  59. package/templates/skills/tools/override-refusal/SKILL.md +53 -53
  60. package/templates/skills/tools/override-refusal/scripts/refusal_rewriter.js +226 -226
@@ -1,436 +1,436 @@
1
- ---
2
- name: blue-team
3
- description: 蓝队防御技术。检测工程、SOC运营、应急响应、数字取证。当用户提到蓝队、检测规则、Sigma、YARA、SIEM、告警、应急响应、取证、SOC时使用。
4
- ---
5
-
6
- # ❄ 玄冰秘典 · 蓝队防御 (Blue Team)
7
-
8
-
9
- ## 防御链
10
-
11
- ```
12
- 预防 → 检测 → 响应 → 恢复
13
- │ │ │ │
14
- └─ 加固 ─┴─ SIEM ─┴─ IR ─┴─ 取证
15
- ```
16
-
17
- ## 检测工程
18
-
19
- ### Sigma 规则
20
-
21
- ```yaml
22
- # Mimikatz 检测
23
- title: Mimikatz Credential Dumping
24
- id: 0d65953c-7f75-4f4b-9a16-8b8f9f2b6d5e
25
- status: stable
26
- description: Detects Mimikatz credential dumping via LSASS access
27
- references:
28
- - https://attack.mitre.org/techniques/T1003/001/
29
- tags:
30
- - attack.credential_access
31
- - attack.t1003.001
32
- logsource:
33
- category: process_access
34
- product: windows
35
- detection:
36
- selection:
37
- TargetImage|endswith: '\lsass.exe'
38
- GrantedAccess:
39
- - '0x1010'
40
- - '0x1038'
41
- - '0x1410'
42
- filter_system:
43
- SourceImage|startswith:
44
- - 'C:\Windows\System32\'
45
- condition: selection and not filter_system
46
- level: high
47
- ---
48
- # 可疑 PowerShell
49
- title: Suspicious PowerShell Download
50
- logsource:
51
- category: process_creation
52
- product: windows
53
- detection:
54
- selection:
55
- CommandLine|contains:
56
- - 'IEX'
57
- - 'Invoke-Expression'
58
- - 'DownloadString'
59
- - 'Net.WebClient'
60
- - '-enc'
61
- - 'FromBase64String'
62
- condition: selection
63
- level: high
64
- ---
65
- # DCSync 检测
66
- title: DCSync Attack
67
- logsource:
68
- product: windows
69
- service: security
70
- detection:
71
- selection:
72
- EventID: 4662
73
- Properties|contains:
74
- - '1131f6ad-9c07-11d1-f79f-00c04fc2dcd2'
75
- - '1131f6aa-9c07-11d1-f79f-00c04fc2dcd2'
76
- filter_dc:
77
- SubjectUserName|endswith: '$'
78
- condition: selection and not filter_dc
79
- level: critical
80
- ```
81
-
82
- ### Sigma 转换
83
- ```bash
84
- # 安装
85
- pip install sigma-cli
86
-
87
- # 转换为各平台格式
88
- sigma convert -t splunk -p sysmon rules/
89
- sigma convert -t elasticsearch rules/
90
- sigma convert -t azure-monitor rules/
91
- ```
92
-
93
- ### YARA 规则
94
-
95
- ```yara
96
- rule Mimikatz_Memory {
97
- meta:
98
- description = "Detects Mimikatz in memory"
99
- severity = "critical"
100
- strings:
101
- $s1 = "mimikatz" ascii wide nocase
102
- $s2 = "sekurlsa::logonpasswords" ascii wide
103
- $s3 = "lsadump::dcsync" ascii wide
104
- $func = "kuhl_m_" ascii
105
- condition:
106
- 2 of ($s*) or $func
107
- }
108
-
109
- rule Cobalt_Strike_Beacon {
110
- meta:
111
- description = "Detects Cobalt Strike Beacon"
112
- strings:
113
- $config = { 69 68 69 68 69 6B 69 68 }
114
- $sleep = "sleeptime" ascii
115
- $jitter = "jitter" ascii
116
- condition:
117
- $config or all of ($sleep, $jitter)
118
- }
119
-
120
- rule Webshell_Generic {
121
- meta:
122
- description = "Generic webshell detection"
123
- strings:
124
- $php = "<?php" nocase
125
- $eval = /eval\s*\(\s*\$_(GET|POST|REQUEST)/ nocase
126
- $system = /system\s*\(\s*\$_(GET|POST)/ nocase
127
- condition:
128
- $php and any of ($eval, $system)
129
- }
130
- ```
131
-
132
- ## 关键日志源
133
-
134
- ### Windows 安全日志
135
- ```python
136
- CRITICAL_EVENTS = {
137
- # 登录事件
138
- '4624': 'Successful Logon',
139
- '4625': 'Failed Logon',
140
- '4648': 'Explicit Credential Logon',
141
-
142
- # 进程事件
143
- '4688': 'Process Creation',
144
- '4689': 'Process Termination',
145
-
146
- # 账户事件
147
- '4720': 'User Account Created',
148
- '4728': 'Member Added to Security Group',
149
- '4732': 'Member Added to Local Group',
150
-
151
- # Kerberos
152
- '4768': 'TGT Request',
153
- '4769': 'Service Ticket Request',
154
- '4771': 'Pre-Auth Failed',
155
-
156
- # 目录服务
157
- '4662': 'Directory Service Access',
158
- }
159
- ```
160
-
161
- ### Sysmon 事件
162
- ```python
163
- SYSMON_EVENTS = {
164
- '1': 'Process Create',
165
- '3': 'Network Connection',
166
- '7': 'Image Loaded',
167
- '8': 'CreateRemoteThread',
168
- '10': 'ProcessAccess',
169
- '11': 'FileCreate',
170
- '12': 'Registry Key Create/Delete',
171
- '13': 'Registry Value Set',
172
- '17': 'Pipe Created',
173
- '22': 'DNS Query',
174
- '23': 'FileDelete',
175
- }
176
- ```
177
-
178
- ## SOC 运营
179
-
180
- ### 告警分级
181
- ```yaml
182
- P1 - Critical (15分钟响应):
183
- - 确认的入侵活动
184
- - 勒索软件执行
185
- - 数据外泄
186
- - 特权账户被控
187
-
188
- P2 - High (1小时响应):
189
- - 可疑横向移动
190
- - 凭证窃取尝试
191
- - C2 通信检测
192
- - 异常特权操作
193
-
194
- P3 - Medium (4小时响应):
195
- - 可疑进程执行
196
- - 异常网络连接
197
- - 策略违规
198
-
199
- P4 - Low (24小时响应):
200
- - 信息性告警
201
- - 合规检查
202
- ```
203
-
204
- ### 告警质量指标
205
- ```python
206
- class AlertMetrics:
207
- def calculate(self, alerts):
208
- total = len(alerts)
209
- tp = sum(1 for a in alerts if a['verified'] == 'true_positive')
210
- fp = sum(1 for a in alerts if a['verified'] == 'false_positive')
211
-
212
- return {
213
- 'true_positive_rate': tp / total * 100,
214
- 'false_positive_rate': fp / total * 100,
215
- 'mean_time_to_detect': self._mttd(alerts),
216
- 'mean_time_to_respond': self._mttr(alerts),
217
- }
218
- ```
219
-
220
- ## 应急响应
221
-
222
- ### IR 流程
223
- ```
224
- ┌─────────────────────────────────────────────────────────────┐
225
- │ 应急响应流程 │
226
- ├─────────────────────────────────────────────────────────────┤
227
- │ 1. 准备 (Preparation) │
228
- │ └─ 工具准备、流程文档、联系人清单 │
229
- │ ↓ │
230
- │ 2. 识别 (Identification) │
231
- │ └─ 确认事件、评估范围、初步分类 │
232
- │ ↓ │
233
- │ 3. 遏制 (Containment) │
234
- │ └─ 隔离系统、阻断通信、保护证据 │
235
- │ ↓ │
236
- │ 4. 根除 (Eradication) │
237
- │ └─ 清除恶意软件、修复漏洞、重置凭证 │
238
- │ ↓ │
239
- │ 5. 恢复 (Recovery) │
240
- │ └─ 系统恢复、监控加强、业务恢复 │
241
- │ ↓ │
242
- │ 6. 总结 (Lessons Learned) │
243
- │ └─ 事件报告、改进措施、知识沉淀 │
244
- └─────────────────────────────────────────────────────────────┘
245
- ```
246
-
247
- ### 快速遏制
248
- ```bash
249
- # Windows - 隔离主机
250
- netsh advfirewall set allprofiles state on
251
- netsh advfirewall firewall add rule name="Block All" dir=out action=block
252
-
253
- # Linux - 隔离主机
254
- iptables -P INPUT DROP
255
- iptables -P OUTPUT DROP
256
- iptables -A INPUT -s TRUSTED_IP -j ACCEPT
257
-
258
- # 禁用账户
259
- net user compromised_user /active:no
260
- passwd -l compromised_user
261
-
262
- # 终止恶意进程
263
- taskkill /F /PID <pid>
264
- kill -9 <pid>
265
- ```
266
-
267
- ### 证据收集
268
- ```bash
269
- # Windows
270
- wmic process list full > processes.txt
271
- netstat -ano > netstat.txt
272
- reg export HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run run.reg
273
- wevtutil epl Security security.evtx
274
-
275
- # Linux
276
- ps auxf > processes.txt
277
- netstat -tulpn > netstat.txt
278
- cat /etc/passwd > passwd.txt
279
- last > logins.txt
280
- cp /var/log/auth.log .
281
- ```
282
-
283
- ## 数字取证
284
-
285
- ### 内存取证
286
- ```bash
287
- # 内存获取
288
- # Windows - WinPMEM
289
- winpmem_mini_x64.exe memory.raw
290
-
291
- # Linux - LiME
292
- insmod lime.ko "path=/tmp/memory.lime format=lime"
293
-
294
- # 分析 - Volatility
295
- vol.py -f memory.raw imageinfo
296
- vol.py -f memory.raw --profile=Win10x64 pslist
297
- vol.py -f memory.raw --profile=Win10x64 netscan
298
- vol.py -f memory.raw --profile=Win10x64 malfind
299
- vol.py -f memory.raw --profile=Win10x64 dlllist
300
- ```
301
-
302
- ### 磁盘取证
303
- ```bash
304
- # 镜像获取
305
- dd if=/dev/sda of=disk.img bs=4M status=progress
306
-
307
- # 挂载分析
308
- mount -o ro,loop disk.img /mnt/evidence
309
-
310
- # 时间线分析
311
- log2timeline.py timeline.plaso disk.img
312
- psort.py -o l2tcsv timeline.plaso -w timeline.csv
313
-
314
- # 文件恢复
315
- foremost -i disk.img -o recovered/
316
- photorec disk.img
317
- ```
318
-
319
- ### 日志分析
320
- ```bash
321
- # Windows 事件日志
322
- # 使用 EvtxECmd 解析
323
- EvtxECmd.exe -f Security.evtx --csv output/
324
-
325
- # Linux 日志
326
- grep "Failed password" /var/log/auth.log
327
- grep "Accepted" /var/log/auth.log | awk '{print $1,$2,$3,$9,$11}'
328
- zcat /var/log/auth.log.*.gz | grep "sudo"
329
- ```
330
-
331
- ## 威胁狩猎
332
-
333
- ### 狩猎假设
334
- ```yaml
335
- # 基于 ATT&CK 的狩猎假设
336
- hypothesis: "攻击者可能使用 PowerShell 下载并执行恶意代码"
337
- technique: T1059.001
338
- data_sources:
339
- - Windows PowerShell 日志
340
- - Sysmon 进程创建
341
- query: |
342
- EventID=4104 AND ScriptBlockText CONTAINS ("IEX" OR "DownloadString")
343
- ```
344
-
345
- ### 狩猎查询示例
346
- ```sql
347
- -- 异常父子进程关系
348
- SELECT parent_name, process_name, command_line
349
- FROM processes
350
- WHERE parent_name = 'winword.exe'
351
- AND process_name IN ('cmd.exe', 'powershell.exe', 'wscript.exe')
352
-
353
- -- 异常网络连接
354
- SELECT process_name, remote_address, remote_port
355
- FROM network_connections
356
- WHERE remote_port NOT IN (80, 443, 53)
357
- AND process_name NOT IN ('chrome.exe', 'firefox.exe')
358
-
359
- -- 可疑计划任务
360
- SELECT name, command, trigger
361
- FROM scheduled_tasks
362
- WHERE command LIKE '%powershell%' OR command LIKE '%cmd%'
363
- ```
364
-
365
- ## 工具清单
366
-
367
- | 工具 | 用途 |
368
- |------|------|
369
- | Sigma | 通用检测规则 |
370
- | YARA | 恶意软件检测 |
371
- | Splunk/Elastic | SIEM 平台 |
372
- | Volatility | 内存取证 |
373
- | Autopsy | 磁盘取证 |
374
- | Velociraptor | 端点响应 |
375
- | TheHive | 事件管理 |
376
- | MISP | 威胁情报 |
377
-
378
- ## 密钥管理
379
-
380
- ### 密钥生命周期
381
- ```
382
- 生成 → 存储 → 分发 → 使用 → 轮转 → 撤销 → 销毁
383
- ```
384
-
385
- ### 核心工具
386
- | 工具 | 类型 | 特点 |
387
- |------|------|------|
388
- | HashiCorp Vault | 平台 | 动态密钥、AppRole、多后端 |
389
- | AWS KMS | 云服务 | 托管密钥、信封加密、自动轮转 |
390
- | AWS Secrets Manager | 云服务 | 自动轮转、Lambda集成 |
391
- | Sealed Secrets | K8s | GitOps 友好、加密存储 |
392
- | External Secrets | K8s | 多后端同步(Vault/AWS/GCP) |
393
-
394
- ### 密钥管理检查清单
395
- ```yaml
396
- 生成与存储:
397
- - [ ] 加密强随机数生成器
398
- - [ ] 密钥长度符合标准(AES-256, RSA-2048+)
399
- - [ ] 集中存储在密钥管理系统 + 静态加密 + 访问控制
400
-
401
- 分发与使用:
402
- - [ ] 最小权限 + 短期凭证优先(动态密钥)
403
- - [ ] 禁止硬编码,使用环境变量或挂载卷
404
- - [ ] 传输加密(TLS)
405
-
406
- 轮转与撤销:
407
- - [ ] 定期自动轮转(P0年度/P1季度/P2月度/P3小时)
408
- - [ ] 支持紧急撤销 + 轮转后验证 + 审计日志
409
-
410
- 监控:
411
- - [ ] 记录所有密钥访问 + 异常检测告警 + 定期合规审计
412
- ```
413
-
414
- ### Vault 关键操作速查
415
- ```bash
416
- # KV 读写
417
- vault kv put secret/myapp/config db_password="xxx" api_key="yyy"
418
- vault kv get -field=db_password secret/myapp/config
419
-
420
- # 动态数据库凭证
421
- vault read database/creds/readonly
422
-
423
- # AppRole 登录
424
- vault write auth/approle/login role_id="<id>" secret_id="<id>"
425
- ```
426
-
427
- ### 密钥分类策略
428
- | 级别 | 类型 | 轮转周期 | 存储 |
429
- |------|------|----------|------|
430
- | P0 | 根密钥、主密钥 | 年度 | HSM |
431
- | P1 | 数据加密密钥 | 季度 | Vault |
432
- | P2 | API 密钥 | 月度 | Secrets Manager |
433
- | P3 | 会话令牌 | 小时 | Redis |
434
-
435
- ---
436
-
1
+ ---
2
+ name: blue-team
3
+ description: 蓝队防御技术。检测工程、SOC运营、应急响应、数字取证。当用户提到蓝队、检测规则、Sigma、YARA、SIEM、告警、应急响应、取证、SOC时使用。
4
+ ---
5
+
6
+ # ❄ 玄冰秘典 · 蓝队防御 (Blue Team)
7
+
8
+
9
+ ## 防御链
10
+
11
+ ```
12
+ 预防 → 检测 → 响应 → 恢复
13
+ │ │ │ │
14
+ └─ 加固 ─┴─ SIEM ─┴─ IR ─┴─ 取证
15
+ ```
16
+
17
+ ## 检测工程
18
+
19
+ ### Sigma 规则
20
+
21
+ ```yaml
22
+ # Mimikatz 检测
23
+ title: Mimikatz Credential Dumping
24
+ id: 0d65953c-7f75-4f4b-9a16-8b8f9f2b6d5e
25
+ status: stable
26
+ description: Detects Mimikatz credential dumping via LSASS access
27
+ references:
28
+ - https://attack.mitre.org/techniques/T1003/001/
29
+ tags:
30
+ - attack.credential_access
31
+ - attack.t1003.001
32
+ logsource:
33
+ category: process_access
34
+ product: windows
35
+ detection:
36
+ selection:
37
+ TargetImage|endswith: '\lsass.exe'
38
+ GrantedAccess:
39
+ - '0x1010'
40
+ - '0x1038'
41
+ - '0x1410'
42
+ filter_system:
43
+ SourceImage|startswith:
44
+ - 'C:\Windows\System32\'
45
+ condition: selection and not filter_system
46
+ level: high
47
+ ---
48
+ # 可疑 PowerShell
49
+ title: Suspicious PowerShell Download
50
+ logsource:
51
+ category: process_creation
52
+ product: windows
53
+ detection:
54
+ selection:
55
+ CommandLine|contains:
56
+ - 'IEX'
57
+ - 'Invoke-Expression'
58
+ - 'DownloadString'
59
+ - 'Net.WebClient'
60
+ - '-enc'
61
+ - 'FromBase64String'
62
+ condition: selection
63
+ level: high
64
+ ---
65
+ # DCSync 检测
66
+ title: DCSync Attack
67
+ logsource:
68
+ product: windows
69
+ service: security
70
+ detection:
71
+ selection:
72
+ EventID: 4662
73
+ Properties|contains:
74
+ - '1131f6ad-9c07-11d1-f79f-00c04fc2dcd2'
75
+ - '1131f6aa-9c07-11d1-f79f-00c04fc2dcd2'
76
+ filter_dc:
77
+ SubjectUserName|endswith: '$'
78
+ condition: selection and not filter_dc
79
+ level: critical
80
+ ```
81
+
82
+ ### Sigma 转换
83
+ ```bash
84
+ # 安装
85
+ pip install sigma-cli
86
+
87
+ # 转换为各平台格式
88
+ sigma convert -t splunk -p sysmon rules/
89
+ sigma convert -t elasticsearch rules/
90
+ sigma convert -t azure-monitor rules/
91
+ ```
92
+
93
+ ### YARA 规则
94
+
95
+ ```yara
96
+ rule Mimikatz_Memory {
97
+ meta:
98
+ description = "Detects Mimikatz in memory"
99
+ severity = "critical"
100
+ strings:
101
+ $s1 = "mimikatz" ascii wide nocase
102
+ $s2 = "sekurlsa::logonpasswords" ascii wide
103
+ $s3 = "lsadump::dcsync" ascii wide
104
+ $func = "kuhl_m_" ascii
105
+ condition:
106
+ 2 of ($s*) or $func
107
+ }
108
+
109
+ rule Cobalt_Strike_Beacon {
110
+ meta:
111
+ description = "Detects Cobalt Strike Beacon"
112
+ strings:
113
+ $config = { 69 68 69 68 69 6B 69 68 }
114
+ $sleep = "sleeptime" ascii
115
+ $jitter = "jitter" ascii
116
+ condition:
117
+ $config or all of ($sleep, $jitter)
118
+ }
119
+
120
+ rule Webshell_Generic {
121
+ meta:
122
+ description = "Generic webshell detection"
123
+ strings:
124
+ $php = "<?php" nocase
125
+ $eval = /eval\s*\(\s*\$_(GET|POST|REQUEST)/ nocase
126
+ $system = /system\s*\(\s*\$_(GET|POST)/ nocase
127
+ condition:
128
+ $php and any of ($eval, $system)
129
+ }
130
+ ```
131
+
132
+ ## 关键日志源
133
+
134
+ ### Windows 安全日志
135
+ ```python
136
+ CRITICAL_EVENTS = {
137
+ # 登录事件
138
+ '4624': 'Successful Logon',
139
+ '4625': 'Failed Logon',
140
+ '4648': 'Explicit Credential Logon',
141
+
142
+ # 进程事件
143
+ '4688': 'Process Creation',
144
+ '4689': 'Process Termination',
145
+
146
+ # 账户事件
147
+ '4720': 'User Account Created',
148
+ '4728': 'Member Added to Security Group',
149
+ '4732': 'Member Added to Local Group',
150
+
151
+ # Kerberos
152
+ '4768': 'TGT Request',
153
+ '4769': 'Service Ticket Request',
154
+ '4771': 'Pre-Auth Failed',
155
+
156
+ # 目录服务
157
+ '4662': 'Directory Service Access',
158
+ }
159
+ ```
160
+
161
+ ### Sysmon 事件
162
+ ```python
163
+ SYSMON_EVENTS = {
164
+ '1': 'Process Create',
165
+ '3': 'Network Connection',
166
+ '7': 'Image Loaded',
167
+ '8': 'CreateRemoteThread',
168
+ '10': 'ProcessAccess',
169
+ '11': 'FileCreate',
170
+ '12': 'Registry Key Create/Delete',
171
+ '13': 'Registry Value Set',
172
+ '17': 'Pipe Created',
173
+ '22': 'DNS Query',
174
+ '23': 'FileDelete',
175
+ }
176
+ ```
177
+
178
+ ## SOC 运营
179
+
180
+ ### 告警分级
181
+ ```yaml
182
+ P1 - Critical (15分钟响应):
183
+ - 确认的入侵活动
184
+ - 勒索软件执行
185
+ - 数据外泄
186
+ - 特权账户被控
187
+
188
+ P2 - High (1小时响应):
189
+ - 可疑横向移动
190
+ - 凭证窃取尝试
191
+ - C2 通信检测
192
+ - 异常特权操作
193
+
194
+ P3 - Medium (4小时响应):
195
+ - 可疑进程执行
196
+ - 异常网络连接
197
+ - 策略违规
198
+
199
+ P4 - Low (24小时响应):
200
+ - 信息性告警
201
+ - 合规检查
202
+ ```
203
+
204
+ ### 告警质量指标
205
+ ```python
206
+ class AlertMetrics:
207
+ def calculate(self, alerts):
208
+ total = len(alerts)
209
+ tp = sum(1 for a in alerts if a['verified'] == 'true_positive')
210
+ fp = sum(1 for a in alerts if a['verified'] == 'false_positive')
211
+
212
+ return {
213
+ 'true_positive_rate': tp / total * 100,
214
+ 'false_positive_rate': fp / total * 100,
215
+ 'mean_time_to_detect': self._mttd(alerts),
216
+ 'mean_time_to_respond': self._mttr(alerts),
217
+ }
218
+ ```
219
+
220
+ ## 应急响应
221
+
222
+ ### IR 流程
223
+ ```
224
+ ┌─────────────────────────────────────────────────────────────┐
225
+ │ 应急响应流程 │
226
+ ├─────────────────────────────────────────────────────────────┤
227
+ │ 1. 准备 (Preparation) │
228
+ │ └─ 工具准备、流程文档、联系人清单 │
229
+ │ ↓ │
230
+ │ 2. 识别 (Identification) │
231
+ │ └─ 确认事件、评估范围、初步分类 │
232
+ │ ↓ │
233
+ │ 3. 遏制 (Containment) │
234
+ │ └─ 隔离系统、阻断通信、保护证据 │
235
+ │ ↓ │
236
+ │ 4. 根除 (Eradication) │
237
+ │ └─ 清除恶意软件、修复漏洞、重置凭证 │
238
+ │ ↓ │
239
+ │ 5. 恢复 (Recovery) │
240
+ │ └─ 系统恢复、监控加强、业务恢复 │
241
+ │ ↓ │
242
+ │ 6. 总结 (Lessons Learned) │
243
+ │ └─ 事件报告、改进措施、知识沉淀 │
244
+ └─────────────────────────────────────────────────────────────┘
245
+ ```
246
+
247
+ ### 快速遏制
248
+ ```bash
249
+ # Windows - 隔离主机
250
+ netsh advfirewall set allprofiles state on
251
+ netsh advfirewall firewall add rule name="Block All" dir=out action=block
252
+
253
+ # Linux - 隔离主机
254
+ iptables -P INPUT DROP
255
+ iptables -P OUTPUT DROP
256
+ iptables -A INPUT -s TRUSTED_IP -j ACCEPT
257
+
258
+ # 禁用账户
259
+ net user compromised_user /active:no
260
+ passwd -l compromised_user
261
+
262
+ # 终止恶意进程
263
+ taskkill /F /PID <pid>
264
+ kill -9 <pid>
265
+ ```
266
+
267
+ ### 证据收集
268
+ ```bash
269
+ # Windows
270
+ wmic process list full > processes.txt
271
+ netstat -ano > netstat.txt
272
+ reg export HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run run.reg
273
+ wevtutil epl Security security.evtx
274
+
275
+ # Linux
276
+ ps auxf > processes.txt
277
+ netstat -tulpn > netstat.txt
278
+ cat /etc/passwd > passwd.txt
279
+ last > logins.txt
280
+ cp /var/log/auth.log .
281
+ ```
282
+
283
+ ## 数字取证
284
+
285
+ ### 内存取证
286
+ ```bash
287
+ # 内存获取
288
+ # Windows - WinPMEM
289
+ winpmem_mini_x64.exe memory.raw
290
+
291
+ # Linux - LiME
292
+ insmod lime.ko "path=/tmp/memory.lime format=lime"
293
+
294
+ # 分析 - Volatility
295
+ vol.py -f memory.raw imageinfo
296
+ vol.py -f memory.raw --profile=Win10x64 pslist
297
+ vol.py -f memory.raw --profile=Win10x64 netscan
298
+ vol.py -f memory.raw --profile=Win10x64 malfind
299
+ vol.py -f memory.raw --profile=Win10x64 dlllist
300
+ ```
301
+
302
+ ### 磁盘取证
303
+ ```bash
304
+ # 镜像获取
305
+ dd if=/dev/sda of=disk.img bs=4M status=progress
306
+
307
+ # 挂载分析
308
+ mount -o ro,loop disk.img /mnt/evidence
309
+
310
+ # 时间线分析
311
+ log2timeline.py timeline.plaso disk.img
312
+ psort.py -o l2tcsv timeline.plaso -w timeline.csv
313
+
314
+ # 文件恢复
315
+ foremost -i disk.img -o recovered/
316
+ photorec disk.img
317
+ ```
318
+
319
+ ### 日志分析
320
+ ```bash
321
+ # Windows 事件日志
322
+ # 使用 EvtxECmd 解析
323
+ EvtxECmd.exe -f Security.evtx --csv output/
324
+
325
+ # Linux 日志
326
+ grep "Failed password" /var/log/auth.log
327
+ grep "Accepted" /var/log/auth.log | awk '{print $1,$2,$3,$9,$11}'
328
+ zcat /var/log/auth.log.*.gz | grep "sudo"
329
+ ```
330
+
331
+ ## 威胁狩猎
332
+
333
+ ### 狩猎假设
334
+ ```yaml
335
+ # 基于 ATT&CK 的狩猎假设
336
+ hypothesis: "攻击者可能使用 PowerShell 下载并执行恶意代码"
337
+ technique: T1059.001
338
+ data_sources:
339
+ - Windows PowerShell 日志
340
+ - Sysmon 进程创建
341
+ query: |
342
+ EventID=4104 AND ScriptBlockText CONTAINS ("IEX" OR "DownloadString")
343
+ ```
344
+
345
+ ### 狩猎查询示例
346
+ ```sql
347
+ -- 异常父子进程关系
348
+ SELECT parent_name, process_name, command_line
349
+ FROM processes
350
+ WHERE parent_name = 'winword.exe'
351
+ AND process_name IN ('cmd.exe', 'powershell.exe', 'wscript.exe')
352
+
353
+ -- 异常网络连接
354
+ SELECT process_name, remote_address, remote_port
355
+ FROM network_connections
356
+ WHERE remote_port NOT IN (80, 443, 53)
357
+ AND process_name NOT IN ('chrome.exe', 'firefox.exe')
358
+
359
+ -- 可疑计划任务
360
+ SELECT name, command, trigger
361
+ FROM scheduled_tasks
362
+ WHERE command LIKE '%powershell%' OR command LIKE '%cmd%'
363
+ ```
364
+
365
+ ## 工具清单
366
+
367
+ | 工具 | 用途 |
368
+ |------|------|
369
+ | Sigma | 通用检测规则 |
370
+ | YARA | 恶意软件检测 |
371
+ | Splunk/Elastic | SIEM 平台 |
372
+ | Volatility | 内存取证 |
373
+ | Autopsy | 磁盘取证 |
374
+ | Velociraptor | 端点响应 |
375
+ | TheHive | 事件管理 |
376
+ | MISP | 威胁情报 |
377
+
378
+ ## 密钥管理
379
+
380
+ ### 密钥生命周期
381
+ ```
382
+ 生成 → 存储 → 分发 → 使用 → 轮转 → 撤销 → 销毁
383
+ ```
384
+
385
+ ### 核心工具
386
+ | 工具 | 类型 | 特点 |
387
+ |------|------|------|
388
+ | HashiCorp Vault | 平台 | 动态密钥、AppRole、多后端 |
389
+ | AWS KMS | 云服务 | 托管密钥、信封加密、自动轮转 |
390
+ | AWS Secrets Manager | 云服务 | 自动轮转、Lambda集成 |
391
+ | Sealed Secrets | K8s | GitOps 友好、加密存储 |
392
+ | External Secrets | K8s | 多后端同步(Vault/AWS/GCP) |
393
+
394
+ ### 密钥管理检查清单
395
+ ```yaml
396
+ 生成与存储:
397
+ - [ ] 加密强随机数生成器
398
+ - [ ] 密钥长度符合标准(AES-256, RSA-2048+)
399
+ - [ ] 集中存储在密钥管理系统 + 静态加密 + 访问控制
400
+
401
+ 分发与使用:
402
+ - [ ] 最小权限 + 短期凭证优先(动态密钥)
403
+ - [ ] 禁止硬编码,使用环境变量或挂载卷
404
+ - [ ] 传输加密(TLS)
405
+
406
+ 轮转与撤销:
407
+ - [ ] 定期自动轮转(P0年度/P1季度/P2月度/P3小时)
408
+ - [ ] 支持紧急撤销 + 轮转后验证 + 审计日志
409
+
410
+ 监控:
411
+ - [ ] 记录所有密钥访问 + 异常检测告警 + 定期合规审计
412
+ ```
413
+
414
+ ### Vault 关键操作速查
415
+ ```bash
416
+ # KV 读写
417
+ vault kv put secret/myapp/config db_password="xxx" api_key="yyy"
418
+ vault kv get -field=db_password secret/myapp/config
419
+
420
+ # 动态数据库凭证
421
+ vault read database/creds/readonly
422
+
423
+ # AppRole 登录
424
+ vault write auth/approle/login role_id="<id>" secret_id="<id>"
425
+ ```
426
+
427
+ ### 密钥分类策略
428
+ | 级别 | 类型 | 轮转周期 | 存储 |
429
+ |------|------|----------|------|
430
+ | P0 | 根密钥、主密钥 | 年度 | HSM |
431
+ | P1 | 数据加密密钥 | 季度 | Vault |
432
+ | P2 | API 密钥 | 月度 | Secrets Manager |
433
+ | P3 | 会话令牌 | 小时 | Redis |
434
+
435
+ ---
436
+