diff --git a/idle_scan.cc b/idle_scan.cc index 2d6a1f06a..408efb356 100644 --- a/idle_scan.cc +++ b/idle_scan.cc @@ -391,6 +391,9 @@ static void initialize_idleproxy(struct idle_proxy_info *proxy, char *proxyName, proxy->rawsd = -1; proxy->ethptr = &proxy->eth; } else { +#ifdef WIN32 + win32_warn_raw_sockets(proxy->host.deviceName()); +#endif if ((proxy->rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 ) pfatal("socket troubles in %s", __func__); unblock_socket(proxy->rawsd); diff --git a/osscan2.cc b/osscan2.cc index 757a2c127..0054d74d1 100644 --- a/osscan2.cc +++ b/osscan2.cc @@ -931,6 +931,9 @@ HostOsScan::HostOsScan(Target *t) { ethptr = ð } else { /* Init our raw socket */ +#ifdef WIN32 + win32_warn_raw_sockets(t->deviceName()); +#endif if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 ) pfatal("socket troubles in %s", __func__); unblock_socket(rawsd); diff --git a/output.cc b/output.cc index 708302b48..a0ad21a8f 100644 --- a/output.cc +++ b/output.cc @@ -116,6 +116,7 @@ #include +#include #include #include #include @@ -296,6 +297,17 @@ static char * getServiceXMLBuf(struct serviceDeductions *sd) { } #ifdef WIN32 +/* Display a warning that a device is not Ethernet and so raw sockets + will be used. The warning is shown only once per unique device name. */ +void win32_warn_raw_sockets(const char *devname) { + static set shown_names; + + if (shown_names.find(devname) == shown_names.end()) { + error("WARNING: Using raw sockets because %s is not an ethernet device. This probably won't work on Windows.\n", devname); + shown_names.insert(devname); + } +} + /* From tcpip.cc. */ bool DnetName2PcapName(const char *dnetdev, char *pcapdev, int pcapdevlen); diff --git a/output.h b/output.h index 2452e0004..8a8da568b 100644 --- a/output.h +++ b/output.h @@ -125,6 +125,12 @@ #include "nmap.h" #include "global_structures.h" +#ifdef WIN32 +/* Display a warning that a device is not Ethernet and so raw sockets + will be used. The warning is shown only once per unique device name. */ +void win32_warn_raw_sockets(const char *devname); +#endif + /* Prints the familiar Nmap tabular output showing the "interesting" ports found on the machine. It also handles the Machine/Greppable output and the XML output. It is pretty ugly -- in particular I diff --git a/scan_engine.cc b/scan_engine.cc index 97095b0ff..dfd01a019 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -1526,6 +1526,9 @@ void UltraScanInfo::Init(vector &Targets, struct scan_lists *pts, styp rawsd = -1; } else { /* Initialize a raw socket */ +#ifdef WIN32 + win32_warn_raw_sockets(Targets[0]->deviceName()); +#endif if ((rawsd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0 ) pfatal("socket troubles in %s", __func__); /* We do not wan't to unblock the socket since we want to wait diff --git a/traceroute.cc b/traceroute.cc index 79b83ba13..a08c09391 100644 --- a/traceroute.cc +++ b/traceroute.cc @@ -216,6 +216,9 @@ Traceroute::Traceroute (const char *device_name, devtype type, const scan_lists if (ethsd == NULL) fatal ("dnet: Failed to open device %s", device_name); } else { +#ifdef WIN32 + win32_warn_raw_sockets(device_name); +#endif if ((fd = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) pfatal ("Traceroute: socket troubles"); broadcast_socket (fd);