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

Print per-second summary statistics detailing a scan, similar to ZMap #473

Merged
merged 14 commits into from
Nov 24, 2024

Conversation

phillip-stephens
Copy link
Contributor

@phillip-stephens phillip-stephens commented Nov 11, 2024

Closes #472

Adds a per-second summary with the following:

  • h/min/sec printout
  • # of domains scanned
  • domains/second
  • success rate of domain resolution
  • Occurrence of the different status codes, sorted greatest to least

A final summary is printed on scan completion

This is printed to stderr by default.

Two new CLI flags are available to modify this behavior:

  -q, --quiet                  do not print status updates
  -u, --status-updates-file=   file to write scan progress to, defaults to stderr (default: -)

Demo

$ cat status
00h:00m:01s; 67 domains scanned; 66.99 domains/sec.; 100.0% success rate; NOERROR: 67
00h:00m:02s; 91 domains scanned; 45.49 domains/sec.; 100.0% success rate; NOERROR: 91
00h:00m:03s; 96 domains scanned; 32.00 domains/sec.; 100.0% success rate; NOERROR: 96
00h:00m:04s; 97 domains scanned; 24.24 domains/sec.; 100.0% success rate; NOERROR: 97
00h:00m:05s; 98 domains scanned; 19.60 domains/sec.; 100.0% success rate; NOERROR: 98
00h:00m:06s; 98 domains scanned; 16.33 domains/sec.; 100.0% success rate; NOERROR: 98
00h:00m:07s; 98 domains scanned; 14.00 domains/sec.; 100.0% success rate; NOERROR: 98
00h:00m:08s; 98 domains scanned; 12.25 domains/sec.; 100.0% success rate; NOERROR: 98
00h:00m:09s; 99 domains scanned; 11.00 domains/sec.; 99.0% success rate; NOERROR: 98, ITERATIVE_TIMEOUT: 1
00h:00m:10s; 99 domains scanned; 9.90 domains/sec.; 99.0% success rate; NOERROR: 98, ITERATIVE_TIMEOUT: 1
00h:00m:11s; 99 domains scanned; 9.00 domains/sec.; 99.0% success rate; NOERROR: 98, ITERATIVE_TIMEOUT: 1
00h:00m:12s; 99 domains scanned; 8.25 domains/sec.; 99.0% success rate; NOERROR: 98, ITERATIVE_TIMEOUT: 1
00h:00m:13s; 100 domains scanned; 7.69 domains/sec.; 99.0% success rate; NOERROR: 99, ITERATIVE_TIMEOUT: 1
00h:00m:13s; Scan Complete, no more input. 100 domains scanned; 7.18 domains/sec.; 99.0% success rate; NOERROR: 99, ITERATIVE_TIMEOUT: 1

Copy link
Member

@zakird zakird left a comment

Choose a reason for hiding this comment

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

I don't think it's OK to make this not disable'able or not redirectable. I also don't think that it's OK to put these on stdout since it precludes piping ZDNS into another program. These should be able to be turned on and off and should be printed to stderr or a file.

The most useful thing in ZMap to make sure a scan looks good is hitrate, which you can't actually quite get here. Can we get the same thing here. When calculating hitrate I would include both NOERROR and NXDOMAIN because both are a successful response from the DNS server.

@phillip-stephens
Copy link
Contributor Author

Yep all seems reasonable! Will make those changes

case <-ticker.C:
// print per-second summary
timeSinceStart := time.Since(stats.scanStartTime)
s := fmt.Sprintf("%02dh:%02dm:%02ds; %d domains scanned; %.02f domains/sec.; %.01f%% success rate; %s\n",
Copy link
Member

Choose a reason for hiding this comment

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

I think that should be names not domains. I also think you could get rid of the . after sec.

}
}
timeSinceStart := time.Since(stats.scanStartTime)
s := fmt.Sprintf("%02dh:%02dm:%02ds; Scan Complete, no more input. %d domains scanned; %.02f domains/sec.; %.01f%% success rate; %s\n",
Copy link
Member

@zakird zakird Nov 19, 2024

Choose a reason for hiding this comment

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

I think you can drop , no more input. Would switch domain to name here.

@zakird zakird merged commit 9a57898 into main Nov 24, 2024
3 checks passed
@zakird zakird deleted the phillip/per-second-updates branch November 24, 2024 22:36
@zakird zakird added this to the Version 2.0 milestone Nov 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Periodically log statistics
2 participants