Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 16 commits into from
Jul 9, 2024

Conversation

phillip-stephens
Copy link
Contributor

@phillip-stephens phillip-stephens commented Jul 2, 2024

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%

@phillip-stephens phillip-stephens marked this pull request as ready for review July 2, 2024 23:16
@phillip-stephens phillip-stephens requested a review from zakird July 2, 2024 23:17
lib/util.c Outdated
// treat as percentage
v = v * ((unsigned long long int)1 << 32) / 100.;
// treat as percentage of the search space, so percent of 2^32 * num_ports
v = v * (((unsigned long long int)1 << 32) * port_count) / 100.;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would define this using something like uint64_t to be explicit about what you want here. We do that other places within the code base.

@phillip-stephens phillip-stephens merged commit a66767c into main Jul 9, 2024
12 checks passed
@phillip-stephens phillip-stephens deleted the phillip/max-targets-percent-help branch July 9, 2024 21:53
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.

2 participants