zmap / zmap

ZMap is a fast single packet network scanner designed for Internet-wide network surveys.
https://zmap.io
Apache License 2.0
5.43k stars 907 forks source link

the `--max-targets` flag with a percent wasn't respecting multi-ports #886

Closed phillip-stephens closed 1 month ago

phillip-stephens commented 2 months ago

Before Fix - The --max-targets flag wasn't behaving as expected for a percent of the address space with multiple ports.

This manifested both in debug messages and in the ETA remaining un-changed when you use more than 1 port with this flag.

Single Port, 1% of address space

sudo ./src/zmap -B 100M -o "/dev/null"  --verbosity=5 -n 1% -p 80
...
Jul 02 23:08:51.018 [DEBUG] iterator: max targets is 42949672
...
 0:05 2% (5m16s left); send: 691206 139 Kp/s (137 Kp/s avg); recv: 8975 2.03 Kp/s (1.78 Kp/s avg); drops: 0 p/s (0 p/s avg); hitrate: 1.30%

2 Ports, 1 % of address space

sudo ./src/zmap -B 100M -o "/dev/null"  --verbosity=5 -n 1% -p 80-81
...
Jul 02 23:09:35.911 [DEBUG] iterator: max targets is 42949672
0:05 2% (5m21s left); send: 683403 135 Kp/s (135 Kp/s avg); recv: 4851 987 p/s (960 p/s avg); drops: 0 p/s (0 p/s avg); hitrate: 0.71%

After Fix, note that max targets is correct and the ETA is as expected

~/zmap-dev on  phillip/max-targets-percent-help! ⌚ 23:10:53
$ sudo ./src/zmap -B 100M -o "/dev/null"  --verbosity=5 -n 1% -p 80-81
...
Jul 02 23:11:05.208 [DEBUG] iterator: max targets is 85899345
...
 0:05 1% (10m left); send: 689020 137 Kp/s (136 Kp/s avg); recv: 4770 926 p/s (942 p/s avg); drops: 0 p/s (0 p/s avg); hitrate: 0.69%