# C2 Infrastructure Pentest

> Use when attacking adversary C2 / attack-kit web infra.

- Skill: `yufeifeio/c2-infrastructure-pentest` (Agent Skill, multi-file: 5 files)
- Install (CLI): `npx get-skill add yufeifeio/c2-infrastructure-pentest`
- Raw SKILL.md: https://api.skillmd.com/api/skills/yufeifeio/c2-infrastructure-pentest/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- Author: Yufeifeio (https://skillmd.com/u/yufeifeio)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/yufeifeio/c2-infrastructure-pentest

---


# C2 Infrastructure Pentest

Adversary C2 / attack-kit web plane: a small Node/Python control service behind nginx (usually behind a CDN, fronted by catch-all decoy pages), static exploit-chain files, and wide-open device/exfil APIs. Typical flow: map the control plane, abuse the data plane's trust gaps, land on the operator side (session theft → panel → RCE endpoint).

## Order of operations
1. **Mine same-family source & deploy docs before any fuzzing** — highest-ROI move. Deploy tutorials leak the port/service map, nginx route tables, directory layouts, service units (watch for `User=root` — app RCE = host root), env/secret usage, DB names, and anti-scan mechanisms. A family-published repo is often their own server webroot (server source, admin-panel auth model, committed keys/certs). See `references/control-plane-mining.md`.
2. **Decompile client/chain JS as the routing spec**: URL-rewrite hooks (`XMLHttpRequest.prototype.open` overrides, origin+mount-prefix rewrites like `origin + "/c2" + pathname`) reveal the real API mount points; boot code carries exact write-endpoint JSON field names, query-vs-body splits, and startup config fetch paths. The **deployed** copies are the freshest source — kit JS ships to victims unauthenticated, so pull `/client/*.js` and chain files from the live host and diff against the leaked mirror: live builds carry the newest aliases, route tables, embedded shared secrets, and the exact beacon/callback formats the operator UI renders.
3. **Build a response-signature table per host × port × method before fuzzing.** Catch-all decoys return 200 for everything — classify by body content and banners, not status codes. Cross-check TLS: one multi-name cert on an operator box often enumerates its sibling services (`admin.`/`c2.`/`rec.`/`land.`-style SANs); re-pull from crt.sh to watch new services deploy.
4. **Verify every documented route behaviorally** across all vhosts, nonstandard ports, and GET/POST. Timeouts get ≥4 retries on different exits before being called dead.
5. **Attack the unauthenticated data plane first**: check-in / sync / log / tracking write endpoints accept arbitrary JSON. Capture unauthenticated health/stats endpoints too — they routinely leak live operational counts (devices controlled, events) as numeric impact proof. Plant tracked payloads in every field an operator UI renders, then automate the watch (`references/operator-session-xss.md`).
6. **Reuse client-hardcoded shared secrets** against the agent/device API (beacon/poll/exfil/result) — but know the limit: per-device command queues validate real registered devices, so fake IDs yield empty results; don't grind there. The same holds for device UUIDs lifted from a SIBLING C2 — registries are per-system even within one family and cross-polling returns empty; one confirming round, then stop.
7. **Sweep operator/looted hosts for network file services.** NFS (2049)/rpcbind (111) on operator dev/ECS boxes routinely expose world-open shares (`no_root_squash` = files land as uid 0); a writable share plus the box's companion HTTP dir listing covers read+write. Procedure and raw-RPC scripts: `nfs-rpc-exploitation`.
8. **Harvest operator IPs from the control plane's audit/log tables and attack those IPs — the highest-yield pivot once the C2 host itself is hardened.** Audit tables record every login source; the operator population's IPs (admin homes, jump boxes, VPN exits) are where the family's OTHER systems live — billing portals, gateway/appliance panels, work-tool frontends — none of which are exposed on the C2 host. Attribute first (`http://ip-api.com/json/<ip>`: country/ISP/ASN clusters separate real operator boxes from proxied/residential noise), then nmap common ports on each candidate; drop IPs answering nothing (proxied home lines), fingerprint every live one against the stack list under Response signatures. Do not call the surface exhausted while un-scanned operator IPs remain in the audit tables.
9. **Credential reuse is a family-wide assumption, not a lucky guess.** The operator population tends to reuse one admin password across everything it runs — a password that works on the C2 console frequently opens the IP-management panel and the billing front too. Log every working credential once, then replay it against all sibling/adjacent systems before investing in per-system brute force; conversely, a password recovered anywhere in the family is worth a spray across every known system.

