From 28604535c43298b9360ff38fc3755cf81e108ac8 Mon Sep 17 00:00:00 2001 From: david Date: Sun, 3 Mar 2013 03:06:42 +0000 Subject: [PATCH] Hardcode constant "CurrentControlSet" parameter. I don't find anywhere in the history where this value has ever varied. This is an old post from Doug where he mentions possibly different values, but they appear to have been unused. http://seclists.org/nmap-dev/2006/q1/147 --- nmap_dns.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nmap_dns.cc b/nmap_dns.cc index 763d3eaec..d4b271958 100644 --- a/nmap_dns.cc +++ b/nmap_dns.cc @@ -862,14 +862,14 @@ static void connect_dns_servers() { #ifdef WIN32 // Reads the Windows registry and adds all the nameservers found via the // add_dns_server() function. -void win32_read_registry(char *controlset) { +void win32_read_registry() { HKEY hKey; HKEY hKey2; char keybasebuf[2048]; char buf[2048], keyname[2048], *p; DWORD sz, i; - Snprintf(keybasebuf, sizeof(keybasebuf), "SYSTEM\\%s\\Services\\Tcpip\\Parameters", controlset); + Snprintf(keybasebuf, sizeof(keybasebuf), "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keybasebuf, 0, KEY_READ, &hKey) != ERROR_SUCCESS) { if (firstrun) error("mass_dns: warning: Error opening registry to read DNS servers. Try using --system-dns or specify valid servers with --dns-servers"); @@ -886,14 +886,14 @@ void win32_read_registry(char *controlset) { RegCloseKey(hKey); - Snprintf(keybasebuf, sizeof(keybasebuf), "SYSTEM\\%s\\Services\\Tcpip\\Parameters\\Interfaces", controlset); + Snprintf(keybasebuf, sizeof(keybasebuf), "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces"); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keybasebuf, 0, KEY_ENUMERATE_SUB_KEYS, &hKey) == ERROR_SUCCESS) { sz = sizeof(buf); for (i=0; RegEnumKeyEx(hKey, i, buf, &sz, NULL, NULL, NULL, NULL) != ERROR_NO_MORE_ITEMS; i++) { - Snprintf(keyname, sizeof(keyname), "SYSTEM\\%s\\Services\\Tcpip\\Parameters\\Interfaces\\%s", controlset, buf); + Snprintf(keyname, sizeof(keyname), "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\%s", buf); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &hKey2) == ERROR_SUCCESS) { @@ -1095,7 +1095,7 @@ static void init_servs(void) { #ifndef WIN32 parse_resolvdotconf(); #else - win32_read_registry("CurrentControlSet"); + win32_read_registry(); #endif } }