diff --git a/nmap.cc b/nmap.cc index 9c46c3d80..5194acfd9 100644 --- a/nmap.cc +++ b/nmap.cc @@ -1893,7 +1893,7 @@ int nmap_main(int argc, char *argv[]) { log_write(LOG_XML, "", (unsigned long) currenths->StartTime(), (unsigned long) currenths->EndTime()); - write_host_status(currenths, o.resolve_all); + write_host_header(currenths); if (currenths->timedOut(NULL)) { log_write(LOG_PLAIN,"Skipping host %s due to host timeout\n", currenths->NameIP(hostname, sizeof(hostname))); diff --git a/output.cc b/output.cc index 6cc23615b..6ee307457 100644 --- a/output.cc +++ b/output.cc @@ -626,9 +626,6 @@ void printportoutput(Target * currenths, PortList * plist) { log_write(LOG_PLAIN, "Scanned at %s for %lds\n", tbufs, tm_sece - tm_secs); } - log_write(LOG_PLAIN, "Interesting %s on %s:\n", - (o.ipprotscan) ? "protocols" : "ports", - currenths->NameIP(hostname, sizeof(hostname))); log_write(LOG_MACHINE, "Host: %s (%s)", currenths->targetipstr(), currenths->HostName()); @@ -1423,6 +1420,19 @@ static char *num_to_string_sigdigits(double d, int digits) { return buf; } + +/* Writes a heading for a full scan report ("Nmap scan report for..."), + including host status and DNS records. */ +void write_host_header(Target *currenths) { + log_write(LOG_PLAIN, "Nmap scan report for %s\n", currenths->NameIP()); + write_host_status(currenths, o.resolve_all); + /* Print reverse DNS if it differs. */ + if (currenths->TargetName() != NULL + && strcmp(currenths->TargetName(), currenths->HostName()) != 0) { + log_write(LOG_PLAIN, "rDNS record for %s: %s\n", + currenths->targetipstr(), currenths->HostName()); + } +} /* Writes host status info to the log streams (including STDOUT). An example is "Host: 10.11.12.13 (foo.bar.example.com)\tStatus: Up\n" to diff --git a/output.h b/output.h index 352f62c63..404b333d0 100644 --- a/output.h +++ b/output.h @@ -178,6 +178,10 @@ void output_ports_to_machine_parseable_output(struct scan_lists *ports, requested and the ports which it will scan for */ void output_xml_scaninfo_records(struct scan_lists *ports); +/* Writes a heading for a full scan report ("Nmap scan report for..."), + including host status and DNS records. */ +void write_host_header(Target *currenths); + /* Writes host status info to the log streams (including STDOUT). An example is "Host: 10.11.12.13 (foo.bar.example.com)\tStatus: Up\n" to machine log. resolve_all should be passed nonzero if the user asked