Skip to content

M4 — multi-host group scan engine (sys::group), wired for -sS - #54

Merged
kj299 merged 1 commit into
masterfrom
claude/m4-group-scan
Jul 25, 2026
Merged

kj299 merged 1 commit into
masterfrom
claude/m4-group-scan

Conversation

@kj299

@kj299 kj299 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Backlog #2, first sub-slice: the multi-host group scan engine — scan a whole host group concurrently through one shared capture instead of one host at a time. Ports nmap's ultra_scan host-group model.

Wired for -sS here to prove the design end-to-end. Migrating -sU + the flag scans onto it (retiring their per-target loops, DRYing the matchers) is the next sub-slice.

What lands

sys::group (0 unsafe) — a generic group engine:

  • RawScanKind trait factors the scan-type-specific bits (build_probe, match_reply, no-response default, BPF filter, protocol), so SYN/UDP/flag will share one loop instead of near-identical per-host copies — this also starts paying down the "DRY the matchers" follow-up.
  • group_scan drives a per-host HostScheduler + a GroupScheduler bounding total probes in flight; one AsyncCapture feeds all hosts, and each reply is demultiplexed to its host by source IP (SynReply now carries src_ip). Every host shares one encoded source-port range because the source address disambiguates them.
  • group_scan_targets buckets targets by egress route and runs one shared-capture group per route.
  • SynKind is the first RawScanKind impl; syn_scan_targets now delegates to it.

core: SynReply gains src_ip (read from the reply's IPv4 source); match_syn_response fills it. Miri-clean.

Verified as root (--features pcap)

  • group_e2e: a two-host loopback scan (127.0.0.1 + 127.0.0.2, each with its own open port) demultiplexes correctly.
  • CLI:
$ nmap-rs -sS -Pn -p P1,P2 127.0.0.1 127.0.0.2
Nmap scan report for 127.0.0.1
  P1/tcp open  ;  Not shown: 1 closed tcp ports (reset)
Nmap scan report for 127.0.0.2
  P2/tcp open  ;  Not shown: 1 closed tcp ports (reset)

Each host's own port open, the other's closed — concurrent, one capture, routed by src IP.

Gates

clippy (default + all-features) + fmt on pinned 1.97.0 · miri clean · unsafe-audit 11/11 (no new unsafe) · full suite green · divergences ledgered (group-scan-shared-capture-demux-by-src, group-scan-per-route-bucketing) · progress.json 34/43 DONE.

Remaining sub-slices of backlog #2

  1. Migrate -sU + flag scans onto this engine (this PR does SYN).
  2. UDP protocol payloads (payload.cc).
  3. SYN/flag ICMP back-fill.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w


Generated by Claude Code

Backlog #2, first sub-slice: scan a whole host group concurrently through ONE
shared capture instead of one host at a time. Ports nmap's ultra_scan host-group
model.

sys::group (0 unsafe): a generic group engine —
- RawScanKind trait factors the scan-type-specific bits (build_probe, match_reply,
  no-response default, BPF filter, protocol) so SYN/UDP/flag share one loop instead
  of near-identical per-host copies (also starts paying down the DRY-the-matchers
  follow-up).
- group_scan drives a per-host HostScheduler + a GroupScheduler bounding total probes
  in flight; one AsyncCapture feeds all hosts, and each reply is demultiplexed to its
  host by SOURCE IP (SynReply now carries src_ip). Every host shares one encoded
  source-port range because the source address disambiguates them.
- group_scan_targets buckets targets by egress route and runs one shared-capture
  group per route.
- SynKind is the first RawScanKind impl; syn_scan_targets now delegates to it.

core: SynReply gains src_ip (read from the reply's IPv4 source); match_syn_response
fills it. Miri-clean.

Verified as root: a two-host loopback group scan demultiplexes correctly (group_e2e),
and the CLI `nmap-rs -sS -Pn -p P1,P2 127.0.0.1 127.0.0.2` reports each host's own
port open and the other's closed — concurrent, one capture, routed by src IP.

Gates: clippy (default + all-features) + fmt on pinned 1.97.0; miri clean;
unsafe-audit 11/11 (no new unsafe); full suite green. Divergences ledgered
(group-scan-shared-capture-demux-by-src, group-scan-per-route-bucketing).
progress.json 34/43 DONE.

Next sub-slices of #2: migrate -sU + flag scans onto this engine (retiring their
per-target loops, DRYing the matchers); then UDP payloads; then SYN/flag ICMP back-fill.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
@kj299
kj299 marked this pull request as ready for review July 25, 2026 01:51
@kj299
kj299 merged commit cf9c32e into master Jul 25, 2026
12 checks passed
kj299 pushed a commit that referenced this pull request Nov 14, 2026
…habit

Every step of nmap's IPv6-scans milestone ran its sabotage from a script
written for the occasion. None bounded a run: one mutation made its test
loop forever, was killed by hand after 96 s, and was then printed as
CAUGHT with no failing test (LESSONS #54). Two ledger entries named, as
their pins, tests that passed with the fix reverted (LESSONS #55).

sabotage.py takes a JSON list of mutations. It requires the replaced span
to occur once, restores from the saved bytes and bumps the mtime, kills a
run at its timeout and calls that INCONCLUSIVE, counts only a failing
test named in the output, and with `expect` only the test the ledger
names (WRONG-TEST otherwise). It refuses to start over a backup a killed
run left behind. Self-tested; run against nmap-rs in a separate worktree.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JfEzHqD7a7TKDuUs5GwZ2w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants