mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Check if an interface is known to pcap before adding its name servers.
Kenneth Frazier reported that sometimes Nmap would use name servers from inactive interfaces. Let's try checking the interface GUIDs against those known by libpcap. http://seclists.org/nmap-dev/2013/q1/292
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
# Nmap Changelog ($Id$); -*-text-*-
|
# Nmap Changelog ($Id$); -*-text-*-
|
||||||
|
|
||||||
|
o The list of nameservers on Windows now ignores nameservers from
|
||||||
|
inactive interfaces. [David Fifield]
|
||||||
|
|
||||||
o Namespace the pipes used to communicate with subprocesses by PID, to
|
o Namespace the pipes used to communicate with subprocesses by PID, to
|
||||||
avoid multiple instances of Ncat from interfering with each other.
|
avoid multiple instances of Ncat from interfering with each other.
|
||||||
Patch by Andrey Olkhin.
|
Patch by Andrey Olkhin.
|
||||||
|
|||||||
30
nmap_dns.cc
30
nmap_dns.cc
@@ -860,6 +860,30 @@ static void connect_dns_servers() {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
static bool interface_is_known_by_guid(const char *guid) {
|
||||||
|
struct interface_info *iflist;
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
iflist = getinterfaces(&n, NULL, 0);
|
||||||
|
if (iflist == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
char pcap_name[1024];
|
||||||
|
char *pcap_guid;
|
||||||
|
|
||||||
|
if (!DnetName2PcapName(iflist[i].devname, pcap_name, sizeof(pcap_name)))
|
||||||
|
continue;
|
||||||
|
pcap_guid = strchr(pcap_name, '{');
|
||||||
|
if (pcap_guid == NULL)
|
||||||
|
continue;
|
||||||
|
if (strcmp(guid, pcap_guid) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Reads the Windows registry and adds all the nameservers found via the
|
// Reads the Windows registry and adds all the nameservers found via the
|
||||||
// add_dns_server() function.
|
// add_dns_server() function.
|
||||||
void win32_read_registry() {
|
void win32_read_registry() {
|
||||||
@@ -892,6 +916,12 @@ void win32_read_registry() {
|
|||||||
|
|
||||||
for (i=0; sz = sizeof(buf), RegEnumKeyEx(hKey, i, buf, &sz, NULL, NULL, NULL, NULL) != ERROR_NO_MORE_ITEMS; i++) {
|
for (i=0; sz = sizeof(buf), RegEnumKeyEx(hKey, i, buf, &sz, NULL, NULL, NULL, NULL) != ERROR_NO_MORE_ITEMS; i++) {
|
||||||
|
|
||||||
|
if (!interface_is_known_by_guid(buf)) {
|
||||||
|
if (o.debugging > 1)
|
||||||
|
log_write(LOG_PLAIN, "Interface %s is not known; ignoring its nameservers.\n", buf);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Snprintf(keyname, sizeof(keyname), "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%s", buf);
|
Snprintf(keyname, sizeof(keyname), "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%s", buf);
|
||||||
|
|
||||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname,
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname,
|
||||||
|
|||||||
Reference in New Issue
Block a user