@kenhkl/agent-moss 0.12.9 → 0.14.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.
@@ -13,8 +13,8 @@
13
13
  "reason": "检测到删除关键系统目录"
14
14
  },
15
15
  {
16
- "pattern": "\\brm\\s+-[a-zA-Z]*r[a-zA-Z]*\\s+/(?!tmp/|var/tmp/|run/|dev/shm/)",
17
- "risk_level": "high",
16
+ "pattern": "\\brm\\s+-[a-zA-Z]*r[a-zA-Z]*\\s+/(?!tmp|var/tmp|run|dev/shm|mnt|media)(?:/|\\b)",
17
+ "risk_level": "medium",
18
18
  "risk_type": "script_execution",
19
19
  "reason": "检测到递归删除操作 (rm -r /...)"
20
20
  },
@@ -25,16 +25,16 @@
25
25
  "reason": "检测到强制删除文件 (rm -f /...)"
26
26
  },
27
27
  {
28
- "pattern": "chmod\\s+[0-7]{0,3}7\\b",
28
+ "pattern": "chmod\\s+(?:(?:-[a-zA-Z]*|--)\\s+)*[0-7]{0,3}7\\b",
29
29
  "risk_level": "critical",
30
30
  "risk_type": "privilege_escalation",
31
- "reason": "检测到危险权限设置 (chmod ...7, other 位含写+执行敞口)"
31
+ "reason": "检测到危险权限设置 (chmod ...7, other 位含写+执行敞口; 含 -R 递归与 -- 分隔符形态)"
32
32
  },
33
33
  {
34
- "pattern": "chmod\\s+[24][0-7]{3}\\b",
34
+ "pattern": "chmod\\s+(?:(?:-[a-zA-Z]*|--)\\s+)*[2-7][0-7]{3}\\b",
35
35
  "risk_level": "critical",
36
36
  "risk_type": "privilege_escalation",
37
- "reason": "检测到 setuid/setgid 位设置 (chmod 4xxx/2xxx, 提权)"
37
+ "reason": "检测到 setuid/setgid 位设置 (chmod 4xxx/2xxx/6xxx 及 3/5/7xxx 组合位, 提权; 含 -R 递归与 -- 分隔符形态)"
38
38
  },
39
39
  {
40
40
  "pattern": "chmod\\s+[ugoa]\\+s\\b",
@@ -114,6 +114,12 @@
114
114
  "risk_type": "data_exfiltration",
115
115
  "reason": "检测到通过 curl POST 外传可能包含敏感信息的请求"
116
116
  },
117
+ {
118
+ "pattern": "\\b(?:curl|wget)\\b[^;&|\\n]*(?:-T|--upload-file)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|/etc/master\\.passwd|id_rsa|id_dsa|id_ecdsa|id_ed25519|\\.aws/credentials|credentials|known_hosts|[^\\s/]*\\.db|secret[^\\s]*|\\.ssh)[^;&|\\n]*https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)",
119
+ "risk_level": "critical",
120
+ "risk_type": "data_exfiltration",
121
+ "reason": "检测到通过 curl/wget -T/--upload-file 上传敏感文件到外部服务器(数据外传)"
122
+ },
117
123
  {
118
124
  "pattern": "\\bnmap\\s+",
119
125
  "risk_level": "high",
@@ -592,6 +598,22 @@
592
598
  "deny_mode": "deny_both",
593
599
  "scope": "root"
594
600
  },
