1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-06 22:49:02 +00:00

Only increment o.numhosts_scanned when we have truly finished scanning a

host, which means that it is either found down or else all
port/script/traceroute/etc. scanning is finished. In r12798 I made it be
updated as soon as DNS resolution happened, to make the status display
"X undergoing Ping Scan" accurate. However the main loop also uses this
variable to count how many addresses have been generated so it knows
when to stop scanning random addresses. If -iR was used, only the first
hostgroup out of all the random addresses would be fully scanned and
then the scan would end. This change fixes that and also makes the
output more like it was pre-r12798; for example, if you had done name
resolution on 1024 hosts with --max-hostgroup 8, and had found the 8th
up host at the 280th one pinged, the output was
Stats: 0:00:29 elapsed; 1016 hosts completed (8 up), 8 undergoing Connect Scan
and is now
Stats: 0:00:29 elapsed; 272 hosts completed (8 up), 8 undergoing Connect Scan
This commit is contained in:
david
2009-05-04 22:59:35 +00:00
parent 51e7f1f4f9
commit fac82a011b
3 changed files with 6 additions and 4 deletions

View File

@@ -1607,7 +1607,7 @@ int nmap_main(int argc, char *argv[]) {
num_host_exp_groups = 0;
/* Now grab any new expressions */
while(num_host_exp_groups < o.ping_group_sz &&
(!o.max_ips_to_scan || o.max_ips_to_scan > o.numhosts_scanned + num_host_exp_groups) &&
(!o.max_ips_to_scan || o.max_ips_to_scan > o.numhosts_scanned + Targets.size() + num_host_exp_groups) &&
(host_spec = grab_next_host_spec(inputfd, argc, fakeargv))) {
// For purposes of random scan
host_exp_group[num_host_exp_groups++] = strdup(host_spec);
@@ -1653,6 +1653,7 @@ int nmap_main(int argc, char *argv[]) {
rare cases, such IPs CAN be port successfully scanned and even connected to */
if (!(currenths->flags & HOST_UP)) {
delete currenths;
o.numhosts_scanned++;
continue;
}
@@ -1685,7 +1686,7 @@ int nmap_main(int argc, char *argv[]) {
if (Targets.size() > 0 &&
strcmp(Targets[Targets.size() - 1]->deviceName(), currenths->deviceName())) {
returnhost(hstate);
o.numhosts_scanned--; o.numhosts_up--;
o.numhosts_up--;
break;
}
o.decoys[o.decoyturn] = currenths->v4source();
@@ -1847,6 +1848,8 @@ int nmap_main(int argc, char *argv[]) {
log_write(LOG_XML, "</host>\n");
}
log_flush_all();
o.numhosts_scanned += Targets.size();
/* Free all of the Targets */
while(!Targets.empty()) {

View File

@@ -1896,7 +1896,7 @@ void printStatusMessage() {
log_write(LOG_STDOUT,
"Stats: %d:%02d:%02d elapsed; %d hosts completed (%d up), %d undergoing %s\n",
time/60/60, time/60 % 60, time % 60, o.numhosts_scanned - o.numhosts_scanning,
time/60/60, time/60 % 60, time % 60, o.numhosts_scanned,
o.numhosts_up, o.numhosts_scanning, scantype2str(o.current_scantype));
}

View File

@@ -529,7 +529,6 @@ do {
goto batchfull;
}
hs->current_batch_sz++;
o.numhosts_scanned++;
}
if (hs->current_batch_sz < hs->max_batch_sz &&