mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +00:00
Don't print output for hosts that don't have any open ports when --open
is used. See discussion at http://seclists.org/nmap-dev/2010/q1/837. In this patch, all output formats are treated the same. So if a host isn't shown in normal output, it's not shown in XML output either.
This commit is contained in:
parent
002a4647c8
commit
7d0fbfb4c2
1 changed files with 15 additions and 13 deletions
28
nmap.cc
28
nmap.cc
|
|
@ -1766,7 +1766,7 @@ int nmap_main(int argc, char *argv[]) {
|
|||
/* I used to check that !currenths->weird_responses, but in some
|
||||
rare cases, such IPs CAN be port successfully scanned and even connected to */
|
||||
if (!(currenths->flags & HOST_UP)) {
|
||||
if (o.verbose) {
|
||||
if (o.verbose && (!o.openOnly() || currenths->ports.hasOpenPorts())) {
|
||||
log_write(LOG_XML, "<host>");
|
||||
write_host_header(currenths);
|
||||
log_write(LOG_XML, "</host>\n");
|
||||
|
|
@ -1914,16 +1914,21 @@ int nmap_main(int argc, char *argv[]) {
|
|||
for(targetno = 0; targetno < Targets.size(); targetno++) {
|
||||
currenths = Targets[targetno];
|
||||
/* Now I can do the output and such for each host */
|
||||
log_write(LOG_XML, "<host starttime=\"%lu\" endtime=\"%lu\">",
|
||||
(unsigned long) currenths->StartTime(),
|
||||
(unsigned long) currenths->EndTime());
|
||||
write_host_header(currenths);
|
||||
if (currenths->timedOut(NULL)) {
|
||||
write_host_header(currenths);
|
||||
log_write(LOG_PLAIN,"Skipping host %s due to host timeout\n",
|
||||
currenths->NameIP(hostname, sizeof(hostname)));
|
||||
log_write(LOG_MACHINE,"Host: %s (%s)\tStatus: Timeout",
|
||||
currenths->targetipstr(), currenths->HostName());
|
||||
} else {
|
||||
/* --open means don't show any hosts without open ports. */
|
||||
if (o.openOnly() && !currenths->ports.hasOpenPorts())
|
||||
continue;
|
||||
|
||||
log_write(LOG_XML, "<host starttime=\"%lu\" endtime=\"%lu\">",
|
||||
(unsigned long) currenths->StartTime(),
|
||||
(unsigned long) currenths->EndTime());
|
||||
write_host_header(currenths);
|
||||
printportoutput(currenths, ¤ths->ports);
|
||||
printmacinfo(currenths);
|
||||
printosscanoutput(currenths);
|
||||
|
|
@ -1931,15 +1936,12 @@ int nmap_main(int argc, char *argv[]) {
|
|||
#ifndef NOLUA
|
||||
printhostscriptresults(currenths);
|
||||
#endif
|
||||
if (o.traceroute)
|
||||
printtraceroute(currenths);
|
||||
printtimes(currenths);
|
||||
log_write(LOG_PLAIN|LOG_MACHINE,"\n");
|
||||
log_write(LOG_XML, "</host>\n");
|
||||
}
|
||||
|
||||
if (o.traceroute)
|
||||
printtraceroute(currenths);
|
||||
|
||||
printtimes(currenths);
|
||||
|
||||
log_write(LOG_PLAIN|LOG_MACHINE,"\n");
|
||||
log_write(LOG_XML, "</host>\n");
|
||||
}
|
||||
log_flush_all();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue