mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-12-05 02:24:17 +01:00
test(skills): drive the catalogue through several rounds, not one call
Every test written for the exploration work so far checks a single call to
route. That proves a round can be selected; it does not prove the loop
advances, which is the thing the loop exists for and the thing that was
broken three separate ways this week.
Add a walk that drives the catalogue on disk the way exploration_loop does:
start at round 1, route, record what ran, feed findings back, go again under
the same budget and gates. On a typical web recon it reaches three rounds —
round 1 no capabilities yet, recon-driven: sqli_error, idor, jwt_manipulation
round 2 the SQLi minted admin_access, credential, internal_host, so
sqli_union and sqli_blind arrive by declared chain while
cloud_iam_privesc and container_escape arrive by capability alone
round 3 privilege_escalation chains to exposed_admin_panel and
account_takeover_chain; ssrf and auth_bypass by capability
Three tests: that it runs more than one round and no round repeats the one
before it, that rounds finding nothing wind the loop down rather than paying
for skills on stale recon, and that max_rounds holds under a productive run.
The findings are synthetic, so this proves the machinery advances and stops
where told. It does not show the selections pay off against a real target —
that still needs an engagement with API keys and something to point at.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8aacc08447
commit
bc0ee6ca27
1 file changed
+127
@@ -1819,3 +1819,130 @@ mod overmint_tests {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod loop_progression_tests {
|
||||
use super::*;
|
||||
|
||||
fn repo_root() -> std::path::PathBuf {
|
||||
std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||
.ancestors().nth(3).unwrap().to_path_buf()
|
||||
}
|
||||
|
||||
fn finding(agent: &str, title: &str, impact: &str, evidence: &str) -> crate::types::Finding {
|
||||
let mut f = crate::types::Finding::default();
|
||||
f.agent = agent.into();
|
||||
f.id = format!("{agent}-f");
|
||||
f.severity = "High".into();
|
||||
f.title = title.into();
|
||||
f.impact = impact.into();
|
||||
f.evidence = evidence.into();
|
||||
f
|
||||
}
|
||||
|
||||
/// Drive the real catalogue through the loop the way `exploration_loop`
|
||||
/// does: start at round 1, route, record what ran, feed back findings, go
|
||||
/// again under the same budget and gates.
|
||||
///
|
||||
/// Every test so far has checked a single call to `route`. This checks the
|
||||
/// thing the loop is for — that it keeps going, picks something different
|
||||
/// each round, and stops where it is told. The findings are synthetic, so
|
||||
/// this proves the machinery advances, not that the selections pay off.
|
||||
fn walk(mode: &str, recon: &str, produce: impl Fn(u32, &[ScoredSkill]) -> Vec<crate::types::Finding>)
|
||||
-> Vec<Vec<String>>
|
||||
{
|
||||
let catalog = load_catalog(&repo_root());
|
||||
let budget = ExplorationBudget {
|
||||
max_rounds: 3, max_skills_per_round: 5, max_total_skills: 20,
|
||||
};
|
||||
|
||||
let mut skills_ran: HashSet<String> = HashSet::new();
|
||||
let mut findings: Vec<crate::types::Finding> = Vec::new();
|
||||
let mut explored = 0usize;
|
||||
let mut rounds: Vec<Vec<String>> = Vec::new();
|
||||
let mut round = 1u32;
|
||||
|
||||
loop {
|
||||
let caps = capabilities_from(&findings);
|
||||
let picked = next_round(
|
||||
&catalog, &findings, &skills_ran, explored, &caps, mode, recon, round, &budget,
|
||||
);
|
||||
if picked.is_empty() {
|
||||
break;
|
||||
}
|
||||
rounds.push(picked.iter().map(|s| s.skill.name.clone()).collect());
|
||||
|
||||
findings.extend(produce(round, &picked));
|
||||
for s in &picked {
|
||||
skills_ran.insert(s.skill.name.clone());
|
||||
explored += 1;
|
||||
}
|
||||
round += 1;
|
||||
}
|
||||
rounds
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_loop_runs_several_rounds_and_does_not_repeat_itself() {
|
||||
let rounds = walk(
|
||||
"web",
|
||||
"nginx php mysql wordpress /api/users?id=1 jwt bearer eyJ upload .map",
|
||||
|round, picked| {
|
||||
// Each round yields one finding from its highest-scoring skill,
|
||||
// phrased as an achievement so it mints capabilities.
|
||||
vec![finding(
|
||||
&picked[0].skill.name,
|
||||
&format!("Round {round}: exploitation confirmed"),
|
||||
"Recovered credentials for an application account",
|
||||
"dumped admin:hunter2 from the users table; backend at 10.0.4.12",
|
||||
)]
|
||||
},
|
||||
);
|
||||
|
||||
assert!(
|
||||
rounds.len() >= 2,
|
||||
"the loop stopped after {} round(s): {rounds:?}",
|
||||
rounds.len(),
|
||||
);
|
||||
|
||||
// A round that reruns the previous round's picks is not progress.
|
||||
for w in rounds.windows(2) {
|
||||
let (a, b) = (&w[0], &w[1]);
|
||||
assert!(
|
||||
b.iter().any(|s| !a.contains(s)),
|
||||
"a round repeated the one before it: {a:?} then {b:?}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A round that finds nothing mints no capabilities, so the loop should
|
||||
/// wind down rather than keep paying for skills on the same stale recon.
|
||||
#[test]
|
||||
fn rounds_that_find_nothing_do_not_keep_the_loop_alive_forever() {
|
||||
let rounds = walk("web", "nginx php mysql /login", |_round, _picked| Vec::new());
|
||||
assert!(
|
||||
rounds.len() <= 3,
|
||||
"ran {} rounds on findings that never appeared: {rounds:?}",
|
||||
rounds.len(),
|
||||
);
|
||||
}
|
||||
|
||||
/// max_rounds is the ceiling whatever the findings do.
|
||||
#[test]
|
||||
fn the_round_ceiling_holds_under_a_productive_run() {
|
||||
let rounds = walk(
|
||||
"host",
|
||||
"445 smb 389 ldap kerberos 88 domain controller windows",
|
||||
|round, picked| {
|
||||
vec![finding(
|
||||
&picked[0].skill.name,
|
||||
&format!("Round {round}: domain foothold"),
|
||||
"Obtained administrative access",
|
||||
"recovered DOMAIN\\svc_sql:Summer2024; dumped NTDS.dit; host 10.10.1.7",
|
||||
)]
|
||||
},
|
||||
);
|
||||
assert!(rounds.len() <= 3, "exceeded max_rounds: {} rounds", rounds.len());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user