Fixes #6403
/claim #6403
Many hosts on Shodan intentionally respond to all nuclei templates to fool scanners, creating noisy false positives. This PR adds a configurable honeypot detection system that tracks unique template matches per host and flags hosts exceeding a threshold.
pkg/honeypot/Detector: Concurrent-safe honeypot detector using sync.Map for lock-free host trackinghost:port, IPv6 brackets, and case differencespkg/output/output.goStandardWriter.Write() records each match and suppresses output from flagged honeypot hostsClose()HoneypotDetector() method for external access-honeypot-threshold / -hpt (int, default 0 = disabled)-max-host-errorpkg/types/types.goHoneypotThreshold field to Options struct and its Copy() method# Flag hosts with 10+ unique template matches as honeypots
nuclei -t templates/ -l targets.txt -hpt 10
# Use verbose mode to see details of flagged hosts
nuclei -t templates/ -l targets.txt -hpt 10 -v
sync.Map + per-entry mutex for concurrent safety without a global lock bottleneck14 comprehensive tests covering:
$ go test ./pkg/honeypot/... -v -count=1
=== RUN TestDetectorBasic
--- PASS: TestDetectorBasic (0.00s)
=== RUN TestDetectorDuplicateTemplates
--- PASS: TestDetectorDuplicateTemplates (0.00s)
=== RUN TestDetectorMultipleHosts
--- PASS: TestDetectorMultipleHosts (0.00s)
=== RUN TestDetectorDisabled
--- PASS: TestDetectorDisabled (0.00s)
=== RUN TestDetectorNegativeThreshold
--- PASS: TestDetectorNegativeThreshold (0.00s)
=== RUN TestDetectorRecordAfterFlagged
--- PASS: TestDetectorRecordAfterFlagged (0.00s)
=== RUN TestDetectorFlaggedHosts
--- PASS: TestDetectorFlaggedHosts (0.00s)
=== RUN TestNormalizeHost
--- PASS: TestNormalizeHost (0.00s)
=== RUN TestDetectorHostNormalization
--- PASS: TestDetectorHostNormalization (0.00s)
=== RUN TestDetectorEmptyHost
--- PASS: TestDetectorEmptyHost (0.00s)
=== RUN TestDetectorConcurrentAccess
--- PASS: TestDetectorConcurrentAccess (0.00s)
=== RUN TestDetectorConcurrentMultipleHosts
--- PASS: TestDetectorConcurrentMultipleHosts (0.00s)
=== RUN TestDetectorUnknownHost
--- PASS: TestDetectorUnknownHost (0.00s)
PASS
ok github.com/projectdiscovery/nuclei/v3/pkg/honeypot 0.006s
$ go build -o ./bin/nuclei ./cmd/nuclei/
$ ./bin/nuclei -h | grep honeypot
-hpt, -honeypot-threshold int threshold of unique template matches before flagging a host as honeypot (0 = disabled)
Nenad Ilic
@nenadilic84
ProjectDiscovery
@projectdiscovery