mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Report IPv4 and IPv6 addresses resolved for each host
Previously, we would only request IPv4 addresses by default, or only IPv6 when scanning with -6. Now, we'll request both (by not passing an address family in the hints to getaddrinfo) and report them all in the "Other addresses" line. This should encourage more users to scan with -6. Additionally, it allows us to catch and report attempts to scan IPv6-only hosts via IPv4, where previously we would just say "Failed to resolve" Closes #76
This commit is contained in:
13
output.cc
13
output.cc
@@ -1426,14 +1426,17 @@ void write_host_header(Target *currenths) {
|
||||
write_host_status(currenths);
|
||||
if (currenths->TargetName() != NULL
|
||||
&& currenths->resolved_addrs.size() > 1) {
|
||||
std::list<struct sockaddr_storage>::iterator it;
|
||||
const struct sockaddr_storage *hs_ss = currenths->TargetSockAddr();
|
||||
|
||||
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)));
|
||||
for (std::list<struct sockaddr_storage>::const_iterator it = currenths->resolved_addrs.begin(), end = currenths->resolved_addrs.end();
|
||||
it != end; it++) {
|
||||
struct sockaddr_storage ss = *it;
|
||||
if (!sockaddr_storage_equal(&ss, hs_ss)) {
|
||||
log_write(LOG_PLAIN, " %s", inet_ntop_ez(&ss, sizeof(ss)));
|
||||
}
|
||||
}
|
||||
log_write(LOG_PLAIN, "\n");
|
||||
}
|
||||
/* Print reverse DNS if it differs. */
|
||||
|
||||
Reference in New Issue
Block a user