## WebSocket operator plane — the auth gap the HTTP middleware never covers

The operator UI usually talks to the C2 over a WebSocket (`/api/ws/`) while the same host's HTTP API
sits behind a strict token middleware. The two planes have **separate auth**, and the WS one is
routinely weaker. Audit the WS message map **before** any login dictionary — a 10k-word run against a
panel cost 80 minutes and returned nothing while the WS answered the same data unauthenticated.

- **Recover the whole message schema from the panel bundle**, not by fuzzing: grep every asset chunk
  for `itype`/`subc` literals (`grep -ohE '(itype|subc)\s*[:=]\s*"[a-zA-Z_]+'`) and list the distinct
  `subc` values — that list IS the command set (read queries plus device control). The panel's
  per-device view shows the exact object shape each command sends (`pid`, paging, date, type).
- **Read queries are often unauthenticated even when they return mass PII.** Measured shape: a
  `{"itype":"slr_panel","subc":"checkphone","email":"<operator email>","token":"","page":1,"pageSize":50}`
  answered the full device inventory — id, model, OS, country, install time, accessibility state,
  wallpaper/screenshot base64 — with an **empty token**. The `email`/`username` constants are not
  secrets: they sit in the payload config class (see packer pitfall) and in the panel's
  `localStorage` keys.
- **The auth handshake is often a username string, not a signed token.** The panel sends
  `{"itype":"slr_panel","subc":"join","pid":"<device>","usercheck":"<CURRENT-USER>"}` when it
  opens the socket. If `usercheck` is the only identity field, forge it with the admin username from
  the payload/panel — the connection is then authorized and every `slr_panelsend` command runs
  (`SMS`, `Contacts`, `Keylog`, `LOADAPPS`, `cam`, `mic`, `screen`, `files`, `SMSSEND`, `OPENINJ`).
  Detect success by the disappearance of the `未授权操作` / `unauthorized` reply, not by a positive ack
  (`join` frequently answers nothing at all).
- **Command targets must be online.** Device-facing commands time out for a device whose `lastPing`
  is stale; filter the inventory to `now - lastPing < 2-3 min` before commanding. Server-stored
  queries (keylog by date, uploaded lists) answer regardless of device state.
- Sample one device per command class and stop — the inventory is the impact proof; bulk-pulling
  victim SMS/contacts adds legal exposure, not findings.

