projectdiscovery / naabu

A fast port scanner written in go with a focus on reliability and simplicity. Designed to be used in combination with other tools for attack surface discovery in bug bounties and pentests
https://projectdiscovery.io
MIT License
4.51k stars 531 forks source link

Statistical inaccuracy #1113

Open zlgxzswjy opened 1 month ago

zlgxzswjy commented 1 month ago

Naabu version: 2.3.1

Current Behavior:

I made an ipx.x.x.x using-host and enabled the-stats -mp 63636 parameter,But when I request http://localhost:63636/metrics , the json returned prompts me that the number of "hosts": 2

Expected Behavior:

Number of hosts should be 1

Steps To Reproduce:

Example: steps to reproduce the behavior:

  1. Run 'naabu -host 47.101.211.147 -p - -stats -mp 63636'
  2. curl http://localhost:63636/metrics|jq

    % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 169 100 169 0 0 19580 0 --:--:-- --:--:-- --:--:-- 21125 { "total": 393210, "packets": 3500, "hosts": 2, "retries": 3, "errors": 0, "startedAt": "2024-06-12T15:45:55.953068423+08:00", "hosts_with_port": 0, "ports": 65535, "duration": "0:00:07" }

Anything else:

zlgxzswjy commented 1 month ago

When I add-Pn, The command becomes: naabu -host 47.101.211.147 -Pn -p - -stats -mp 63636。the statistics are correct. So is it just a statistical error, or are there really a lot of duplicate requests?

*Switch to version 2.1.6 for testing, regardless of whether there is a-Pn parameter, the statistical results are correct, and obviously much faster

dogancanbakir commented 1 month ago

Can you retry with dev branch? Thanks

go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@dev
Mzack9999 commented 1 month ago

Just guessing, but that's possible that statistics are wrongly incremented during host-discovery phase. Whereas if we have both service-discovery + port-scan probably we should consider only portscan as relevant, or split the statistics in two parts for the respective phases.

zlgxzswjy commented 1 month ago

Can you retry with dev branch? Thanks

go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@dev

I try this dev branch with the same commad,the json also returned prompts me : "hosts": 2

dogancanbakir commented 1 month ago

I couldn't repro this issue - used the dev branch for testing.

$ go run . -host 47.101.211.147 -p - -stats -mp 63636

                  __
  ___  ___  ___ _/ /  __ __
 / _ \/ _ \/ _ \/ _ \/ // /
/_//_/\_,_/\_,_/_.__/\_,_/

                projectdiscovery.io

[INF] Current naabu version 2.3.1 (latest)
[INF] Running CONNECT scan with non root privileges
Target: 47.101.211.147/32, Target Count: 1
47.101.211.147:32080
47.101.211.147:43080
$ curl -s http://localhost:63636/metrics | jq .hosts
1
zlgxzswjy commented 1 month ago

This may be a problem with my cloud service provider. I scan the same ip on my local arch linux,hosts is indeed 1, but when placed on my Aliyun ECS, hosts is still 3 or 2,And debug output the following information:

[DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:32748 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16) [DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:44512 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16) [DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:35597 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16) [DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:15332 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16) [DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:11172 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16) [DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:24343 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16) [DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:58715 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16) [DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:9790 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16) [DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:9793 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16) [DBG] Can not send packet to ffff:ffff:800:4514:28:0:4000:f706:44531 port: Invalid source IPv6 address (wrong length of 0 bytes instead of 16)

dogancanbakir commented 4 days ago

FYI: I still can't repro this but I'll leave it open for a while to see if someone else is experiencing it.