diff --git a/neurosploit-rs/app/src/main.rs b/neurosploit-rs/app/src/main.rs index ebce10a..57edc6c 100644 --- a/neurosploit-rs/app/src/main.rs +++ b/neurosploit-rs/app/src/main.rs @@ -140,6 +140,20 @@ struct Cli { /// burp, rea, neurosploit). Repeatable. #[arg(long = "mcp-server", global = true)] mcp_server: Vec, + /// Stealth / OPSEC mode: slower and quieter, living-off-the-land. Lowers + /// recon intensity, prefers native tooling over noisy uploads (less likely + /// to trip AV/EDR), paces actions — without dropping test coverage. + #[arg(long = "stealth", global = true)] + stealth: bool, + /// Skip the adversarial validation vote. Keep every finding with the severity + /// its agent assigned (status `unvalidated`); discard nothing useful. + #[arg(long = "no-validate", global = true)] + no_validate: bool, + /// Route the planner/strategist role to a specific model (provider:model), + /// e.g. a second provider proposing alternative approaches, while the rest of + /// the pool executes and validates. + #[arg(long = "planner-model", global = true)] + planner_model: Option, } #[derive(Subcommand)] @@ -1090,6 +1104,11 @@ async fn main() -> anyhow::Result<()> { cfg.reactive = reactive; cfg.mcp_profile = mcp_profile; cfg.autonomy = autonomy; + cfg.stealth = cli.stealth; + cfg.no_validate = cli.no_validate; + cfg.planner_model = cli.planner_model.clone(); + if cfg.no_validate { std::env::set_var("NEUROSPLOIT_NO_VALIDATE", "1"); } + if cfg.stealth && cfg.recon_intensity > 2 { cfg.recon_intensity = 2; } apply_creds(&mut cfg, creds.as_deref()).await; let out = run_engagement(&base, cfg, mcp, false).await?; print_findings(&out); @@ -1209,6 +1228,20 @@ async fn main() -> anyhow::Result<()> { cli.session_environment.as_deref().unwrap_or("lab"), cli.session_policy.as_deref().unwrap_or("web"), )?; + cfg.neo4j = cli.neo4j.clone(); + cfg.stealth = cli.stealth; + cfg.no_validate = cli.no_validate; + cfg.planner_model = cli.planner_model.clone(); + // A dedicated planner model also joins the pool so it actually runs + // (proposes alternative approaches alongside the primary) and takes + // part in cross-model voting. + if let Some(pm) = cfg.planner_model.clone() { + if !pm.trim().is_empty() && !cfg.models.iter().any(|m| m == &pm) { + cfg.models.push(pm); + } + } + if cfg.no_validate { std::env::set_var("NEUROSPLOIT_NO_VALIDATE", "1"); } + if cfg.stealth && cfg.recon_intensity > 2 { cfg.recon_intensity = 2; } let out = run_mode(&base, cfg, false, Mode::Host).await?; print_findings(&out); } diff --git a/neurosploit-rs/crates/harness/src/graph_memory.rs b/neurosploit-rs/crates/harness/src/graph_memory.rs index 1cf1951..7890a48 100644 --- a/neurosploit-rs/crates/harness/src/graph_memory.rs +++ b/neurosploit-rs/crates/harness/src/graph_memory.rs @@ -525,13 +525,32 @@ fn privileged_name(n: &str) -> bool { fn finding_status(f: &Finding) -> Option { match f.review_status.as_str() { - "rejected" => None, + // A vote-rejected finding that still carries a concrete receipt — a + // looted credential/key/secret, a command output, captured evidence — + // is NOT dropped from the graph. It enters as needs-review so it informs + // path analysis and can seed chain expansion: a useful key must never + // lose its value just because the opinion-vote did not confirm it. + "rejected" => if finding_has_receipt(f) { Some(Status::NeedsReview) } else { None }, "confirmed" => Some(Status::Confirmed), _ if f.validated => Some(Status::Confirmed), _ => Some(Status::NeedsReview), } } +/// True when the finding carries something reproducible/reusable: looted +/// credential or secret, a captured evidence record, or a payload/command. +fn finding_has_receipt(f: &Finding) -> bool { + let has = |s: &str| { + let t = s.trim(); + !t.is_empty() && t != "N/A" && t != "n/a" && t != "none" && t != "-" + }; + f.evidence_data.is_some() + || has(&f.evidence) + || has(&f.secret) + || has(&f.account) + || has(&f.payload) +} + fn exchanges(ev: &Evidence) -> Vec<(String, &Exchange)> { let mut v: Vec<(String, &Exchange)> = Vec::new(); if let Some(x) = &ev.baseline { diff --git a/neurosploit-rs/crates/harness/src/pipeline.rs b/neurosploit-rs/crates/harness/src/pipeline.rs index 9a435bc..da56222 100644 --- a/neurosploit-rs/crates/harness/src/pipeline.rs +++ b/neurosploit-rs/crates/harness/src/pipeline.rs @@ -121,6 +121,27 @@ RULES OF ENGAGEMENT:\n\ proceeding — and never fabricate results you did not actually produce.\n\ \n"; +const STEALTH_PREAMBLE: &str = "\ +STEALTH / OPSEC MODE — this engagement is run quiet. Minimise footprint and \ +detection WITHOUT reducing test coverage or depth — you still pursue every \ +objective, just on a lower-observable path:\n\ +• Pace yourself: avoid bursty scans and parallel floods. Prefer slow, targeted \ + probes (e.g. nmap -T2/-T1, -sT, only the ports you need) over mass/aggressive \ + scans (no -T4/-T5, no rustscan full-range, no noisy brute bursts).\n\ +• Live off the land: prefer tools already present on the target and native \ + protocols (SSH, built-in PowerShell/WMI/WinRM, nltest, dsquery, reg, native \ + SMB) over UPLOADING binaries. Uploaded tools (e.g. chisel.exe, mimikatz.exe) \ + trip AV/EDR — reach for them only when no native path exists, and stage them \ + in a location an admin exclusion covers, renamed/innocuous.\n\ +• Credentials: no blind password spraying that risks lockout. Test a specific \ + known/looted credential; space attempts; respect lockout thresholds.\n\ +• Tunnelling: prefer a single clean hop and native SOCKS over deep nested \ + forwards; keep listeners minimal and clean them up.\n\ +• Clean up artifacts you drop (temp files, uploaded tools, created accounts) and \ + note what you left behind. Quality of proof stays the same — receipts for every \ + finding — just obtained quietly.\n\ +\n"; + const RECON_SYS: &str = "You are an elite web recon specialist on an AUTHORIZED engagement. Actively fetch the target with your tools and map the REAL attack surface in DEPTH — do not ask for permission, proceed:\n\ - Crawl pages, forms and parameters; record every input, header, cookie and redirect.\n\ - DOWNLOAD the linked JavaScript bundles (curl each script) and ANALYZE them: extract API endpoints/routes, hidden/undocumented parameters, GraphQL operations, secrets / API keys / tokens, cloud & third-party URLs, feature flags, and `sourceMappingURL` references (fetch source maps if exposed to recover original source).\n\ @@ -268,6 +289,9 @@ fn operator_directives(cfg: &RunConfig) -> String { if let Some(focus) = cfg.instructions.as_deref().filter(|x| !x.trim().is_empty()) { s.push_str(&format!("OPERATOR FOCUS — prioritise this: {focus}\n")); } + if cfg.stealth { + s.push_str(STEALTH_PREAMBLE); + } // Scope is enforced in code (see `crate::scope`); this block exists so the // agent does not burn a round trip discovering a boundary the guard would // have refused anyway. The prose version alone was never a control. @@ -3588,6 +3612,22 @@ async fn validate(candidates: Vec, pool: &ModelPool, sys: &str, vote_n: } async fn validate_with_persist(candidates: Vec, pool: &ModelPool, sys: &str, vote_n: usize, tx: &Sender, workdir: Option<&str>) -> Vec { + // --no-validate: operator opted out of the adversarial vote. Keep every + // finding with the severity its agent assigned, marked `unvalidated` — the + // panel discards nothing. (Set by the launcher when cfg.no_validate.) + if std::env::var("NEUROSPLOIT_NO_VALIDATE").map(|v| v == "1").unwrap_or(false) { + let _ = tx.send(format!("⚠ --no-validate: skipping the vote — keeping all {} finding(s) with agent-assigned severity", candidates.len())).await; + return candidates.into_iter().map(|mut f| { + f.validated = false; + if f.review_status.is_empty() || f.review_status == "rejected" { + f.review_status = "unvalidated".into(); + } + if f.review_reason.is_empty() { + f.review_reason = "validation vote skipped (--no-validate); kept with agent severity".into(); + } + f + }).collect(); + } // Stamp the clock. A path is a sequence in time as much as in dependency: // the attack-path builder refuses to let a later step enable an earlier // one, and it can only do that if each step records when it was proven. @@ -3656,6 +3696,20 @@ async fn validate_with_persist(candidates: Vec, pool: &ModelPool, sys: f.review_status = "needs-review".into(); f.review_reason = format!("voter rejected the narrative, mechanic retained: {}", f.review_reason.trim()); f.confidence = f.confidence.min(0.5); + } else if finding_has_loot(&f) { + // The finding carries a looted credential, private key or + // secret. A leaked long-lived credential / key / API key that + // authenticates or is reused downstream is a REAL finding — + // not "just a cat of a file on an already-owned host", which + // is how the opinion-vote tends to dismiss it. Keep it as + // needs-review at its OWN severity (never rejected, never + // auto-capped to Low): a useful key must not lose its value. + f.review_status = "needs-review".into(); + f.review_reason = format!( + "kept — looted credential/secret/key present and reusable; validator under-credited it: {}", + f.review_reason.trim() + ); + f.confidence = f.confidence.max(0.5); } else if grounded_receipt(&f) || has_http_receipt(&f) { // Unanimously rejected by the opinion-vote, but the finding // carries a concrete, REPRODUCIBLE receipt (a captured HTTP @@ -3943,6 +3997,18 @@ fn parse_claims(o: &serde_json::Map) -> Option bool { + let has = |s: &str| { + let t = s.trim(); + !t.is_empty() && t != "N/A" && t != "n/a" && t != "none" && t != "-" + }; + has(&f.secret) || has(&f.account) +} + fn grounded_receipt(f: &Finding) -> bool { if f.evidence_data.is_some() { return true; diff --git a/neurosploit-rs/crates/harness/src/types.rs b/neurosploit-rs/crates/harness/src/types.rs index 50f8291..7cd0389 100644 --- a/neurosploit-rs/crates/harness/src/types.rs +++ b/neurosploit-rs/crates/harness/src/types.rs @@ -337,6 +337,21 @@ pub struct RunConfig { /// When set, the matching MCP server and tool allowlist are auto-configured. #[serde(default)] pub mcp_profile: Option, + /// Stealth / OPSEC mode: slower, quieter, living-off-the-land. Lowers recon + /// intensity, injects an OPSEC directive into every agent, and prefers native + /// tooling over noisy uploads — without dropping test coverage. + #[serde(default)] + pub stealth: bool, + /// Skip the adversarial validation vote entirely. Every finding is kept with + /// the severity its agent assigned and marked `unvalidated`. Nothing useful + /// is discarded by the panel. + #[serde(default)] + pub no_validate: bool, + /// Route the planner / strategist role to a specific model (e.g. a second + /// provider proposing alternative approaches), while executor and validator + /// use the rest of the pool. Empty → the primary model plans. + #[serde(default)] + pub planner_model: Option, } fn default_autonomy() -> String { @@ -406,6 +421,9 @@ impl RunConfig { autonomy: default_autonomy(), reactive: false, mcp_profile: None, + stealth: false, + no_validate: false, + planner_model: None, } } }