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
- 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). Seereferences/control-plane-mining.md. - Decompile client/chain JS as the routing spec: URL-rewrite hooks (
XMLHttpRequest.prototype.openoverrides, origin+mount-prefix rewrites likeorigin + "/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/*.jsand 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. - 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. - Verify every documented route behaviorally across all vhosts, nonstandard ports, and GET/POST. Timeouts get ≥4 retries on different exits before being called dead.
- 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). - 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.
- 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. - 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. - 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/subcliterals (grep -ohE '(itype|subc)\s*[:=]\s*"[a-zA-Z_]+') and list the distinctsubcvalues — 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. Theemail/usernameconstants are not secrets: they sit in the payload config class (see packer pitfall) and in the panel'slocalStoragekeys. - 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. Ifusercheckis the only identity field, forge it with the admin username from the payload/panel — the connection is then authorized and everyslr_panelsendcommand runs (SMS,Contacts,Keylog,LOADAPPS,cam,mic,screen,files,SMSSEND,OPENINJ). Detect success by the disappearance of the未授权操作/unauthorizedreply, not by a positive ack (joinfrequently answers nothing at all). - Command targets must be online. Device-facing commands time out for a device whose
lastPingis stale; filter the inventory tonow - lastPing < 2-3 minbefore 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 30proves 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. 403with NOWWW-Authenticateacross an entire admin subtree (bare nginx page) = source-IP allow/deny gate — the path-mutation +X-Forwarded-For/X-Real-IPmatrix 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>.phplogin page titled…加固/CHINA DRAGON C2is the family's APK crypter / hardening panel (中国龙C2-class, sold commercially as 报毒处理/免杀系统): only<name>.php+captcha.phpexist, 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 — fetchcore.urland 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 inreferences/js-login-obfuscation.md.- Next.js frontends (
__next_error__,/_next/static/chunks/…, turbopack markers): probe thex-middleware-subrequest: middleware:middleware:middleware:middleware:middlewareheader 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 -xloop 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-verifystep): a correct password just parks you at a server-side compare. Park it ascredentials cracked / 2FA walland 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.xmlwith the ZIP encrypted flag (0x1) set while the bytes are ordinary Deflate: read the local file header (offset/size atheader_offset, thenzlib.decompressobj(-15).decompress(data)) and confirm with CRC32 — both entries recovered with zero password effort, so aBad passwordfrom 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.dexthen 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_managemonitor 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).