@kenhkl/agent-moss 0.13.0 → 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": "组合攻击链:获取命令执行能力 → 持久化后门 → 数据外传"