Implements honeypot detection for Nuclei to address the issue where certain Shodan-exposed hosts deliberately serve responses matching a large number of vulnerability templates, producing massive amounts of false positive results. When a host matches an unusually high number of unique template signatures, this PR flags it as a likely honeypot, warns the user, and optionally suppresses results from that host.
/claim #6403
pkg/honeypot/detector.go - New Detector type that tracks unique template IDs matched per normalized host. When the match count crosses a configurable threshold, the host is flagged and a warning is logged. Thread-safe via sync.Mutex. Handles all host/URL forms via normalizeHost (strips scheme, path, query, fragment, userinfo, IPv6 brackets).
pkg/honeypot/detector_test.go - 13 unit tests covering: disabled-by-default, nil-safety, threshold triggering, suppress mode, warn-only mode, duplicate template deduplication, multi-host isolation, empty inputs, host normalization (including IPv6 bracket notation), flagged-host listing, summary output, URL normalization, and concurrent access.
pkg/output/output.go - Integration into StandardWriter.Write(): records each match with the detector, sets HoneypotDetected: true on the ResultEvent, and optionally returns early to suppress output. Adds HoneypotDetected bool field to ResultEvent (json:"honeypot_detected,omitempty"). Summary printed in Close().
pkg/types/types.go - Two new options fields: HoneypotThreshold int and HoneypotSuppressResults bool. Both included in Options.Copy().
cmd/nuclei/main.go - Two new CLI flags in the optimization group:
-honeypot-threshold / -hpt (int, default 0 = disabled)-honeypot-suppress / -hpq (bool, default false = warn only)Since this feature requires scanning actual honeypot hosts, here is the expected behavior based on the implementation and tests:
Warn-only mode (default when detection enabled):
nuclei -target 120.26.237.211 -hpt 10
# When a host matches 10+ unique templates:
[WRN] [honeypot] 120.26.237.211 matched 10 unique templates (threshold: 10) - likely honeypot
# Results still written but tagged in JSON:
{"template-id":"cve-2024-50379","host":"120.26.237.211","honeypot_detected":true,...}
Suppress mode:
nuclei -target 120.26.237.211 -hpt 10 -hpq
# Warning appears, subsequent results silently dropped. Summary at close:
[WRN]
[honeypot] 1 host(s) flagged as potential honeypot(s):
- 120.26.237.211 (10 unique template matches)
-hpt 0): opt-in, no behavior change for existing users[::1], userinfo strippingStandardWriter.Write() is the natural chokepoint, no middleware wrapper neededThis PR was developed with AI assistance (Claude/Anthropic). All changes reviewed against codebase conventions.
New Features
Tests
St34lthcole
@St34lthcole
ProjectDiscovery
@projectdiscovery