Skip to content

Improve --scan-all-computers timeout handling and configurability#21

Open
jazofra wants to merge 9 commits into
SpecterOps:mainfrom
jazofra:main
Open

Improve --scan-all-computers timeout handling and configurability#21
jazofra wants to merge 9 commits into
SpecterOps:mainfrom
jazofra:main

Conversation

@jazofra
Copy link
Copy Markdown
Contributor

@jazofra jazofra commented May 28, 2026

Summary

Fixes --scan-all-computers runs that could appear stuck near the end of enumeration and makes the blind computer sweep more configurable.

The main issue was that --scan-all-computers could leave the concurrent worker pool waiting forever if one target became stuck in a nested SQL, LDAP, DNS, or Windows SID lookup path. This PR adds bounded timeout behavior around the risky paths and adds an outer per-server worker timeout so one wedged target cannot prevent the run from completing.

This also improves scan-all behavior. SPN-discovered SQL Servers still preserve their AD-advertised port or instance. Blindly enumerated domain computers continue to default to TCP 1433, but operators can now provide additional candidate ports and tune the TCP reachability timeout.

Changes

  • Added direct LDAP dial deadlines so LDAP fallback setup cannot block before LDAP operation timeouts apply.
  • Added a bounded Windows computer SID lookup wrapper.
  • Added an outer per-server worker timeout so blocked nested calls return a failed result instead of holding the worker pool open.
  • Added --scan-all-computer-ports, defaulting to 1433, for scanning additional candidate SQL ports on domain computers.
  • Added --port-check-timeout, defaulting to 2 seconds, for TCP reachability checks.
  • Preserved existing default behavior when the new flags are not provided.
  • Added regression tests for port parsing, scan-all computer target expansion, Windows SID timeout behavior, and worker timeout behavior.
  • Updated the saved project plan and lessons for the timeout patterns found during investigation.
  • Added a count for nodes and edges

Validation

  • go test ./...
  • go build ./cmd/mssqlhound

jazofra and others added 9 commits May 11, 2026 18:52
…computers is more configurable

The main issue was that --scan-all-computers could leave the concurrent worker pool waiting forever if one target became stuck in a nested SQL, LDAP, DNS, or Windows SID lookup path. This PR adds bounded timeout behavior around the risky paths and adds an outer per-server worker timeout so one wedged target cannot prevent the run from completing.

This also clarifies and improves scan-all behavior. SPN-discovered SQL Servers still preserve their AD-advertised port or instance. Blindly enumerated domain computers continue to default to TCP 1433, but operators can now provide additional candidate ports and tune the TCP reachability timeout.

Changes
Added direct LDAP dial deadlines so LDAP fallback setup cannot block before LDAP operation timeouts apply.
Added a bounded Windows computer SID lookup wrapper.
Added an outer per-server worker timeout so blocked nested calls return a failed result instead of holding the worker pool open.
Added --scan-all-computer-ports, defaulting to 1433, for scanning additional candidate SQL ports on domain computers.
Added --port-check-timeout, defaulting to 2 seconds, for TCP reachability checks.
Preserved existing default behavior when the new flags are not provided.
Added regression tests for port parsing, scan-all computer target expansion, Windows SID timeout behavior, and worker timeout behavior.
Updated the saved project plan and lessons for the timeout patterns found during investigation.
…computers is more configurable

The main issue was that --scan-all-computers could leave the concurrent worker pool waiting forever if one target became stuck in a nested SQL, LDAP, DNS, or Windows SID lookup path. This PR adds bounded timeout behavior around the risky paths and adds an outer per-server worker timeout so one wedged target cannot prevent the run from completing.

This also clarifies and improves scan-all behavior. SPN-discovered SQL Servers still preserve their AD-advertised port or instance. Blindly enumerated domain computers continue to default to TCP 1433, but operators can now provide additional candidate ports and tune the TCP reachability timeout.

Changes
Added direct LDAP dial deadlines so LDAP fallback setup cannot block before LDAP operation timeouts apply.
Added a bounded Windows computer SID lookup wrapper.
Added an outer per-server worker timeout so blocked nested calls return a failed result instead of holding the worker pool open.
Added --scan-all-computer-ports, defaulting to 1433, for scanning additional candidate SQL ports on domain computers.
Added --port-check-timeout, defaulting to 2 seconds, for TCP reachability checks.
Preserved existing default behavior when the new flags are not provided.
Added regression tests for port parsing, scan-all computer target expansion, Windows SID timeout behavior, and worker timeout behavior.
Adds the new scan-all flags to the Target Selection table and to the
Full Domain Enumeration examples, and notes the per-server worker
timeout that prevents a wedged target from holding the pool open.
principal.Name from sys.server_principals is always DOMAIN\account for
Windows logins. The AD node creation loop was using that form directly,
producing DOMAIN\account@DOMAIN.COM instead of BloodHound's expected
account@DOMAIN.COM convention.

Strip the NETBIOS prefix before appending the UPN suffix, mirroring the
identical pattern already present in the service-account node block.
StreamingWriter now tracks counts broken down by node kind and edge kind.
After each server file is written, a second log line reports the breakdown
so operators can see exactly which types of nodes and edges were produced.

https://claude.ai/code/session_01R2EgSH37FnPxdqeVy4yTEg
Add per-type node and edge statistics tracking
The collector now accumulates per-kind counts across all output files
(server files and AD files) and logs a single "Total node and edge counts
by type" line at the end of Run(), giving a full-run view alongside the
existing per-file breakdowns.

https://claude.ai/code/session_01R2EgSH37FnPxdqeVy4yTEg
Add aggregate node/edge type summary at end of collection run
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