## Response signatures (build before fuzzing)
- 200 + identical HTML for arbitrary paths = SPA/catch-all decoy. Compare bodies, not status — and before writing it off as static, read the inline scripts and retry with the victim device's UA (iPhone UA for iOS-kit C2s): the "decoy" is often the UA-gated distributor itself, hiding the chain in a 1×1 offscreen iframe only for matching UAs while desktop/curl always gets the decoy (a failed chain silently keeps the decoy). One `-A '<iPhone UA>'` diff settles it.
- `405 Not Allowed` + server banner on POST = path NOT proxied (fell into a static-serving location). The route is absent, not broken — stop testing it. Confirm the answer is global (same via Tor and a fresh region) before concluding: the same URL answering cover page vs styled 404 vs 405 across exits = a per-IP reputation layer, not routing.
- 401/403 JSON with a consistent server-specific message = auth middleware gating an entire prefix. Find the exact whitelisted subset by testing sibling paths/methods.
- Plain `ok` / single-token bodies on arbitrary subpaths = greedy stub or emulation layer, not a real API. Don't confuse stub success with real persistence. Map the stub family cheaply: one known-real path + several plausible names + one random garbage name — plausible names returning the identical stub body while garbage gets the connection dropped = decoy layer; stop blind enumeration there, the real routes live elsewhere. Ground truth for which path is genuinely wired: the call sites inside the shipped client/chain JS — an endpoint the kit itself calls is real even when its reply shape matches the stubs.
- Login endpoints: empty body AND garbage creds returning the same success shape (`{"msg":"OK","code":200}`-style) = decoy stub, not a real login — real ones branch per input (`用户名不能为空` vs `用户名或密码错误`). Test both before investing in credential work.
- Explicit Spring-style errors (`Request method 'X' is not supported`) = real handler on a routed path; dig methods and params.
- **PHP warnings embedded in a 200 response are free path/line disclosure.** A device-facing write endpoint answering `Warning: mkdir(): Permission denied in /var/www/html/api/Error.php on line 30` proves the parameter set reached the sink (so the field names are correct) and hands you the absolute webroot plus the handler line — use it to size later file-write ideas instead of guessing directories. A log/error endpoint that fails its filesystem op is also a dead end for log-poisoning-to-webshell: re-test the same endpoint's parameters for a DB sink before writing it off.
- `403` with NO `WWW-Authenticate` across an entire admin subtree (bare nginx page) = source-IP allow/deny gate — the path-mutation + `X-Forwarded-For`/`X-Real-IP` matrix answers a uniform 403; record and pivot instead of grinding variants.
- A download/static path that 302s to `/admin` (payload-bundle URL, mirror path) hands you the panel path — follow every redirect on download endpoints. A dedicated APK/download host whose root 302s to a single `/<name>.php` login page titled `…加固` / `CHINA DRAGON C2` is the family's **APK crypter / hardening panel** (中国龙C2-class, sold commercially as 报毒处理/免杀系统): only `<name>.php` + `captcha.php` exist, and the public product repos (usually README-only) leak deploy defaults — DB name = user = password is a common pattern.
- Device-facing status JSON (`{ok:true, settings:…, core:{url:…}}`) leaks the payload-bundle URL and refresh intervals — fetch `core.url` and note where it lands.
- **Stack fingerprints → first probe:**
  - `302 → /whmcs/clientarea.php` (+ `x-powered-by: PHP`, Apache) = WHMCS hosting/billing portal — the operator's sales front. Probe the client-area/cart/register flow and match the page's WHMCS version against known CVEs; the 302 appears on the bare domain, so never treat a root URL's redirect chain as uninteresting.
  - `Server: BarracudaHTTP` + `/cgi-mod/index.cgi` + a CUI (`/cui/*.js`) shell = Barracuda appliance (mail-gateway class). Its login obfuscates the password client-side — reverse-and-replay recipe and default-credential candidates in `references/js-login-obfuscation.md`.
  - Next.js frontends (`__next_error__`, `/_next/static/chunks/…`, turbopack markers): probe the `x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware` header against admin/dashboard paths — unpatched builds pass it through auth middleware for free.
  - A bundle or docs page linking a public GitHub repo = the panel is open source: pull the repo and read its auth/route code directly; source beats black-box probing.

