1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Windows DNS: only use servers from the chosen device if -e is used

This commit is contained in:
dmiller
2025-05-23 19:03:02 +00:00
parent d59349fe99
commit 0f48a510eb

View File

@@ -1039,9 +1039,20 @@ void win32_get_servers() {
error("Unable to get DNS servers: %08x", ret);
return;
}
char pcap_name[1024];
const char *pcap_guid = NULL;
if (*o.device && DnetName2PcapName(o.device, pcap_name, sizeof(pcap_name))) {
// pcap_guid is the AdapterName for the requested adapter.
pcap_guid = strchr(pcap_name, '{');
}
for (IP_ADAPTER_ADDRESSES *a = &advec[0]; a != NULL; a = a->Next) {
if (a->OperStatus != IfOperStatusUp)
continue;
// If user requested an interface with -e,
// don't use DNS servers configured on other interfaces.
if (pcap_guid && 0 != strcasecmp(a->AdapterName, pcap_guid))
continue;
for (IP_ADAPTER_DNS_SERVER_ADDRESS_XP *d = a->FirstDnsServerAddress;
d != NULL; d = d->Next) {
const sockaddr_storage* ss = (sockaddr_storage*)d->Address.lpSockaddr;