@kenhkl/agent-moss 0.13.0 → 0.15.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/dist/cli.js +630 -150
- package/dist/cli.js.map +1 -1
- package/dist/engine/coordinator.d.ts +1 -1
- package/dist/engine/coordinator.js +554 -197
- package/dist/engine/coordinator.js.map +1 -1
- package/dist/rules/l1_rules.json +28 -6
- package/dist/rules/l2_rules.json +242 -214
- package/dist/rules/mc_rules.json +258 -26
- package/dist/server.js +716 -246
- package/dist/server.js.map +1 -1
- package/dist/static/index.html +22 -8
- package/package.json +1 -1
package/dist/rules/mc_rules.json
CHANGED
|
@@ -2,53 +2,107 @@
|
|
|
2
2
|
"_comment": "L2.2 模型检测规则单一事实源(Python + TS 共用)。原子命题正则 + LTL 公式(前缀 AST)。公式在事件迹位置 0 处评估:LTL 公式满足 = 攻击存在。对应站点 detection-l2-2.html 的 10 条 LTL + 5 条 CTL 规则(CTL 活性降级为 G(!φ) 安全不变量,见 docs/DETECTION_METHODS.md 5.4)。",
|
|
3
3
|
"ap_patterns": {
|
|
4
4
|
"reads_credential": [
|
|
5
|
-
"
|
|
5
|
+
"(?:cat|head|tail|less|more|sed|awk|strings|base64|dd)\\s+[^;&|\\n]*[~]?/\\.ssh(?:/[\\w.-]+)?\\b",
|
|
6
|
+
"(?:cat|head|tail|less|more|sed|awk|strings|base64|dd)\\s+[^;&|\\n]*(?:id_rsa|id_dsa|id_ecdsa|\\.aws/credentials|credentials\\.json|\\.netrc)",
|
|
7
|
+
"(?:cat|head|tail|less|more|sed|awk|strings|base64)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd)",
|
|
8
|
+
"(?:cat|head|tail|less|more|grep)\\s+[^;&|\\n]*known_hosts",
|
|
9
|
+
"(?:grep|find)\\s+[^;&|\\n]*\\b(?:password|secret|passwd|credential|api[_-]?key)\\b[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|~?/\\.aws/credentials)",
|
|
10
|
+
"\\bcurl\\b[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)",
|
|
11
|
+
"\\bpython3?\\s+-c\\s+['\\\"][\\s\\S]{0,200}?(?:base64\\.b64encode|open\\s*\\(|Path\\(|io\\.open\\s*\\(|read_text\\s*\\(|read\\s*\\()[\\s\\S]{0,200}?(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)"
|
|
6
12
|
],
|
|
7
13
|
"network_egress": [
|
|
8
|
-
"
|
|
14
|
+
"\\bcurl\\b[^;&|\\n]*(?:-X\\s+POST\\s+|-d\\s+|-F\\s+|--data|--upload-file|--data-binary|-T\\s+)[^;&|\\n]*https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)",
|
|
15
|
+
"\\b(?:curl|wget|ftp)\\b[^;&|\\n]*\\s(?:-T|--upload-file|--post-file|--post-data|put)\\b[^;&|\\n]*https?://(?!localhost|127\\.0\\.0\\.1)",
|
|
16
|
+
"[^;&|\\n]*\\|\\s*(?:nc|netcat)\\s+\\S+\\s+\\d{1,5}\\b",
|
|
17
|
+
"(?:requests|urllib(?:\\.request)?|aiohttp|httpx)\\.(?:post|put|request|send)\\s*\\(",
|
|
18
|
+
"\\b(?:scp|sftp|rsync)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|id_dsa|credentials|\\S*secret\\S*|\\.ssh/)[^;&|\\n]*\\S+@\\S+:",
|
|
19
|
+
"\\b(?:smtplib|ftplib|paramiko)\\s*\\."
|
|
9
20
|
],
|
|
10
21
|
"execute_file": [
|
|
11
|
-
"
|
|
22
|
+
"\\bpython3?\\s+-c\\s+['\\\"](?![^'\\\"]*\\b(?:print|pprint|echo)\\s*\\()",
|
|
23
|
+
"\\b(?:bash|sh)\\s+-[ce]\\b",
|
|
24
|
+
"\\bos\\.system\\s*\\(",
|
|
25
|
+
"\\bsubprocess\\.(?:run|call|Popen|check_output|check_call)\\s*\\(",
|
|
26
|
+
"\\bshell\\s*=\\s*True\\b",
|
|
27
|
+
"\\beval\\s*[\\(\\s]|\\bexec\\s*\\(|\\bexecve\\b",
|
|
28
|
+
"\\bperl\\s+-e\\b|\\bnode\\s+-e\\b|\\bphp\\s+-r\\b",
|
|
29
|
+
"\\./[\\w.-]+\\.(?:sh|py|pl)\\b"
|
|
12
30
|
],
|
|
13
31
|
"write_file": [
|
|
14
|
-
"
|
|
32
|
+
"(?:>|>>|tee\\s+)\\s*(?:/etc/passwd|/etc/shadow|/etc/crontab|/var/spool/cron/|~?/\\.ssh/(?:authorized_keys|config))",
|
|
33
|
+
"(?:cp|mv)\\s+[^;&|\\n]*\\s(?:/etc/passwd|/etc/shadow|/etc/crontab)"
|
|
15
34
|
],
|
|
16
35
|
"delete_file": [
|
|
17
|
-
"\\brm\\s
|
|
36
|
+
"\\brm\\s+-[rf]+\\s+/|\\brm\\s+-[rf]+\\s+[^;&|\\n]*(?:/etc|/var|/opt|/home)",
|
|
37
|
+
"\\bshred\\b|\\bwipe\\b"
|
|
18
38
|
],
|
|
19
39
|
"disable_security": [
|
|
20
|
-
"iptables\\s+-F|setenforce\\s+0|systemctl\\s+stop\\s+(
|
|
40
|
+
"iptables\\s+-F|setenforce\\s+0|systemctl\\s+stop\\s+(?:firewalld|apparmor|fail2ban)|ufw\\s+disable",
|
|
41
|
+
"\\b(?:killing|disable)\\s+(?:selinux|firewall|av)"
|
|
21
42
|
],
|
|
22
43
|
"install_persistence": [
|
|
23
|
-
"
|
|
44
|
+
"(?:echo|printf|cat)\\b[^;&|\\n]*\\|\\s*(?:crontab|at\\b)\\s*-",
|
|
45
|
+
"\\bsystemctl\\s+enable\\s+",
|
|
46
|
+
"(?:echo|printf)\\b[^;&|\\n]*[^;&|\\n]*(?:/dev/tcp/|nc\\s+-l|ncat|reverse|backdoor|bash\\s+-i)[^;&|\\n]*(?:>>|>)\\s*(?:~?/\\.bashrc|~?/\\.profile)",
|
|
47
|
+
"\\bat\\s+now\\b|\\bchkconfig\\s+\\S+\\s+on\\b",
|
|
48
|
+
"\\bcrontab\\s+-e\\b"
|
|
24
49
|
],
|
|
25
50
|
"privilege_escalation": [
|
|
26
|
-
"\\bsudo\\
|
|
51
|
+
"\\bsudo\\s+-u\\s+root\\b",
|
|
52
|
+
"\\bsudo\\b[^;&|\\n]*(?:/bin/sh|/bin/bash|\\bchmod\\b|\\bsetcap\\b|\\bvisudo\\b|\\bpasswd\\s+root|\\buseradd\\b)",
|
|
53
|
+
"\\bchmod\\s+u\\+s\\b|setcap\\b|pkexec\\b|doas\\b|setuid\\b",
|
|
54
|
+
"\\bsu\\s+-\\s*$|\\bsu\\s+root\\b|\\bsu\\s+-l\\s+root\\b"
|
|
27
55
|
],
|
|
28
56
|
"download_file": [
|
|
29
|
-
"curl\\
|
|
57
|
+
"\\b(?:curl|wget)\\b[^;&|\\n]*(?:-o|--output|--location|-O)\\s+(?:(?:/tmp|/var/tmp|/dev/shm|~/)[\\w./-]*\\.(?:sh|py|pl|elf|bin|out)\\b|\\S+\\.(?:sh|py|pl|elf)\\b)",
|
|
58
|
+
"\\b(?:git\\s+clone|svn\\s+checkout)\\s+\\S+"
|
|
30
59
|
],
|
|
31
60
|
"archive_data": [
|
|
32
|
-
"\\
|
|
61
|
+
"\\b(?:tar|zip|7za?|rar)\\s+[^;&|\\n]*(?:-c|-a)\\s+[^;&|\\n]*(?:(?:/etc|/var|/home|/root)|shadow|passwd|\\.ssh|secret)",
|
|
62
|
+
"\\bbase64\\b[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|secret)"
|
|
33
63
|
],
|
|
34
64
|
"prompt_injection": [
|
|
35
|
-
"ignore
|
|
65
|
+
"ignore\\s+(?:previous|prior|all)\\s+(?:instructions?|commands?)",
|
|
66
|
+
"<INFORMATION>|TODO:\\s*(?:send|email|transfer|delete|forward|reserve)"
|
|
36
67
|
],
|
|
37
68
|
"sensitive_data": [
|
|
38
|
-
"api[_-]?token|access[_-]?token|bearer\\s+[a-z0-9._-]+|sk-[a-z0-9_-]
|
|
69
|
+
"(?:api[_-]?token|access[_-]?token|bearer\\s+[a-z0-9._-]+|sk-[a-z0-9_-]{10,})",
|
|
70
|
+
"-----BEGIN [A-Z ]*PRIVATE KEY-----",
|
|
71
|
+
"(?:^|[\\s\\W]|/)(?:\\.env|\\.env\\.local)\\b"
|
|
39
72
|
],
|
|
40
73
|
"lateral_movement": [
|
|
41
|
-
"\\bssh\\s
|
|
74
|
+
"\\bssh\\s+[^;&|\\n]*\\S+@\\S+[\\s;&|]+(?:exec|cat|curl|wget|nc|scp|ssh|sudo|chmod|base64)",
|
|
75
|
+
"\\bssh\\s+-i\\s+\\S+\\s+\\S+@",
|
|
76
|
+
"(?:psexec|wmiexec|smbexec|sshpass)"
|
|
42
77
|
],
|
|
43
78
|
"clear_logs": [
|
|
44
|
-
"history\\s+-c
|
|
79
|
+
"history\\s+-c\\b",
|
|
80
|
+
"(?:>|>>)\\s*/var/log/|journalctl\\s+.*--vacuum",
|
|
81
|
+
"\\b(?:truncate|shred)\\s+[\\w/]*(?:log|journal)",
|
|
82
|
+
"\\brm\\s+-[rf]+\\s+/var/log/"
|
|
45
83
|
]
|
|
46
84
|
},
|
|
47
85
|
"rules": [
|
|
48
86
|
{
|
|
49
87
|
"id": "mc-ltl-001",
|
|
50
88
|
"type": "ltl",
|
|
51
|
-
"formula": [
|
|
89
|
+
"formula": [
|
|
90
|
+
"F",
|
|
91
|
+
[
|
|
92
|
+
"&",
|
|
93
|
+
[
|
|
94
|
+
"ap",
|
|
95
|
+
"reads_credential"
|
|
96
|
+
],
|
|
97
|
+
[
|
|
98
|
+
"F",
|
|
99
|
+
[
|
|
100
|
+
"ap",
|
|
101
|
+
"network_egress"
|
|
102
|
+
]
|
|
103
|
+
]
|
|
104
|
+
]
|
|
105
|
+
],
|
|
52
106
|
"risk_level": "critical",
|
|
53
107
|
"action": "block",
|
|
54
108
|
"reason": "凭证读取后网络外传(mc-ltl-001)"
|
|
@@ -56,7 +110,23 @@
|
|
|
56
110
|
{
|
|
57
111
|
"id": "mc-ltl-002",
|
|
58
112
|
"type": "ltl",
|
|
59
|
-
"formula": [
|
|
113
|
+
"formula": [
|
|
114
|
+
"F",
|
|
115
|
+
[
|
|
116
|
+
"&",
|
|
117
|
+
[
|
|
118
|
+
"ap",
|
|
119
|
+
"download_file"
|
|
120
|
+
],
|
|
121
|
+
[
|
|
122
|
+
"F",
|
|
123
|
+
[
|
|
124
|
+
"ap",
|
|
125
|
+
"execute_file"
|
|
126
|
+
]
|
|
127
|
+
]
|
|
128
|
+
]
|
|
129
|
+
],
|
|
60
130
|
"risk_level": "critical",
|
|
61
131
|
"action": "block",
|
|
62
132
|
"reason": "下载后执行(mc-ltl-002)"
|
|
@@ -64,7 +134,37 @@
|
|
|
64
134
|
{
|
|
65
135
|
"id": "mc-ltl-003",
|
|
66
136
|
"type": "ltl",
|
|
67
|
-
"formula": [
|
|
137
|
+
"formula": [
|
|
138
|
+
"F",
|
|
139
|
+
[
|
|
140
|
+
"&",
|
|
141
|
+
[
|
|
142
|
+
"ap",
|
|
143
|
+
"disable_security"
|
|
144
|
+
],
|
|
145
|
+
[
|
|
146
|
+
"F",
|
|
147
|
+
[
|
|
148
|
+
"|",
|
|
149
|
+
[
|
|
150
|
+
"ap",
|
|
151
|
+
"execute_file"
|
|
152
|
+
],
|
|
153
|
+
[
|
|
154
|
+
"|",
|
|
155
|
+
[
|
|
156
|
+
"ap",
|
|
157
|
+
"delete_file"
|
|
158
|
+
],
|
|
159
|
+
[
|
|
160
|
+
"ap",
|
|
161
|
+
"privilege_escalation"
|
|
162
|
+
]
|
|
163
|
+
]
|
|
164
|
+
]
|
|
165
|
+
]
|
|
166
|
+
]
|
|
167
|
+
],
|
|
68
168
|
"risk_level": "critical",
|
|
69
169
|
"action": "block",
|
|
70
170
|
"reason": "禁用安全后破坏性操作(mc-ltl-003)"
|
|
@@ -72,7 +172,37 @@
|
|
|
72
172
|
{
|
|
73
173
|
"id": "mc-ltl-004",
|
|
74
174
|
"type": "ltl",
|
|
75
|
-
"formula": [
|
|
175
|
+
"formula": [
|
|
176
|
+
"F",
|
|
177
|
+
[
|
|
178
|
+
"&",
|
|
179
|
+
[
|
|
180
|
+
"ap",
|
|
181
|
+
"prompt_injection"
|
|
182
|
+
],
|
|
183
|
+
[
|
|
184
|
+
"F",
|
|
185
|
+
[
|
|
186
|
+
"|",
|
|
187
|
+
[
|
|
188
|
+
"ap",
|
|
189
|
+
"network_egress"
|
|
190
|
+
],
|
|
191
|
+
[
|
|
192
|
+
"|",
|
|
193
|
+
[
|
|
194
|
+
"ap",
|
|
195
|
+
"write_file"
|
|
196
|
+
],
|
|
197
|
+
[
|
|
198
|
+
"ap",
|
|
199
|
+
"execute_file"
|
|
200
|
+
]
|
|
201
|
+
]
|
|
202
|
+
]
|
|
203
|
+
]
|
|
204
|
+
]
|
|
205
|
+
],
|
|
76
206
|
"risk_level": "critical",
|
|
77
207
|
"action": "block",
|
|
78
208
|
"reason": "注入后敏感操作(mc-ltl-004)"
|
|
@@ -80,7 +210,23 @@
|
|
|
80
210
|
{
|
|
81
211
|
"id": "mc-ltl-005",
|
|
82
212
|
"type": "ltl",
|
|
83
|
-
"formula": [
|
|
213
|
+
"formula": [
|
|
214
|
+
"F",
|
|
215
|
+
[
|
|
216
|
+
"&",
|
|
217
|
+
[
|
|
218
|
+
"ap",
|
|
219
|
+
"reads_credential"
|
|
220
|
+
],
|
|
221
|
+
[
|
|
222
|
+
"F",
|
|
223
|
+
[
|
|
224
|
+
"ap",
|
|
225
|
+
"lateral_movement"
|
|
226
|
+
]
|
|
227
|
+
]
|
|
228
|
+
]
|
|
229
|
+
],
|
|
84
230
|
"risk_level": "critical",
|
|
85
231
|
"action": "block",
|
|
86
232
|
"reason": "凭证读取后横向移动(mc-ltl-005)"
|
|
@@ -88,7 +234,23 @@
|
|
|
88
234
|
{
|
|
89
235
|
"id": "mc-ltl-006",
|
|
90
236
|
"type": "ltl",
|
|
91
|
-
"formula": [
|
|
237
|
+
"formula": [
|
|
238
|
+
"F",
|
|
239
|
+
[
|
|
240
|
+
"&",
|
|
241
|
+
[
|
|
242
|
+
"ap",
|
|
243
|
+
"sensitive_data"
|
|
244
|
+
],
|
|
245
|
+
[
|
|
246
|
+
"F",
|
|
247
|
+
[
|
|
248
|
+
"ap",
|
|
249
|
+
"clear_logs"
|
|
250
|
+
]
|
|
251
|
+
]
|
|
252
|
+
]
|
|
253
|
+
],
|
|
92
254
|
"risk_level": "critical",
|
|
93
255
|
"action": "block",
|
|
94
256
|
"reason": "敏感数据访问后清除日志(mc-ltl-006)"
|
|
@@ -96,7 +258,23 @@
|
|
|
96
258
|
{
|
|
97
259
|
"id": "mc-ltl-007",
|
|
98
260
|
"type": "ltl",
|
|
99
|
-
"formula": [
|
|
261
|
+
"formula": [
|
|
262
|
+
"F",
|
|
263
|
+
[
|
|
264
|
+
"&",
|
|
265
|
+
[
|
|
266
|
+
"ap",
|
|
267
|
+
"privilege_escalation"
|
|
268
|
+
],
|
|
269
|
+
[
|
|
270
|
+
"F",
|
|
271
|
+
[
|
|
272
|
+
"ap",
|
|
273
|
+
"install_persistence"
|
|
274
|
+
]
|
|
275
|
+
]
|
|
276
|
+
]
|
|
277
|
+
],
|
|
100
278
|
"risk_level": "critical",
|
|
101
279
|
"action": "block",
|
|
102
280
|
"reason": "提权后安装持久化(mc-ltl-007)"
|
|
@@ -104,7 +282,23 @@
|
|
|
104
282
|
{
|
|
105
283
|
"id": "mc-ltl-008",
|
|
106
284
|
"type": "ltl",
|
|
107
|
-
"formula": [
|
|
285
|
+
"formula": [
|
|
286
|
+
"F",
|
|
287
|
+
[
|
|
288
|
+
"&",
|
|
289
|
+
[
|
|
290
|
+
"ap",
|
|
291
|
+
"download_file"
|
|
292
|
+
],
|
|
293
|
+
[
|
|
294
|
+
"F",
|
|
295
|
+
[
|
|
296
|
+
"ap",
|
|
297
|
+
"install_persistence"
|
|
298
|
+
]
|
|
299
|
+
]
|
|
300
|
+
]
|
|
301
|
+
],
|
|
108
302
|
"risk_level": "critical",
|
|
109
303
|
"action": "block",
|
|
110
304
|
"reason": "下载后安装持久化(mc-ltl-008)"
|
|
@@ -112,7 +306,33 @@
|
|
|
112
306
|
{
|
|
113
307
|
"id": "mc-ltl-009",
|
|
114
308
|
"type": "ltl",
|
|
115
|
-
"formula": [
|
|
309
|
+
"formula": [
|
|
310
|
+
"F",
|
|
311
|
+
[
|
|
312
|
+
"&",
|
|
313
|
+
[
|
|
314
|
+
"ap",
|
|
315
|
+
"sensitive_data"
|
|
316
|
+
],
|
|
317
|
+
[
|
|
318
|
+
"F",
|
|
319
|
+
[
|
|
320
|
+
"&",
|
|
321
|
+
[
|
|
322
|
+
"ap",
|
|
323
|
+
"archive_data"
|
|
324
|
+
],
|
|
325
|
+
[
|
|
326
|
+
"F",
|
|
327
|
+
[
|
|
328
|
+
"ap",
|
|
329
|
+
"network_egress"
|
|
330
|
+
]
|
|
331
|
+
]
|
|
332
|
+
]
|
|
333
|
+
]
|
|
334
|
+
]
|
|
335
|
+
],
|
|
116
336
|
"risk_level": "critical",
|
|
117
337
|
"action": "block",
|
|
118
338
|
"reason": "敏感数据→归档→外传(mc-ltl-009)"
|
|
@@ -120,7 +340,13 @@
|
|
|
120
340
|
{
|
|
121
341
|
"id": "mc-ltl-010",
|
|
122
342
|
"type": "ltl",
|
|
123
|
-
"formula": [
|
|
343
|
+
"formula": [
|
|
344
|
+
"F",
|
|
345
|
+
[
|
|
346
|
+
"ap",
|
|
347
|
+
"install_persistence"
|
|
348
|
+
]
|
|
349
|
+
],
|
|
124
350
|
"risk_level": "medium",
|
|
125
351
|
"action": "approval",
|
|
126
352
|
"reason": "持久化机制安装,需审批(mc-ltl-010)"
|
|
@@ -128,10 +354,16 @@
|
|
|
128
354
|
{
|
|
129
355
|
"id": "mc-ctl-001",
|
|
130
356
|
"type": "ltl",
|
|
131
|
-
"formula": [
|
|
357
|
+
"formula": [
|
|
358
|
+
"F",
|
|
359
|
+
[
|
|
360
|
+
"ap",
|
|
361
|
+
"clear_logs"
|
|
362
|
+
]
|
|
363
|
+
],
|
|
132
364
|
"risk_level": "critical",
|
|
133
365
|
"action": "block",
|
|
134
366
|
"reason": "安全不变量:任何情况不得清除日志(mc-ctl-001,AG(!clear_logs) 线性迹降级:违反 ⟺ 出现 clear_logs ⟺ F(clear_logs) 成立)"
|
|
135
367
|
}
|
|
136
368
|
]
|
|
137
|
-
}
|
|
369
|
+
}
|