601
+ {
602
+ "path": ".ssh",
603
+ "risk_level": "high",
604
+ "desc": "SSH 配置目录(私钥/授权密钥所在)——整目录删除拦截,目录内文件按具体路径规则(读 known_hosts/config、写 authorized_keys/id_rsa 各自拦截),目录创建/权限设置放行",
605
+ "deny_mode": "deny_write",
606
+ "dir_del_only": true,
607
+ "scope": "home"
608
+ },
609
+ {
610
+ "path": ".aws",
611
+ "risk_level": "critical",
612
+ "desc": "AWS 配置目录(凭据所在)——整目录删除拦截,目录内文件按具体路径规则(读 .aws/config 非凭据配置放行、写 credentials 拦截),目录创建/权限设置放行",
613
+ "deny_mode": "deny_write",
614
+ "dir_del_only": true,
615
+ "scope": "home"
616
+ },
595
617
  {
596
618
  "path": ".ssh/id_rsa",
597
619
  "risk_level": "critical",
@@ -82,11 +82,25 @@
82
82
  "combo_chains": {
83
83
  "_comment": "L2 组合攻击链检测:单步操作可能无害,但按 kill chain 顺序组合即为后渗透攻击(参考 ChainWatch 六阶段 kill chain / 玄武实验室 Hermes 案例)。阶段 pattern 匹配 action_detail(含 tool call 参数),链定义要求至少 min_stages 个阶段按顺序出现才命中,防单步误报。A 会话内杀伤链 / D 提权-利用组合 / E 持久化-外联组合在 L2 实现(基于 action_history 子序列匹配);B 跨会话组合链 / C 敏感数据传播链 / F 跨设备组合依赖行为图与数据流,由 formal_engine 实现。",
84
84
  "stages": {
85
+ "PRIVESC": [
86
+ "\\b(?:pkexec|doas)\\b",
87
+ "\\bsudo\\s+-u\\s+root\\b",
88
+ "\\bsudo\\b[^;&|\\n]*(?:/bin/sh|/bin/bash|\\bchmod\\b|\\bsetcap\\b|\\bvisudo\\b|\\bpasswd\\s+root|\\buseradd\\b)",
89
+ "\\bchmod\\s+u\\+s\\b|\\bsetcap\\b|\\bsetuid\\b",
90
+ "\\bsu\\s+-?l?\\s+root\\b"
91
+ ],
92
+ "SCAN": [
93
+ "\\bnc\\s+-z\\b",
94
+ "\\bnmap\\b(?!\\s+--help\\b)",
95
+ "\\bmasscan\\b",
96
+ "\\bhping3\\b",
97
+ "\\bzenmap\\b",
98
+ "\\bseq\\b.*\\bnc\\b"
99
+ ],
85
100
  "LISTEN": [
86
- "\\bflask\\b",
87
- "\\bfastapi\\b",
88
- "httpserver",
89
- "http\\.server",
101
+ "\\bsocket\\s*\\([^)]*\\)\\s*[^;&|\\n]*(?:bind\\s*\\([^)]*\\)\\s*[^;&|\\n]*listen\\s*\\(|listen\\s*\\([^)]*\\)\\s*[^;&|\\n]*bind\\s*\\()",
102
+ "\\bflask\\b|\\bfastapi\\b",
103
+ "httpserver|http\\.server",
90
104
  "\\bnc\\s+-l",
91
105
  "\\bsocat\\b",
92
106
  "nohup\\s+.*\\bpython",
@@ -94,120 +108,134 @@
94
108
  "listen\\("
95
109
  ],
96
110
  "EXEC": [
97
- "subprocess",
98
- "os\\.system",
99
- "shell\\s*=\\s*True",
100
- "\\beval\\(",
101
- "\\bexec\\(",
102
- "/exec",
103
- "\\bbash\\s+-c",
104
- "run.*command"
111
+ "\\bpython3?\\s+-c\\s+['\\\"](?!.*(?:requests|urllib(?:\\.request)?|aiohttp|httpx)\\.(?:post|put|request|send)\\s*\\()(?![^'\\\"]*\\b(?:print|pprint|echo)\\s*\\()",
112
+ "\\b(?:bash|sh)\\s+-[ce]\\b",
113
+ "(?:^|[;&|\\s])(?!grep\\b|cat\\b|sed\\b|awk\\b|find\\b|less\\b|more\\b|head\\b|tail\\b)\\b(?:os\\.system\\b|subprocess\\b|shell\\s*=\\s*True\\b)",
114
+ "\\b(?:bash|sh)\\s+-[ce]\\b",
115
+ "\\beval\\s*[\\(\\s]|\\bexec\\s*\\(|/exec\\b",
116
+ "\\bperl\\s+-e\\b|\\bnode\\s+-e\\b|\\bphp\\s+-r\\b",
117
+ "\\./[\\w.-]+\\.(?:sh|py|pl)\\b"
105
118
  ],
106
- "SCAN": [
107
- "\\bnc\\s+-z",
108
- "\\bnmap\\b",
109
- "port\\s*scan",
110
- "\\bseq\\b.*\\bnc\\b",
111
- "192\\.168\\..*nc",
112
- "scan.*\\bport"
119
+ "EXFIL": [
120
+ "\\bcurl\\b[^;&|\\n]*(?:-X\\s+POST\\s+|-d\\s+|-F\\s+|--data|--upload-file|--data-binary)[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|[^\\s]*\\.db|secret[^\\s]*)[^;&|\\n]*https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)",
121
+ "\\bcurl\\b[^;&|\\n]*(?:-X\\s+POST\\s+|-d\\s+|-F\\s+|--data|--upload-file|--data-binary)[^;&|\\n]*https?://(?!127\\.\\d+\\.\\d+\\.\\d+|0\\.0\\.0\\.0|localhost|\\[?::1\\]?)",
122
+ "\\b(?:curl|wget)\\b[^;&|\\n]*\\s(?:-T|--upload-file)\\s+[^;&|\\n]*https?://(?!localhost|127\\.0\\.0\\.1)",
123
+ "[^;&|\\n]*\\|\\s*nc\\s+[^;&|\\n]*\\d{1,5}\\b",
124
+ "\\b(?:scp|sftp|rsync)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|id_dsa|credentials|\\S*secret\\S*|\\.ssh/)[^;&|\\n]*\\S+@\\S+:",
125
+ "\\bpython3?\\s+-c\\s+['\\\"][^'\\\"]*(?:requests|urllib(?:\\.request)?|aiohttp)\\.(?:post|put|request|send)\\s*\\([^'\\\"]*['\\\"]"
113
126
  ],
114
127
  "CRED": [
115
- "known_hosts",
116
- "\\.ssh",
117
- "id_rsa",
118
- "/etc/shadow",
119
- "/etc/passwd",
120
- "credential",
121
- "aws.*credentials"
122
- ],
123
- "EXFIL": [
124
- "\\bcurl\\s+.*https?://",
125
- "\\bwget\\s+.*https?://",
126
- "\\bscp\\s+.*@",
127
- "\\brsync\\s+.*@",
128
- "POST.*https?://"
128
+ "(?:cat|head|tail|less|more|sed|awk|strings|base64|dd)\\s+[^;&|\\n]*[~]?/\\.ssh(?:/[\\w.-]+)?\\b",
129
+ "(?:cat|head|tail|less|more|sed|awk|strings|base64|dd)\\s+[^;&|\\n]*(?:id_rsa|id_dsa|id_ecdsa|\\.aws/credentials|credentials\\.json|\\.netrc)",
130
+ "(?:cat|head|tail|less|more|sed|awk|strings|base64)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|/etc/master\\.passwd)",
131
+ "(?:cat|head|tail|less|more|grep)\\s+[^;&|\\n]*known_hosts",
132
+ "\\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)",
133
+ "(?:grep|find|cat)\\s+[^;&|\\n]*\\b(?:password|secret|passwd|shadow|credential|api[_-]?key)\\b[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)",
134
+ "(?:cp|mv|dd|curl)\\s+[^;&|\\n]*(?:/etc/shadow|/etc/passwd|id_rsa|credentials|\\.ssh)"
129
135
  ],
130
136
  "PERSIST": [
131
- "\\bcrontab\\b",
132
- "\\bsystemd\\b",
133
- "systemctl\\s+enable",
134
- "\\.bashrc",
135
- "\\.profile",
136
- "/etc/rc\\.local",
137
- "\\bnohup\\b",
138
- "\\bdaemon\\b",
139
- "startup\\s+item",
140
- "\\bat\\s+reboot"
141
- ],
142
- "PRIVESC": [
143
- "\\bsudo\\b",
144
- "\\bsu\\b",
145
- "chmod\\s+u\\s*\\+\\s*s",
146
- "\\bsetuid\\b",
147
- "\\bpkexec\\b",
148
- "\\bdoas\\b"
137
+ "(?:echo|printf|cat)\\b[^;\\n]*\\|[^;\\n]*(?:crontab|at\\b)\\s*-",
138
+ "\\bsystemctl\\s+enable\\s+",
139
+ "(?:echo|printf)\\b[^;\\n]*(?:/dev/tcp/|nc\\s+-l|ncat|reverse|backdoor|bash\\s+-i)[^;\\n]*(?:>>|>)\\s*(?:~?/\\.bashrc|~?/\\.profile|/etc/rc\\.local|/etc/crontab)",
140
+ "\\bat\\s+now\\b|\\bchkconfig\\s+\\S+\\s+on\\b",
141
+ "\\bcrontab\\s+-e\\b"
149
142
  ]
150
143
  },
151
144
  "chains": [
152
145
  {
153
146
  "id": "listener-exec-scan",
154
- "stages": ["LISTEN", "EXEC", "SCAN"],
147
+ "stages": [
148
+ "LISTEN",
149
+ "EXEC",
150
+ "SCAN"
151
+ ],
155
152
  "min_stages": 3,
156
153
  "risk_level": "high",
157
154
  "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 网络侦察"
158
155
  },
159
156
  {
160
157
  "id": "listener-exec-cred",
161
- "stages": ["LISTEN", "EXEC", "CRED"],
158
+ "stages": [
159
+ "LISTEN",
160
+ "EXEC",
161
+ "CRED"
162
+ ],
162
163
  "min_stages": 3,
163
164
  "risk_level": "critical",
164
165
  "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 访问凭据文件"
165
166
  },
166
167
  {
167
168
  "id": "listener-exec-exfil",
168
- "stages": ["LISTEN", "EXEC", "EXFIL"],
169
+ "stages": [
170
+ "LISTEN",
171
+ "EXEC",
172
+ "EXFIL"
173
+ ],
169
174
  "min_stages": 3,
170
175
  "risk_level": "critical",
171
176
  "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 数据外传"
172
177
  },
173
178
  {
174
179
  "id": "listener-exec-persist",
175
- "stages": ["LISTEN", "EXEC", "PERSIST"],
180
+ "stages": [
181
+ "LISTEN",
182
+ "EXEC",
183
+ "PERSIST"
184
+ ],
176
185
  "min_stages": 3,
177
186
  "risk_level": "high",
178
187
  "reason": "组合攻击链:建立监听服务 → 获取命令执行能力 → 持久化后门"
179
188
  },
180
189
  {
181
190
  "id": "exec-scan-cred",
182
- "stages": ["EXEC", "SCAN", "CRED"],
191
+ "stages": [
192
+ "EXEC",
193
+ "SCAN",
194
+ "CRED"
195
+ ],
183
196
  "min_stages": 3,
184
197
  "risk_level": "high",
185
198
  "reason": "组合攻击链:获取命令执行能力 → 网络侦察 → 访问凭据文件"
186
199
  },
187
200
  {
188
201
  "id": "exec-privesc-cred",
189
- "stages": ["EXEC", "PRIVESC", "CRED"],
202
+ "stages": [
203
+ "EXEC",
204
+ "PRIVESC",
205
+ "CRED"
206
+ ],
190
207
  "min_stages": 3,
191
208
  "risk_level": "high",
192
209
  "reason": "组合攻击链:获取命令执行能力 → 提权 → 访问凭据文件"
193
210
  },
194
211
  {
195
212
  "id": "privesc-cred-exfil",
196
- "stages": ["PRIVESC", "CRED", "EXFIL"],
213
+ "stages": [
214
+ "PRIVESC",
215
+ "CRED",
216
+ "EXFIL"
217
+ ],
197
218
  "min_stages": 3,
198
219
  "risk_level": "critical",
199
220
  "reason": "组合攻击链:提权 → 访问凭据文件 → 数据外传"
200
221
  },
201
222
  {
202
223
  "id": "persist-exfil",
203
- "stages": ["PERSIST", "EXFIL"],
224
+ "stages": [
225
+ "PERSIST",
226
+ "EXFIL"
227
+ ],
204
228
  "min_stages": 2,
205
229
  "risk_level": "high",
206
230
  "reason": "组合攻击链:持久化后门 → 数据外传(C2 信标)"
207
231
  },
208
232
  {
209
233
  "id": "exec-persist-exfil",
210
- "stages": ["EXEC", "PERSIST", "EXFIL"],
234
+ "stages": [
235
+ "EXEC",
236
+ "PERSIST",
237
+ "EXFIL"
238
+ ],
211
239
  "min_stages": 3,
212
240
  "risk_level": "critical",
213
241
  "reason": "组合攻击链:获取命令执行能力 → 持久化后门 → 数据外传"
@@ -0,0 +1,369 @@
1
+ {
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
+ "ap_patterns": {
4
+ "reads_credential": [
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)"
12
+ ],
13
+ "network_egress": [
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*\\."
20
+ ],
21
+ "execute_file": [
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"
30
+ ],
31
+ "write_file": [
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)"
34
+ ],
35
+ "delete_file": [
36
+ "\\brm\\s+-[rf]+\\s+/|\\brm\\s+-[rf]+\\s+[^;&|\\n]*(?:/etc|/var|/opt|/home)",
37
+ "\\bshred\\b|\\bwipe\\b"
38
+ ],
39
+ "disable_security": [
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)"
42
+ ],
43
+ "install_persistence": [
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"
49
+ ],
50
+ "privilege_escalation": [
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"
55
+ ],
56
+ "download_file": [
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+"
59
+ ],
60
+ "archive_data": [
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)"
63
+ ],
64
+ "prompt_injection": [
65
+ "ignore\\s+(?:previous|prior|all)\\s+(?:instructions?|commands?)",
66
+ "<INFORMATION>|TODO:\\s*(?:send|email|transfer|delete|forward|reserve)"
67
+ ],
68
+ "sensitive_data": [
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"
72
+ ],
73
+ "lateral_movement": [
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)"
77
+ ],
78
+ "clear_logs": [
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/"
83
+ ]
84
+ },
85
+ "rules": [
86
+ {
87
+ "id": "mc-ltl-001",
88
+ "type": "ltl",
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
+ ],
106
+ "risk_level": "critical",
107
+ "action": "block",
108
+ "reason": "凭证读取后网络外传(mc-ltl-001)"
109
+ },
110
+ {
111
+ "id": "mc-ltl-002",
112
+ "type": "ltl",
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
+ ],
130
+ "risk_level": "critical",
131
+ "action": "block",
132
+ "reason": "下载后执行(mc-ltl-002)"
133
+ },
134
+ {
135
+ "id": "mc-ltl-003",
136
+ "type": "ltl",
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
+ ],
168
+ "risk_level": "critical",
169
+ "action": "block",
170
+ "reason": "禁用安全后破坏性操作(mc-ltl-003)"
171
+ },
172
+ {
173
+ "id": "mc-ltl-004",
174
+ "type": "ltl",
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
+ ],
206
+ "risk_level": "critical",
207
+ "action": "block",
208
+ "reason": "注入后敏感操作(mc-ltl-004)"
209
+ },
210
+ {
211
+ "id": "mc-ltl-005",
212
+ "type": "ltl",
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
+ ],
230
+ "risk_level": "critical",
231
+ "action": "block",
232
+ "reason": "凭证读取后横向移动(mc-ltl-005)"
233
+ },
234
+ {
235
+ "id": "mc-ltl-006",
236
+ "type": "ltl",
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
+ ],
254
+ "risk_level": "critical",
255
+ "action": "block",
256
+ "reason": "敏感数据访问后清除日志(mc-ltl-006)"
257
+ },
258
+ {
259
+ "id": "mc-ltl-007",
260
+ "type": "ltl",
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
+ ],
278
+ "risk_level": "critical",
279
+ "action": "block",
280
+ "reason": "提权后安装持久化(mc-ltl-007)"
281
+ },
282
+ {
283
+ "id": "mc-ltl-008",
284
+ "type": "ltl",
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
+ ],
302
+ "risk_level": "critical",
303
+ "action": "block",
304
+ "reason": "下载后安装持久化(mc-ltl-008)"
305
+ },
306
+ {
307
+ "id": "mc-ltl-009",
308
+ "type": "ltl",
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
+ ],
336
+ "risk_level": "critical",
337
+ "action": "block",
338
+ "reason": "敏感数据→归档→外传(mc-ltl-009)"
339
+ },
340
+ {
341
+ "id": "mc-ltl-010",
342
+ "type": "ltl",
343
+ "formula": [
344
+ "F",
345
+ [
346
+ "ap",
347
+ "install_persistence"
348
+ ]
349
+ ],
350
+ "risk_level": "medium",
351
+ "action": "approval",
352
+ "reason": "持久化机制安装,需审批(mc-ltl-010)"
353
+ },
354
+ {
355
+ "id": "mc-ctl-001",
356
+ "type": "ltl",
357
+ "formula": [
358
+ "F",
359
+ [
360
+ "ap",
361
+ "clear_logs"
362
+ ]
363
+ ],
364
+ "risk_level": "critical",
365
+ "action": "block",
366
+ "reason": "安全不变量:任何情况不得清除日志(mc-ctl-001,AG(!clear_logs) 线性迹降级:违反 ⟺ 出现 clear_logs ⟺ F(clear_logs) 成立)"
367
+ }
368
+ ]
369
+ }