From 57238b7df5a73311b53d9e17c51d3ae6c6b7ccef Mon Sep 17 00:00:00 2001 From: david Date: Tue, 11 May 2010 05:59:09 +0000 Subject: [PATCH] Print the addresses that were resolved but not scanned in each scan report. It looks like this. $ ./nmap google.com -sn Starting Nmap 5.30BETA1 ( http://nmap.org ) at 2010-05-10 23:57 MDT Nmap scan report for google.com (66.102.7.99) Host is up (0.073s latency). Other addresses for google.com (not scanned): 66.102.7.104 rDNS record for 66.102.7.99: lax04s01-in-f99.1e100.net This replaces the line Hostname google.com resolves to 2 IPs. Only scanned 66.102.7.99 --- TargetGroup.cc | 2 +- output.cc | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/TargetGroup.cc b/TargetGroup.cc index cd1995492..c515ce5b8 100644 --- a/TargetGroup.cc +++ b/TargetGroup.cc @@ -217,7 +217,7 @@ int TargetGroup::parse_expr(const char * const target_expr, int af) { struct sockaddr_in *sin = (struct sockaddr_in *) &ss; sin->sin_family = AF_INET; - sin->sin_addr = addr; + memcpy(&sin->sin_addr, target->h_addr_list[count], sizeof(sin->sin_addr)); resolvedaddrs.push_back(ss); count++; } diff --git a/output.cc b/output.cc index d1640816b..cae249fad 100644 --- a/output.cc +++ b/output.cc @@ -1305,9 +1305,15 @@ void write_host_header(Target *currenths) { write_host_status(currenths, o.resolve_all); if (currenths->TargetName() != NULL && currenths->resolved_addrs.size() > 1) { - log_write(LOG_PLAIN, "Hostname %s resolves to %u IPs. Only scanned %s\n", - currenths->TargetName(), (unsigned int) currenths->resolved_addrs.size(), - currenths->targetipstr()); + std::list::iterator it; + + log_write(LOG_PLAIN, "Other addresses for %s (not scanned):", + currenths->TargetName()); + it = currenths->resolved_addrs.begin(); + it++; + for (; it != currenths->resolved_addrs.end(); it++) + log_write(LOG_PLAIN, " %s", inet_ntop_ez(&*it, sizeof(*it))); + log_write(LOG_PLAIN, "\n"); } /* Print reverse DNS if it differs. */ if (currenths->TargetName() != NULL