diff -Nraupb nmap/nmap.cc nmap-fixed/nmap.cc --- nmap/nmap.cc 2008-04-09 02:28:40.000000000 +0200 +++ nmap-fixed/nmap.cc 2008-04-11 01:12:16.000000000 +0200 @@ -1197,6 +1197,7 @@ int nmap_main(int argc, char *argv[]) { #ifdef WIN32 win_init(); #endif + strncpy(o.nmappath, argv[0], sizeof(o.nmappath)-1); tty_init(); // Put the keyboard in raw mode diff -Nraupb nmap/NmapOps.h nmap-fixed/NmapOps.h --- nmap/NmapOps.h 2008-04-09 02:28:40.000000000 +0200 +++ nmap-fixed/NmapOps.h 2008-04-11 01:12:16.000000000 +0200 @@ -309,6 +309,7 @@ class NmapOps { FILE *nmap_stdout; /* Nmap standard output */ int ttl; // Time to live int badsum; + char nmappath[512]; /* path to nmap. currently copy of argv[0] */ char *datadir; /* A map from abstract data file names like "nmap-services" and "nmap-os-db" to paths which have been requested by the user. nmap_fetchfile will return diff -Nraupb nmap/tcpip.cc nmap-fixed/tcpip.cc --- nmap/tcpip.cc 2008-04-09 02:28:40.000000000 +0200 +++ nmap-fixed/tcpip.cc 2008-04-11 01:12:16.000000000 +0200 @@ -101,6 +101,9 @@ /* $Id: tcpip.cc 6858 2008-02-28 18:52:06Z fyodor $ */ #ifdef WIN32 #include "nmap_winconfig.h" +#include "winfix.h" +#include +#include #endif #include "portreasons.h" #include @@ -1066,6 +1069,26 @@ eth_t *eth_open_cached(const char *devic } etht_cache_device = eth_open(device); + + #ifdef WIN32 + /* + The driver needs to be loaded in admin. + Load winpcap driver :) Say hello tu wonderful UAC + ShellExecute Function: http://msdn2.microsoft.com/en-us/library/bb762153(VS.85).aspx */ + if (!etht_cache_device) { + /* if (o.debugging) */ + error("WARNING: Could not open network device %s. Trying to load WinPcap driver with Administrator privileges.", device); + char params[512]; + snprintf(params, sizeof(params), "-sS -p 80 -P0 -n -e %s 127.0.0.1", device); + ShellExecute(NULL, "runas", o.nmappath, params, 0, SW_SHOWNORMAL /* SW_HIDE | SW_MINIMIZE */ ); + /* wait for the driver to be loaded*/ + sleep(2); + /* try again */ + etht_cache_device = eth_open(device); + if(etht_cache_device /* && o.debugging */) + error("WARNING: WinPcap driver loaded with success."); + } + #endif if (etht_cache_device) Strncpy(etht_cache_device_name, device, sizeof(etht_cache_device_name));