mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 16:57:06 +00:00
Show a warning whenever raw socket sending is attempted on Windows--not just
when using --send-ip.
This commit is contained in:
parent
e02f4bc983
commit
4ff30d9b99
6 changed files with 30 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
12
output.cc
12
output.cc
|
|
@ -116,6 +116,7 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
|
@ -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<string> 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);
|
||||
|
||||
|
|
|
|||
6
output.h
6
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
|
||||
|
|
|
|||
|
|
@ -1526,6 +1526,9 @@ void UltraScanInfo::Init(vector<Target *> &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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue