Skip to content

feat: hostname resolution via reverse DNS and passive OS inference from banners - #42

Merged
reloadfast merged 2 commits into
mainfrom
feat/hostname-and-os-hints-37
Feb 28, 2026
Merged

reloadfast merged 2 commits into
mainfrom
feat/hostname-and-os-hints-37

Conversation

@reloadfast

Copy link
Copy Markdown
Owner

Closes #37

Changes

backend/app/scanner/dns_lookup.py (new)

Reverse DNS fallback for hosts nmap couldn't name. Uses socket.gethostbyaddr() with a per-IP SIGALRM timeout (1 s) to avoid stalling the scan on unresponsive resolvers.

backend/app/scanner/os_inference.py (new)

Passive OS inference from service/version banners — no elevated privileges required. Recognises:

  • SSH banners: Ubuntu, Debian, Raspbian, CentOS, FreeBSD, OpenBSD, Windows, generic Linux
  • HTTP Server headers: OpenWrt, DD-WRT, Synology DSM, QNAP, TrueNAS, Unraid, MikroTik, Cisco
  • Service names: microsoft-ds, msrpc, ms-wbt-server → Windows

backend/app/scanner/__init__.py

Two new steps wired into orchestrate_scan() after nmap completes:

  1. resolve_hostnames() — fills missing hostnames
  2. enrich_os_guesses() — fills missing os_guess

backend/tests/test_enrichment.py (new — 21 unit tests)

Full coverage of both modules: banner matching, priority ordering, graceful failure, no-overwrite guard.

reloadfast and others added 2 commits February 28, 2026 17:43
…om banners

Closes #37

Two enrichment steps added after nmap in orchestrate_scan():

## Hostname (dns_lookup.py)
- resolve_hostnames() performs socket.gethostbyaddr() for any host
  nmap did not name (no PTR in XML)
- Per-IP SIGALRM timeout (1s) prevents a slow resolver stalling scans
- Fails gracefully — missing PTR leaves hostname as empty string

## OS hints (os_inference.py)
- enrich_os_guesses() infers os_guess from service/version banners
  for any host where os_guess is still empty after nmap
- SSH banner patterns: Ubuntu, Debian, Raspbian, FreeBSD, Windows, etc.
- HTTP Server header patterns: OpenWrt, DD-WRT, Synology DSM, QNAP, etc.
- Service-name fallbacks: microsoft-ds/msrpc/RDP → Windows

## Tests (test_enrichment.py) — 21 unit tests
- OS inference: 12 tests covering SSH banners, HTTP headers,
  service-name hints, priority ordering, no-match case
- Hostname: 6 tests covering PTR resolution, existing-name guard,
  OSError/TimeoutError graceful handling, selective querying

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@reloadfast
reloadfast merged commit 767a932 into main Feb 28, 2026
5 checks passed
@reloadfast
reloadfast deleted the feat/hostname-and-os-hints-37 branch February 28, 2026 17:35
@reloadfast
reloadfast restored the feat/hostname-and-os-hints-37 branch March 26, 2026 19:35
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.

feat: hostname resolution via reverse DNS fallback and OS hints from service banners

1 participant