mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-12-05 02:24:17 +01:00
fix(harness): resolve 37 compilation warnings and 3 bugs
Bug fixes: - attack_graph.rs: remove unreachable duplicate CWE match arms (915, 384, 770, 799) - pipeline.rs: wire technology detection flags into agent negative scoring - pipeline.rs: add Hermes/DeepSeek V2 format detection to looks_like_tool_call Cleanup: remove 10 unused imports, prefix 7 unused vars, remove 2 unnecessary mut qualifiers, mark 5 dead code items, remove 1 unnecessary parenthesis. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
9e50dcbfec
commit
9a087833a6
19 files changed
+57
-30
No files matched your search
@@ -566,7 +566,7 @@ fn stack_specific_payloads(class: &str, stack: &TargetStack) -> Vec<String> {
|
||||
payloads
|
||||
}
|
||||
|
||||
fn bypass_encodings(blocked: &[String], successful: &[Encoding]) -> Vec<Encoding> {
|
||||
fn bypass_encodings(_blocked: &[String], successful: &[Encoding]) -> Vec<Encoding> {
|
||||
let mut encodings = Vec::new();
|
||||
|
||||
// Prioritize encodings that already worked
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -377,6 +377,7 @@ impl CodeIndex {
|
||||
}
|
||||
|
||||
/// Callers of def `d`, by name resolution.
|
||||
#[allow(dead_code)]
|
||||
fn callers(&self, d: usize) -> Vec<usize> {
|
||||
let name = &self.defs[d].name;
|
||||
(0..self.defs.len())
|
||||
|
||||
@@ -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<usize>| {
|
||||
let union = |a: usize, b: usize, parent: &mut Vec<usize>| {
|
||||
let (ra, rb) = (find(parent, a), find(parent, b));
|
||||
if ra != rb { parent[ra] = rb; }
|
||||
};
|
||||
|
||||
@@ -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 ──
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
///
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<String, String> {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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<IntentQueue>) -> Handle {
|
||||
pub fn prepare(_cfg: &ReactiveConfig, graph: DualGraph, queue: Option<IntentQueue>) -> 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<Shared>, cfg: Arc<ReactiveConfig>) -> 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).
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -122,7 +122,7 @@ pub async fn start(config: &TunnelConfig) -> anyhow::Result<Tunnel> {
|
||||
}
|
||||
}
|
||||
}
|
||||
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`")
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ async fn list_candidates(cfg: &RunConfig, win: &Win) -> Vec<String> {
|
||||
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<String> = 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<String> {
|
||||
.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::<Vec<_>>()
|
||||
.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.
|
||||
|
||||
Reference in new issue
Block a user