fix: --evasion uses a browser User-Agent (harness + tool recon)

- default UA is the browser UA under evasion; explicit NEUROSPLOIT_UA still wins
- browser Accept/Accept-Language; scan header stays dropped
- recon curl/katana/nuclei/ffuf carry the same UA
This commit is contained in:
CyberSecurityUP committed 2026-12-03 11:30:22 -03:00
1 parent 821742ce7f
commit 207be99ebe
1 file changed
+27 -15
+27 -15
View File
@@ -654,6 +654,12 @@ fn tool_doctrine(mcp_on: bool) -> String {
/// `X-NeuroSploit-Scan` header (see `default_scan_headers`), which every request
/// carries, so the scan stays identifiable to defenders regardless of the UA.
pub fn default_user_agent() -> String {
// Attribution must not be a free fingerprint. With --evasion the scanner UA
// is itself an IOC (the Worker blocked on `NeuroSploit/4.6.0` before the
// first request), so use the same realistic browser UA the agents use.
if crate::evasion::suppress_attribution() {
return realistic_user_agent().to_string();
}
format!("NeuroSploit/{}", env!("CARGO_PKG_VERSION"))
}
@@ -661,12 +667,15 @@ pub fn default_user_agent() -> String {
/// the HEADER (not just the UA) and survives a browser-UA switch:
/// `Accept: */*` and `X-NeuroSploit-Scan: <ver>`.
pub fn default_scan_headers() -> reqwest::header::HeaderMap {
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT};
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT, ACCEPT_LANGUAGE};
let mut h = HeaderMap::new();
h.insert(ACCEPT, HeaderValue::from_static("*/*"));
// OPSEC/evasion: drop the scan-identifying header when the operator opted in
// (`--evasion` / NEUROSPLOIT_EVASION=1). Default keeps it for attribution.
if !crate::evasion::suppress_attribution() {
// OPSEC/evasion: drop the scan-identifying header and look like a browser
// (`--evasion` / NEUROSPLOIT_EVASION=1). Default keeps attribution.
if crate::evasion::suppress_attribution() {
h.insert(ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"));
h.insert(ACCEPT_LANGUAGE, HeaderValue::from_static("en-US,en;q=0.9"));
} else {
h.insert(ACCEPT, HeaderValue::from_static("*/*"));
if let Ok(v) = HeaderValue::from_str(env!("CARGO_PKG_VERSION")) {
h.insert("X-NeuroSploit-Scan", v);
}
@@ -7369,12 +7378,15 @@ fn fair_take(lists: &[Vec<String>], total: usize) -> Vec<String> {
/// Run the recon commands for ONE host (sequential within the host).
async fn recon_one_host(cfg: &RunConfig, host: &str, crawl_depth: usize, url_cap: usize, intensity: usize, light: bool) -> HostRecon {
let mut r = HostRecon { host: host.to_string(), ..Default::default() };
// Under --evasion the UA is a browser UA; otherwise attribution is explicit.
let ua = default_user_agent();
let ua_arg = format!("-A '{ua}'");
// 1. Deep crawl + historical URL harvest.
let harvest = format!(
"( echo {host} | gau --threads 20 2>/dev/null; \
echo {host} | waybackurls 2>/dev/null; \
katana -u https://{host} -d {crawl_depth} -jc -kf all -ef css,png,jpg,gif,svg,woff,woff2,ttf,ico -silent 2>/dev/null \
katana -u https://{host} -d {crawl_depth} -jc -H 'User-Agent: {ua}' -kf all -ef css,png,jpg,gif,svg,woff,woff2,ttf,ico -silent 2>/dev/null \
) | sort -u | head -{url_cap}");
if !light {
if let Some(out) = recon_tool(cfg, "gau", &harvest).await {
@@ -7392,7 +7404,7 @@ async fn recon_one_host(cfg: &RunConfig, host: &str, crawl_depth: usize, url_cap
/graphql /.env /server-info /server-status /actuator /actuator/health \
/wp-login.php /wp-admin/ /administrator/ /admin/ /login /register /signup \
/feed /feed/atom /rss; do \
code=$(curl -s -o /dev/null -w '%{{http_code}}' -m 5 \"https://{host}$p\" 2>/dev/null); \
code=$(curl -s -o /dev/null -w '%{{http_code}}' -m 5 {ua_arg} \"https://{host}$p\" 2>/dev/null); \
if [ \"$code\" != \"000\" ] && [ \"$code\" != \"404\" ]; then \
echo \"$code $p\"; \
fi; \
@@ -7408,7 +7420,7 @@ async fn recon_one_host(cfg: &RunConfig, host: &str, crawl_depth: usize, url_cap
// 3. Sitemap URL extraction (follow sitemap.xml for all listed URLs).
let sitemap = format!(
"curl -s -m 10 'https://{host}/sitemap.xml' 2>/dev/null | \
"curl -s -m 10 {ua_arg} 'https://{host}/sitemap.xml' 2>/dev/null | \
perl -ne 'print \"$1\\n\" if m#<loc>([^<]+)#' | head -200");
if !light {
if let Some(out) = recon_tool(cfg, "curl", &sitemap).await {
@@ -7418,9 +7430,9 @@ async fn recon_one_host(cfg: &RunConfig, host: &str, crawl_depth: usize, url_cap
// 4. JS endpoint extraction (linkfinder-style from inline and external JS).
let js_extract = format!(
"katana -u https://{host} -d 1 -jc -silent 2>/dev/null | grep -iE '\\.js(\\?|$)' | head -30 | \
"katana -u https://{host} -d 1 -jc -H 'User-Agent: {ua}' -silent 2>/dev/null | grep -iE '\\.js(\\?|$)' | head -30 | \
while read js; do \
curl -s -m 8 \"$js\" 2>/dev/null | \
curl -s -m 8 {ua_arg} \"$js\" 2>/dev/null | \
perl -ne 'print \"$1\\n\" while m#(?<=[\"\\x27])(/[a-zA-Z0-9_/\\-]+(?:\\?[a-zA-Z0-9_=&]+)?)(?=[\"\\x27])#g' | \
sed \"s|^|https://{host}|\" ; \
done | sort -u | head -100");
@@ -7432,9 +7444,9 @@ async fn recon_one_host(cfg: &RunConfig, host: &str, crawl_depth: usize, url_cap
// 5. Form extraction (find all <form> actions + input names).
let form_extract = format!(
"curl -s -m 10 'https://{host}' 2>/dev/null | \
"curl -s -m 10 {ua_arg} 'https://{host}' 2>/dev/null | \
perl -ne 'print \"$1\\n\" while m#<form[^>]*action=[\"\\x27]?([^\"\\x27\\s>]+)#gi' | head -20; \
curl -s -m 10 'https://{host}' 2>/dev/null | \
curl -s -m 10 {ua_arg} 'https://{host}' 2>/dev/null | \
perl -ne 'print \"$1\\n\" while m#<input[^>]*name=[\"\\x27]([^\"\\x27]+)#gi' | head -30");
if let Some(out) = recon_tool(cfg, "curl", &form_extract).await {
for l in out.lines() { let t = l.trim(); if !t.is_empty() { r.forms.push(format!("[{host}] {t}")); } }
@@ -7444,9 +7456,9 @@ async fn recon_one_host(cfg: &RunConfig, host: &str, crawl_depth: usize, url_cap
if !light && intensity >= 3 {
let fuzz = format!(
"ffuf -u 'https://{host}/FUZZ' -w /usr/share/wordlists/dirb/common.txt \
-mc 200,201,301,302,307,401,403,405 -t 20 -s 2>/dev/null | head -100 || \
-H 'User-Agent: {ua}' -mc 200,201,301,302,307,401,403,405 -t 20 -s 2>/dev/null | head -100 || \
feroxbuster -u 'https://{host}' -w /usr/share/wordlists/dirb/common.txt \
--no-recursion -t 20 -s 200,301,302,401,403 -q 2>/dev/null | head -100");
-H 'User-Agent: {ua}' --no-recursion -t 20 -s 200,301,302,401,403 -q 2>/dev/null | head -100");
if let Some(out) = recon_tool(cfg, "ffuf", &fuzz).await {
for l in out.lines() {
let u = l.trim();
@@ -7467,7 +7479,7 @@ async fn recon_one_host(cfg: &RunConfig, host: &str, crawl_depth: usize, url_cap
}
// 8. Targeted nuclei quick-wins (exposures/misconfig/takeover).
let nuc = format!("nuclei -u https://{host} -t exposures/,misconfiguration/,takeovers/ -severity critical,high,medium -silent -nc 2>/dev/null | head -40");
let nuc = format!("nuclei -u https://{host} -H 'User-Agent: {ua}' -t exposures/,misconfiguration/,takeovers/ -severity critical,high,medium -silent -nc 2>/dev/null | head -40");
if let Some(out) = recon_tool(cfg, "nuclei", &nuc).await {
for l in out.lines() { let t = l.trim(); if !t.is_empty() { r.nuclei.push(t.to_string()); } }
}