mirror of
https://github.com/nmap/nmap.git
synced 2025-12-27 18:09:01 +00:00
Give a better error message "requires root privileges" when trying to run a raw
scan on Windows with --unprivileged. Previously Nmap assumed that the only way o.isr00t could be false on Windows was if pcap functions were not available, so the user would get the false message "requires that WinPcap version 3.1 or higher...". NmapOps now has a state variable have_pcap so the meaning of isr00t isn't overloaded.
This commit is contained in:
@@ -217,6 +217,7 @@ void NmapOps::Initialize() {
|
||||
else
|
||||
isr00t = !(geteuid());
|
||||
#endif
|
||||
have_pcap = true;
|
||||
debugging = 0;
|
||||
verbose = 0;
|
||||
min_packet_send_rate = 0.0; /* Unset. */
|
||||
@@ -335,10 +336,10 @@ bool NmapOps::RawScan() {
|
||||
|
||||
|
||||
void NmapOps::ValidateOptions() {
|
||||
#ifdef WIN32
|
||||
const char *privreq = "that WinPcap version 3.1 or higher and iphlpapi.dll be installed. You seem to be missing one or both of these. Winpcap is available from http://www.winpcap.org. iphlpapi.dll comes with Win98 and later operating sytems and NT 4.0 with SP4 or greater. For previous windows versions, you may be able to take iphlpapi.dll from another system and place it in your system32 dir (e.g. c:\\windows\\system32)";
|
||||
#else
|
||||
const char *privreq = "root privileges";
|
||||
#ifdef WIN32
|
||||
if (!o.have_pcap)
|
||||
privreq = "that WinPcap version 3.1 or higher and iphlpapi.dll be installed. You seem to be missing one or both of these. Winpcap is available from http://www.winpcap.org. iphlpapi.dll comes with Win98 and later operating sytems and NT 4.0 with SP4 or greater. For previous windows versions, you may be able to take iphlpapi.dll from another system and place it in your system32 dir (e.g. c:\\windows\\system32)";
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -145,6 +145,8 @@ class NmapOps {
|
||||
adjustments (quietly or with a warning to the
|
||||
user). */
|
||||
int isr00t;
|
||||
/* Whether we have pcap functions (can be false on Windows). */
|
||||
bool have_pcap;
|
||||
int debugging;
|
||||
|
||||
#define PACKET_SEND_NOPREF 1
|
||||
|
||||
@@ -120,8 +120,6 @@
|
||||
|
||||
extern NmapOps o;
|
||||
|
||||
int pcap_avail = 0;
|
||||
|
||||
/* internal functions */
|
||||
static void win_cleanup(void);
|
||||
static char pcaplist[4096];
|
||||
@@ -173,7 +171,7 @@ void win_init()
|
||||
{
|
||||
ULONG len = sizeof(pcaplist);
|
||||
|
||||
pcap_avail = 1;
|
||||
o.have_pcap = true;
|
||||
if(o.debugging > 2) printf("***WinIP*** trying to initialize WinPcap\n");
|
||||
PacketGetAdapterNames(pcaplist, &len);
|
||||
|
||||
@@ -181,7 +179,7 @@ void win_init()
|
||||
if(FAILED(__HrLoadAllImportsForDll("wpcap.dll")))
|
||||
{
|
||||
error("WARNING: your winpcap is too old to use. Nmap may not function.\n");
|
||||
pcap_avail = 0;
|
||||
o.have_pcap = false;
|
||||
}
|
||||
#endif
|
||||
if(o.debugging)
|
||||
@@ -190,11 +188,11 @@ void win_init()
|
||||
#ifdef _MSC_VER
|
||||
__except (1) {
|
||||
error("WARNING: Could not import all necessary WinPcap functions. You may need to upgrade to version 3.1 or higher from http://www.winpcap.org. Resorting to connect() mode -- Nmap may not function completely");
|
||||
pcap_avail=0;
|
||||
o.have_pcap=false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!pcap_avail)
|
||||
if (!o.have_pcap)
|
||||
o.isr00t = 0;
|
||||
atexit(win_cleanup);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user