mirror of
https://github.com/nmap/nmap.git
synced 2026-08-03 22:29:06 +00:00
Fix Npcap loading in Nping. Fixes #559
This commit is contained in:
parent
bf4c2651ec
commit
5806603494
4 changed files with 21 additions and 27 deletions
|
|
@ -1,5 +1,9 @@
|
|||
# Nmap Changelog ($Id$); -*-text-*-
|
||||
|
||||
o [Nping][GH#559] Fix Nping's ability to use Npcap on Windows. A privilege
|
||||
check was performed too late, so the Npcap loading code assumed the user had no
|
||||
rights. [Yang Luo, Daniel Miller]
|
||||
|
||||
o [Zenmap] Fix a crash in the About page in the Spanish translation due to a
|
||||
missing format specifier:
|
||||
File "zenmapGUI\About.pyo", line 217, in __init__
|
||||
|
|
|
|||
|
|
@ -188,8 +188,19 @@ NpingOps::NpingOps() {
|
|||
disable_packet_capture_set=false;
|
||||
|
||||
/* Privileges */
|
||||
/* If user did not specify --privileged or --unprivileged explicitly, try to
|
||||
* determine if has root privileges. */
|
||||
#if defined WIN32 || defined __amigaos__
|
||||
/* TODO: Check this because although nmap does exactly the same, it has a this->have_pcap that may affect to this */
|
||||
isr00t=true;
|
||||
#else
|
||||
if (getenv("NMAP_PRIVILEGED") || getenv("NPING_PRIVILEGED"))
|
||||
isr00t=true;
|
||||
else if (getenv("NMAP_UNPRIVILEGED") || getenv("NPING_UNPRIVILEGED"))
|
||||
isr00t=false;
|
||||
isr00t_set=false;
|
||||
else
|
||||
isr00t = !(geteuid());
|
||||
#endif
|
||||
|
||||
/* Payloads */
|
||||
payload_type=PL_NONE;
|
||||
|
|
@ -957,7 +968,6 @@ int NpingOps::af(){
|
|||
int NpingOps::setIsRoot(int v) {
|
||||
int prev=this->isr00t;
|
||||
this->isr00t = (v==0) ? 0 : 1;
|
||||
this->isr00t_set=true;
|
||||
return prev;
|
||||
} /* End of setIsRoot() */
|
||||
|
||||
|
|
@ -967,7 +977,6 @@ int NpingOps::setIsRoot(int v) {
|
|||
int NpingOps::setIsRoot() {
|
||||
int prev=this->isr00t;
|
||||
this->isr00t=1;
|
||||
this->isr00t_set=true;
|
||||
return prev;
|
||||
} /* End of setIsRoot() */
|
||||
|
||||
|
|
@ -978,12 +987,6 @@ bool NpingOps::isRoot() {
|
|||
} /* End of isRoot() */
|
||||
|
||||
|
||||
/* Returns true if option has been set */
|
||||
bool NpingOps::issetIsRoot(){
|
||||
return this->isr00t_set;
|
||||
} /* End of isset() */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Payloads *
|
||||
******************************************************************************/
|
||||
|
|
@ -2288,21 +2291,6 @@ const char *privreq = "root privileges";
|
|||
//if (!this->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 systems 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
|
||||
/* If user did not specify --privileged or --unprivileged explicitly, try to
|
||||
* determine if has root privileges. */
|
||||
if( !this->issetIsRoot() ){
|
||||
#if defined WIN32 || defined __amigaos__
|
||||
/* TODO: Check this because although nmap does exactly the same, it has a this->have_pcap that may affect to this */
|
||||
this->setIsRoot(1);
|
||||
#else
|
||||
if (getenv("NMAP_PRIVILEGED") || getenv("NPING_PRIVILEGED"))
|
||||
this->setIsRoot(1);
|
||||
else if (getenv("NMAP_UNPRIVILEGED") || getenv("NPING_UNPRIVILEGED"))
|
||||
this->setIsRoot(0);
|
||||
else
|
||||
this->setIsRoot( !(geteuid()) );
|
||||
#endif
|
||||
}
|
||||
|
||||
if (this->havePcap()==false){
|
||||
#ifdef WIN32
|
||||
|
|
|
|||
|
|
@ -218,7 +218,6 @@ class NpingOps {
|
|||
|
||||
/* Privileges */
|
||||
bool isr00t; /* True if current user has root privs */
|
||||
bool isr00t_set;
|
||||
|
||||
/* Payloads */
|
||||
int payload_type; /* Type of payload (RAND,HEX,FILE) */
|
||||
|
|
@ -447,7 +446,6 @@ class NpingOps {
|
|||
int setIsRoot(int v);
|
||||
int setIsRoot();
|
||||
bool isRoot();
|
||||
bool issetIsRoot();
|
||||
|
||||
/* Payloads */
|
||||
int setPayloadType(int t);
|
||||
|
|
|
|||
|
|
@ -175,7 +175,6 @@ int main(int argc, char *argv[] ){
|
|||
/* Init a few things on Windows */
|
||||
#ifdef WIN32
|
||||
win_pre_init();
|
||||
win_init();
|
||||
#endif
|
||||
|
||||
/* Register the SIGINT signal so when the users presses CTRL-C we print stats
|
||||
|
|
@ -186,6 +185,11 @@ int main(int argc, char *argv[] ){
|
|||
|
||||
/* Let's parse and validate user supplied args */
|
||||
a.parseArguments(argc, argv);
|
||||
#ifdef WIN32
|
||||
// Must come after parseArguments because of --unprivileged
|
||||
// Must come before validateOptions because it sets o.isRoot
|
||||
win_init();
|
||||
#endif
|
||||
o.validateOptions();
|
||||
|
||||
/* ISO 8601 date/time -- http://www.cl.cam.ac.uk/~mgk25/iso-time.html */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue