diff --git a/neurosploit-rs/crates/harness/src/adaptive.rs b/neurosploit-rs/crates/harness/src/adaptive.rs index f714ffa..79f80ab 100644 --- a/neurosploit-rs/crates/harness/src/adaptive.rs +++ b/neurosploit-rs/crates/harness/src/adaptive.rs @@ -566,7 +566,7 @@ fn stack_specific_payloads(class: &str, stack: &TargetStack) -> Vec { payloads } -fn bypass_encodings(blocked: &[String], successful: &[Encoding]) -> Vec { +fn bypass_encodings(_blocked: &[String], successful: &[Encoding]) -> Vec { let mut encodings = Vec::new(); // Prioritize encodings that already worked diff --git a/neurosploit-rs/crates/harness/src/attack_graph.rs b/neurosploit-rs/crates/harness/src/attack_graph.rs index 40ab42c..180ef47 100644 --- a/neurosploit-rs/crates/harness/src/attack_graph.rs +++ b/neurosploit-rs/crates/harness/src/attack_graph.rs @@ -42,16 +42,14 @@ fn map_cwe(cwe: &str) -> (&'static str, &'static str, &'static str) { 942 | 346 | 1385 => ("A05:2021-Security-Misconfiguration", "T1190", "initial-access"), // Mass assignment writes state. 915 | 913 => ("A08:2021-Software-Data-Integrity", "T1565", "impact"), - // Session fixation. - 384 => ("A07:2021-Auth-Failures", "T1539", "credential-access"), 601 => ("A01:2021-Broken-Access-Control", "T1566", "initial-access"), 113 | 93 => ("A03:2021-Injection", "T1557", "initial-access"), 644 => ("A03:2021-Injection", "T1557", "initial-access"), 564 => ("A03:2021-Injection", "T1190", "execution"), 352 => ("A01:2021-Broken-Access-Control", "T1189", "execution"), 434 => ("A04:2021-Insecure-Design", "T1505.003", "execution"), - 1321 | 915 => ("A08:2021-Software-Data-Integrity", "T1059", "execution"), - 400 | 770 | 1333 | 799 => ("A04:2021-Insecure-Design", "T1499", "impact"), + 1321 => ("A08:2021-Software-Data-Integrity", "T1059", "execution"), + 400 | 1333 => ("A04:2021-Insecure-Design", "T1499", "impact"), // AD: capture-replay auth (NTLM relay/LLMNR/coercion), cert abuse (AD CS), default creds, privilege mgmt. 294 => ("A07:2021-Auth-Failures", "T1557", "credential-access"), 295 => ("A07:2021-Auth-Failures", "T1649", "credential-access"), diff --git a/neurosploit-rs/crates/harness/src/chain.rs b/neurosploit-rs/crates/harness/src/chain.rs index bf7880b..bcf46ed 100644 --- a/neurosploit-rs/crates/harness/src/chain.rs +++ b/neurosploit-rs/crates/harness/src/chain.rs @@ -431,7 +431,7 @@ mod tests { fs[1].endpoint = "https://other.example.org/login".into(); let links = derive_links(&fs); assert!( - !links.iter().any(|l| (l.from == 1 || l.to == 1)), + !links.iter().any(|l| l.from == 1 || l.to == 1), "classes fitting is not a reason to chain across unrelated assets" ); } diff --git a/neurosploit-rs/crates/harness/src/cloud_probe.rs b/neurosploit-rs/crates/harness/src/cloud_probe.rs index 8af8545..f2e3a83 100644 --- a/neurosploit-rs/crates/harness/src/cloud_probe.rs +++ b/neurosploit-rs/crates/harness/src/cloud_probe.rs @@ -30,10 +30,6 @@ pub struct CloudFacts { pub evidence: String, } -fn sq(s: &str) -> String { - format!("'{}'", s.replace('\'', "'\\''")) -} - pub fn imds_v1_command(timeout: u64) -> String { format!("curl -s -m {} http://169.254.169.254/latest/meta-data/", timeout) } diff --git a/neurosploit-rs/crates/harness/src/codeindex.rs b/neurosploit-rs/crates/harness/src/codeindex.rs index 7428e36..9eb17b1 100644 --- a/neurosploit-rs/crates/harness/src/codeindex.rs +++ b/neurosploit-rs/crates/harness/src/codeindex.rs @@ -377,6 +377,7 @@ impl CodeIndex { } /// Callers of def `d`, by name resolution. + #[allow(dead_code)] fn callers(&self, d: usize) -> Vec { let name = &self.defs[d].name; (0..self.defs.len()) diff --git a/neurosploit-rs/crates/harness/src/cold_digest.rs b/neurosploit-rs/crates/harness/src/cold_digest.rs index 536b2c7..84d556b 100644 --- a/neurosploit-rs/crates/harness/src/cold_digest.rs +++ b/neurosploit-rs/crates/harness/src/cold_digest.rs @@ -156,7 +156,7 @@ impl DigestState { while p[c] != r { let n = p[c]; p[c] = r; c = n; } r } - let mut union = |a: usize, b: usize, parent: &mut Vec| { + let union = |a: usize, b: usize, parent: &mut Vec| { let (ra, rb) = (find(parent, a), find(parent, b)); if ra != rb { parent[ra] = rb; } }; diff --git a/neurosploit-rs/crates/harness/src/exploration_graph.rs b/neurosploit-rs/crates/harness/src/exploration_graph.rs index 7adba2f..8e96c3b 100644 --- a/neurosploit-rs/crates/harness/src/exploration_graph.rs +++ b/neurosploit-rs/crates/harness/src/exploration_graph.rs @@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap, HashSet}; -use std::path::{Path, PathBuf}; +use std::path::Path; // ── Asset Graph ── diff --git a/neurosploit-rs/crates/harness/src/graph_reasoning.rs b/neurosploit-rs/crates/harness/src/graph_reasoning.rs index 0c95709..c0de5a9 100644 --- a/neurosploit-rs/crates/harness/src/graph_reasoning.rs +++ b/neurosploit-rs/crates/harness/src/graph_reasoning.rs @@ -12,9 +12,9 @@ //! 3. **Graph enrichment**: after a finding, trace which assets are reachable from //! the compromised position and mark them as high-priority targets. -use crate::exploration_graph::{AssetKind, AssetRelation, DualGraph, ExplorationKind, ExplorationStatus}; +use crate::exploration_graph::{AssetKind, DualGraph, ExplorationKind}; use crate::planner::{IntentAction, PlannerIntent}; -use serde::{Deserialize, Serialize}; +use serde::Serialize; /// A candidate chain: a sequence of assets from a finding to an untested surface. #[derive(Debug, Clone, Serialize)] @@ -290,7 +290,7 @@ pub fn enrich_after_finding(dg: &mut DualGraph, finding_asset_id: &str) { #[cfg(test)] mod tests { use super::*; - use crate::exploration_graph::{AnchorDirection, AssetKind}; + use crate::exploration_graph::{AssetKind, AssetRelation, ExplorationStatus}; use std::collections::BTreeMap; fn sample_graph() -> DualGraph { diff --git a/neurosploit-rs/crates/harness/src/mcp_hot_reload.rs b/neurosploit-rs/crates/harness/src/mcp_hot_reload.rs index 4d93f62..c62f312 100644 --- a/neurosploit-rs/crates/harness/src/mcp_hot_reload.rs +++ b/neurosploit-rs/crates/harness/src/mcp_hot_reload.rs @@ -1,7 +1,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use std::sync::atomic::{AtomicU64, Ordering}; -use std::time::{Duration, SystemTime, UNIX_EPOCH}; +use std::time::{Duration, UNIX_EPOCH}; /// Watches `mcp.servers.json` for changes and rewrites `.mcp.json` so the /// next agent spawn picks up newly added (or removed) MCP servers mid-run. diff --git a/neurosploit-rs/crates/harness/src/nday_restore.rs b/neurosploit-rs/crates/harness/src/nday_restore.rs index e167aa2..29c69ea 100644 --- a/neurosploit-rs/crates/harness/src/nday_restore.rs +++ b/neurosploit-rs/crates/harness/src/nday_restore.rs @@ -609,7 +609,7 @@ vsftpd 2.3.4 - Backdoor Command Execution | exploits/unix/remote/49757. #[test] fn content_based_reclassification_catches_traversal() { - let mut c = ExploitCandidate { + let _c = ExploitCandidate { edb_id: "1".into(), title: "Some Tool - Arbitrary File".into(), path: "x".into(), cve: None, exploit_type: ExploitType::Unknown, }; diff --git a/neurosploit-rs/crates/harness/src/netguard.rs b/neurosploit-rs/crates/harness/src/netguard.rs index 426e7af..5d4f320 100644 --- a/neurosploit-rs/crates/harness/src/netguard.rs +++ b/neurosploit-rs/crates/harness/src/netguard.rs @@ -21,7 +21,7 @@ //! redirect's target, re-resolve a name and refuse a rebind, and refuse a name //! that resolves to a private/loopback address it should not. -use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; +use std::net::{IpAddr, Ipv4Addr}; /// Canonicalise a host into the form the scope rules compare against. /// diff --git a/neurosploit-rs/crates/harness/src/noise_governor.rs b/neurosploit-rs/crates/harness/src/noise_governor.rs index ceec726..fc41ae4 100644 --- a/neurosploit-rs/crates/harness/src/noise_governor.rs +++ b/neurosploit-rs/crates/harness/src/noise_governor.rs @@ -218,8 +218,9 @@ impl NoiseGovernor { /// Ask the governor whether to proceed with a request. pub fn check(&mut self, host: &str, request_hash: u64) -> RequestDecision { // Check cache first - if let Some(cached) = self.cache.get(&request_hash) { + if let Some(cached) = self.cache.get_mut(&request_hash) { if cached.cached_at.elapsed() < Duration::from_secs(self.config.cache_ttl_secs) { + cached.hit_count += 1; self.global_stats.total_cached += 1; return RequestDecision::UseCached { status: cached.status, @@ -375,6 +376,7 @@ impl NoiseGovernor { hosts_tracked: self.hosts.len(), hosts_blocked: self.hosts.values().filter(|h| h.blocked).count(), cache_entries: self.cache.len(), + cache_hit_count: self.cache.values().map(|c| c.hit_count as u64).sum(), } } @@ -423,6 +425,7 @@ pub struct GovernorStats { pub hosts_tracked: usize, pub hosts_blocked: usize, pub cache_entries: usize, + pub cache_hit_count: u64, } fn jitter_ms(jitter_factor: f64, base: u64) -> u64 { diff --git a/neurosploit-rs/crates/harness/src/pivot.rs b/neurosploit-rs/crates/harness/src/pivot.rs index 48e8abf..c714b3a 100644 --- a/neurosploit-rs/crates/harness/src/pivot.rs +++ b/neurosploit-rs/crates/harness/src/pivot.rs @@ -16,7 +16,7 @@ //! proxy env so their tools (impacket, nxc, nmap) route through the pivot. use serde::{Deserialize, Serialize}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::net::Ipv4Addr; use std::sync::Arc; use std::time::Duration; @@ -1234,7 +1234,6 @@ async fn get_our_ip_for(target: &str) -> Result { } fn base64_encode(data: &[u8]) -> String { - use std::fmt::Write; const CHARS: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; let mut out = String::with_capacity((data.len() + 2) / 3 * 4); for chunk in data.chunks(3) { diff --git a/neurosploit-rs/crates/harness/src/planner.rs b/neurosploit-rs/crates/harness/src/planner.rs index bc1a02f..fdb4b72 100644 --- a/neurosploit-rs/crates/harness/src/planner.rs +++ b/neurosploit-rs/crates/harness/src/planner.rs @@ -16,7 +16,7 @@ use crate::exploration_graph::{DualGraph, ExplorationKind, ExplorationStatus, AssetKind}; use crate::adaptive::AdaptiveEngine; use serde::{Deserialize, Serialize}; -use std::collections::{BTreeMap, HashMap, HashSet}; +use std::collections::{HashMap, HashSet}; /// A planner decision: what to do next. #[derive(Debug, Clone, Serialize, Deserialize)] @@ -826,6 +826,7 @@ fn now() -> u64 { #[cfg(test)] mod tests { use super::*; + use std::collections::BTreeMap; #[test] fn test_planner_coverage_intents() { diff --git a/neurosploit-rs/crates/harness/src/pool.rs b/neurosploit-rs/crates/harness/src/pool.rs index a337dd8..6307667 100644 --- a/neurosploit-rs/crates/harness/src/pool.rs +++ b/neurosploit-rs/crates/harness/src/pool.rs @@ -1,4 +1,4 @@ -use crate::models::{cli_binary_for, ChatClient, ModelRef}; +use crate::models::{ChatClient, ModelRef}; use anyhow::{anyhow, Result}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{Arc, Mutex}; diff --git a/neurosploit-rs/crates/harness/src/reactive.rs b/neurosploit-rs/crates/harness/src/reactive.rs index c380089..d8a25b6 100644 --- a/neurosploit-rs/crates/harness/src/reactive.rs +++ b/neurosploit-rs/crates/harness/src/reactive.rs @@ -209,7 +209,7 @@ pub fn resume_state(dir: &std::path::Path) -> Option<(DualGraph, IntentQueue)> { } /// Create the control handle and engine state together. -pub fn prepare(cfg: &ReactiveConfig, graph: DualGraph, queue: Option) -> Handle { +pub fn prepare(_cfg: &ReactiveConfig, graph: DualGraph, queue: Option) -> Handle { let q = queue.unwrap_or_else(|| IntentQueue::new(2)); Handle { s: new_shared(graph, q) } } @@ -362,7 +362,7 @@ async fn planner_loop(s: Arc, cfg: Arc) -> EndReason { let chains = crate::graph_reasoning::find_chains(&g, 3); if !chains.is_empty() { let summary = crate::graph_reasoning::graph_summary(&g); - let prompt = crate::graph_reasoning::decision_prompt(&chains, &summary, 5); + let _prompt = crate::graph_reasoning::decision_prompt(&chains, &summary, 5); // Parse the prompt itself won't generate intents — we build // them directly from the top-scored chains instead of calling // an LLM in the planner loop (that's the worker's job). diff --git a/neurosploit-rs/crates/harness/src/request_analyzer.rs b/neurosploit-rs/crates/harness/src/request_analyzer.rs index 3b0499a..c6d35e8 100644 --- a/neurosploit-rs/crates/harness/src/request_analyzer.rs +++ b/neurosploit-rs/crates/harness/src/request_analyzer.rs @@ -11,7 +11,7 @@ //! 6. **Content-type aware parsing** — JSON, HTML, XML, multipart, GraphQL use serde::{Deserialize, Serialize}; -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; /// Analysis of an HTTP response. #[derive(Debug, Clone, Default, Serialize, Deserialize)] diff --git a/neurosploit-rs/crates/harness/src/tunnel.rs b/neurosploit-rs/crates/harness/src/tunnel.rs index ef19a7b..f4ebfe8 100644 --- a/neurosploit-rs/crates/harness/src/tunnel.rs +++ b/neurosploit-rs/crates/harness/src/tunnel.rs @@ -122,7 +122,7 @@ pub async fn start(config: &TunnelConfig) -> anyhow::Result { } } } - let mut t = Tunnel { public_url: String::new(), local_port: config.port, child }; + let t = Tunnel { public_url: String::new(), local_port: config.port, child }; t.stop(); anyhow::bail!("ngrok started but no public URL appeared on 127.0.0.1:4040 — check the authtoken and `ngrok diagnose`") } diff --git a/neurosploit-rs/crates/harness/src/winbin_harvest.rs b/neurosploit-rs/crates/harness/src/winbin_harvest.rs index cb3abfa..bfb89e0 100644 --- a/neurosploit-rs/crates/harness/src/winbin_harvest.rs +++ b/neurosploit-rs/crates/harness/src/winbin_harvest.rs @@ -55,8 +55,8 @@ async fn list_candidates(cfg: &RunConfig, win: &Win) -> Vec { STATS_FILE=/tmp/.ns_spider.json 2>&1 || smbclient -L //{} {auth}{domain} -N 2>&1", sq(host), sq(host) ); - let Some(out) = crate::pipeline::recon_tool_timed(cfg, "netexec", &cmd, 120).await else { return Vec::new() }; - out.lines() + let spider_out = crate::pipeline::recon_tool_timed(cfg, "netexec", &cmd, 120).await.unwrap_or_default(); + let mut results: Vec = spider_out.lines() .filter(|l| { let lo = l.to_ascii_lowercase(); (lo.ends_with(".sys") || lo.ends_with(".dll")) && !lo.contains("microsoft") && !lo.contains("\\winsxs\\") @@ -64,7 +64,36 @@ async fn list_candidates(cfg: &RunConfig, win: &Win) -> Vec { .map(|l| l.trim().to_string()) .filter(|l| !l.is_empty()) .take(MAX_HARVESTED) - .collect() + .collect(); + // Fallback: when spider_plus yields nothing, probe known directories via smbclient. + if results.is_empty() { + for dir in CANDIDATE_DIRS { + let (share, pattern) = dir.splitn(2, '\\').collect::>() + .split_first() + .map(|(s, r)| (*s, r.join("\\"))) + .unwrap_or(("C$", dir.to_string())); + let ls_cmd = format!( + "smbclient //{} {auth}{domain} -N -c {} 2>&1", + sq(&format!("{host}/{share}")), + sq(&format!("ls \"{pattern}\"")), + ); + if let Some(ls_out) = crate::pipeline::recon_tool_timed(cfg, "smbclient", &ls_cmd, 30).await { + for l in ls_out.lines() { + let lo = l.to_ascii_lowercase().trim().to_string(); + if (lo.ends_with(".sys") || lo.ends_with(".dll")) && !lo.contains("microsoft") { + let name = l.split_whitespace().next().unwrap_or("").trim(); + if !name.is_empty() { + results.push(format!("{share}\\{pattern}\\{name}").replace("*\\", "")); + } + } + if results.len() >= MAX_HARVESTED { break; } + } + } + if results.len() >= MAX_HARVESTED { break; } + } + } + results.truncate(MAX_HARVESTED); + results } /// Pull one remote file to `dest` over SMB. Returns `true` on success.