fix: reactive seeds target from prose recon; add --no-reactive off switch

- add_recon always seeds the target asset and extracts in-scope URLs /
  subdomains from free text, so a prose recon answer no longer leaves the
  graph empty (which made the planner quiesce with 0 findings)
- --no-reactive / NEUROSPLOIT_NO_REACTIVE=1 and unchecking the web toggle
  now actually disable reactive and fall back to the phased pipeline
This commit is contained in:
CyberSecurityUP committed 2026-12-02 14:44:32 -03:00
1 parent 2d8ffe70d0
commit 2ed7ec6a51
3 files changed
+111 -7

No files matched your search

+8 -1
View File
@@ -205,6 +205,10 @@ struct Cli {
/// never auto-enabled.
#[arg(long = "no-auto-config", global = true)]
no_auto_config: bool,
/// Disable the reactive engine and use the phased pipeline. Overrides the
/// auto-config default (same as NEUROSPLOIT_NO_REACTIVE=1).
#[arg(long = "no-reactive", global = true)]
no_reactive: bool,
}
/// Flags shared by the infrastructure-style engagements (network · ad · cloud).
@@ -1169,6 +1173,9 @@ async fn main() -> anyhow::Result<()> {
if cli.no_auto_config {
std::env::set_var("NEUROSPLOIT_NO_AUTO", "1");
}
if cli.no_reactive {
std::env::set_var("NEUROSPLOIT_NO_REACTIVE", "1");
}
// Auto-configuration (early env): enable tools/economy when detected.
harness::autoconfig::apply_early();
let base = ensure_agents(&find_base()).await;
@@ -1569,7 +1576,7 @@ async fn main() -> anyhow::Result<()> {
if !models.is_empty() {
cfg.models = models;
}
cfg.reactive = reactive;
cfg.reactive = reactive && !cli.no_reactive;
cfg.mcp_profile = mcp_profile;
cfg.autonomy = autonomy;
cfg.stealth = cli.stealth;
+102 -6
View File
@@ -41,15 +41,22 @@ fn clip(s: &str, n: usize) -> String { s.trim().chars().take(n).collect() }
/// Add recon-discovered assets. Returns how many assets were new.
pub fn add_recon(dg: &mut DualGraph, target: &str, recon: &str, in_scope: &dyn Fn(&str) -> bool) -> usize {
let (Some(s), Some(e)) = (recon.find('{'), recon.rfind('}')) else { return 0 };
if e <= s { return 0; }
let Ok(v) = serde_json::from_str::<Value>(&recon[s..=e]) else { return 0 };
let thost = host_of(target);
let mut added = 0usize;
if thost.is_empty() {
return 0;
}
let kind = if is_ip(&thost) { AssetKind::IpAddress } else { AssetKind::Domain };
added += dg.assets.upsert(kind, &thost, BTreeMap::new(), "target") as usize;
// Always seed the target. Recon is best-effort: even when the model answers
// in prose (no JSON), the planner still needs a root asset to schedule.
let mut added = dg.assets.upsert(kind, &thost, BTreeMap::new(), "target") as usize;
let root_id = dg.assets.find(kind, &thost).map(|a| a.id.clone());
added += add_recon_text(dg, recon, &thost, &root_id, in_scope);
let (Some(s), Some(e)) = (recon.find('{'), recon.rfind('}')) else { return added };
if e <= s {
return added;
}
let Ok(v) = serde_json::from_str::<Value>(&recon[s..=e]) else { return added };
for key in ["hosts", "subdomains"] {
for raw in strings(&v, key) {
@@ -81,6 +88,77 @@ pub fn add_recon(dg: &mut DualGraph, target: &str, recon: &str, in_scope: &dyn F
added
}
/// Pull URLs and in-scope subdomains out of free-text recon (models often reply
/// in prose instead of the requested JSON). Never invents assets: only absolute
/// URLs whose host is in scope and subdomains of the target.
fn add_recon_text(
dg: &mut DualGraph,
recon: &str,
thost: &str,
root_id: &Option<String>,
in_scope: &dyn Fn(&str) -> bool,
) -> usize {
let mut added = 0usize;
let mut seen = std::collections::BTreeSet::new();
for raw in recon.split(|c: char| {
c.is_whitespace() || matches!(c, '"' | '\'' | ',' | '(' | ')' | '[' | ']' | '<' | '>' | '`')
}) {
let tok = raw.trim().trim_end_matches(['.', ';', ':', ')', ']', '}', '"', '\'']);
if tok.is_empty() || tok.len() > 300 || !seen.insert(tok.to_string()) {
continue;
}
if added >= MAX_NEW_ASSETS {
break;
}
if tok.starts_with("http://") || tok.starts_with("https://") {
if !in_scope(tok) {
continue;
}
added += dg
.assets
.upsert(AssetKind::Endpoint, tok, BTreeMap::new(), "recon-text") as usize;
if let (Some(root), Some(ep)) = (
root_id,
dg.assets.find(AssetKind::Endpoint, tok).map(|a| a.id.clone()),
) {
dg.assets.relate(&ep, root, AssetRelation::HostedOn);
}
} else if looks_like_host(tok) {
let host = tok.trim_start_matches("*.").to_lowercase();
if host == thost || !host.ends_with(&format!(".{thost}")) {
continue;
}
if !in_scope(&format!("https://{host}")) {
continue;
}
added += dg
.assets
.upsert(AssetKind::Subdomain, &host, BTreeMap::new(), "recon-text") as usize;
if let (Some(root), Some(sub)) = (
root_id,
dg.assets.find(AssetKind::Subdomain, &host).map(|a| a.id.clone()),
) {
dg.assets.relate(root, &sub, AssetRelation::ParentOf);
}
}
}
added
}
fn looks_like_host(s: &str) -> bool {
if s.is_empty() || s.len() > 253 || s.contains('/') || !s.contains('.') {
return false;
}
if !s
.chars()
.all(|c| c.is_ascii_alphanumeric() || matches!(c, '.' | '-' | '_'))
{
return false;
}
let tld = s.rsplit('.').next().unwrap_or("");
tld.len() >= 2 && tld.chars().any(|c| c.is_ascii_alphabetic())
}
/// Record findings as intent -> finding with anchors. Returns (new, updated).
pub fn add_findings(dg: &mut DualGraph, target: &str, findings: &[Finding], in_scope: &dyn Fn(&str) -> bool) -> (usize, usize) {
// One root goal per target.
@@ -165,6 +243,24 @@ mod tests {
assert!(dg.assets.edges.iter().any(|e| e.kind == AssetRelation::ParentOf));
}
#[test]
fn prose_recon_still_seeds_target_and_endpoints() {
let mut dg = DualGraph::default();
let any = |_u: &str| true;
let n = add_recon(
&mut dg,
"http://127.0.0.1:8765/",
"Found http://127.0.0.1:8765/login then api.t.com",
&any,
);
assert!(n >= 1);
assert!(dg.assets.find(AssetKind::IpAddress, "127.0.0.1").is_some());
assert!(dg
.assets
.find(AssetKind::Endpoint, "http://127.0.0.1:8765/login")
.is_some());
}
#[test]
fn findings_become_intent_finding_with_anchors_and_dedupe() {
let mut dg = DualGraph::default();
+1
View File
@@ -665,6 +665,7 @@ function autoOptOutEnv(body) {
if (body.revalidatePoc === false) env.NEUROSPLOIT_NO_REVALIDATE = '1';
if (body.evasion === false) env.NEUROSPLOIT_NO_EVASION = '1';
if (body.sandbox === 'host') env.NEUROSPLOIT_NO_SANDBOX = '1';
if (body.reactive === false) env.NEUROSPLOIT_NO_REACTIVE = '1';
return env;
}