## Pitfalls
- Deployed nginx ≠ deploy tutorial: operators edit routes, so a documented route can 405/cover live. Verify behaviorally, never assume from docs.
- Unknown JSON fields are silently dropped by Spring/Jackson (default `FAIL_ON_UNKNOWN_PROPERTIES=false`): writes "succeed" while storing nothing. Source exact field names/casing from client code before trusting any OK, and re-plant if you used the wrong schema.
- Junk proxies: an exit that returns foreign banners, router/NAS pages, or arbitrary local services for any Host:port is broken infrastructure, not target intel. Validate proxies against TWO independent markers of the intended target (see `scripts/validate_proxies.py`).
- Region-tuned WAF rules can 403 datacenter/known-bad exits while regional (e.g. CN-range) exits pass: when the operator population is regional, build a regional proxy subset rather than declaring the vhost unreachable.
- Many HTTP proxies forward only 80/443; enumerate per-proxy CONNECT capability (short-timeout `curl -x` loop per proxy) before calling a nonstandard port dead.
- Timing-based blind SQLi through rotator pools is noise (proxy jitter of tens of seconds ≫ SLEEP(5)). Pin one stable exit or prefer error-based / response-diff channels.
- Path-normalization whitelist bypasses (dot-segments, semicolons, double-encoding) against a modern normalized stack (Spring/Tomcat + token middleware seeing decoded paths) fail comprehensively — one quick matrix round max, then pivot to abusing the whitelisted endpoint's own data flow.
- Mature C2s ship anti-scanner daemons with dynamic IP deny lists: sudden total blockage = temporary auto-block; back off and rotate — hammering extends it.
- **Measure the login rate limit before any dictionary work.** Crypter/C2 panels commonly throttle to a few POSTs per minute behind a single-use captcha, which makes a 1000-word list a 4-hour no-op. Crack the captcha if it is a dot-matrix font (`captcha-ocr-solving/references/dot-matrix-font.md`), confirm the throttle with six spaced probes, then stop and report the asset instead of hanging a brute — the panel's existence is itself reportable impact.
- Origin-sealed check: if the CDN-fronted target has wildcard DNS, no MX/SPF, no origin certs in CT logs, and a Host-header sweep of the suspected range finds no match, assume the origin is IP-allowlisted to the CDN — cap the hunt and shift investment to the planted-XSS operator-session path, which does not need the origin.
- Chat-app-gated 2FA on an operator panel (password login returns a challenge; the 6-digit code goes to the operator's messenger, e.g. a `login-telegram-verify` step): a correct password just parks you at a server-side compare. Park it as `credentials cracked / 2FA wall` and sidestep via the planted-XSS path — spraying survivors burns IP reputation for nothing.
- Report discipline: distinguish "endpoint reachable" vs "write accepted" vs "data visibly stored/rendered to a human" — prove the third before claiming impact (self-created/test accounts never count as takeover).
- **A commercial crypter/hardening packer's "encryption" is usually cosmetic — test raw Deflate and a short XOR before any password work.** Packed APKs ship `classes.dex`/`AndroidManifest.xml` with the ZIP encrypted flag (`0x1`) set while the bytes are ordinary Deflate: read the local file header (offset/size at `header_offset`, then `zlib.decompressobj(-15).decompress(data)`) and confirm with CRC32 — both entries recovered with zero password effort, so a `Bad password` from the ZIP library only means the flag lied. Bundle assets (`assets/*.bt`-class) are typically a fixed repeating XOR: derive the key from known plaintext (a rendered view starts `<!DOCTYPE html>`), confirm the length by an index-of-coincidence peak, then decrypt the set.
- **Decompile the payload DEX and read its config class before attacking the panel.** Packer loaders keep one small class with the build-injected constants — C2 domain/WS URL, operator email/login name, XOR key, campaign tag, disguised app name. That class supplies the username and identity strings the WS `join` (above) accepts, and the campaign tag names the family for the report. `jadx -d out --no-res --no-imports classes.dex` then read the class referencing the C2 host string.

## Execution notes (Hermes)
- Long proxy sweeps (10–60 s/request) must run backgrounded with a log file (`nohup … > x.log 2>&1 &` + notify) and be polled from the log; foreground shell calls are capped and kill a sweep mid-run.
- Quoting-heavy one-liners get rejected — write a script file, then run it.
- Passive waits (payloads awaiting operator review): deterministic snapshot script in `~/.hermes/scripts/` + `cronjob_manage` monitor mode. First tick = baseline; snapshot output must be timestamp-free or every tick looks changed; delivery to the origin chat only on change.

## References
- `references/control-plane-mining.md` — repo/deploy-doc mining checklist: finding operator repos, webroot-mirror loot (server source, panel auth model, committed keys/certs), repo-derived credential pivots, loader decompile targets.
- `references/operator-session-xss.md` — planting into operator-visible stores, stealer design, watch→wake loop, post-trigger token replay.
- `references/js-login-obfuscation.md` — reverse a login form's client-side password obfuscation from the page's own JS (inline scripts first) and replay it with fresh per-load tokens; Barracuda CUI algorithm, field map, and pacing notes.
- `scripts/validate_proxies.py` — dual-marker proxy validator (status alone is not enough).

