mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 14:11:29 +00:00
Use Npcap-specific error messages on Windows for privilege issues.
This commit is contained in:
10
NmapOps.cc
10
NmapOps.cc
@@ -374,6 +374,10 @@ Npcap is available from https://npcap.com. The Npcap driver service must\n\
|
|||||||
be started by an administrator before Npcap can be used. Running nmap.exe\n\
|
be started by an administrator before Npcap can be used. Running nmap.exe\n\
|
||||||
will open a UAC dialog where you can start the service if you have\n\
|
will open a UAC dialog where you can start the service if you have\n\
|
||||||
administrator privileges.";
|
administrator privileges.";
|
||||||
|
|
||||||
|
#define YOU_ARE_ROOT "Npcap is installed"
|
||||||
|
#else
|
||||||
|
#define YOU_ARE_ROOT "you are root"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -403,15 +407,15 @@ administrator privileges.";
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((pingtype & PINGTYPE_UDP) && (!isr00t)) {
|
if ((pingtype & PINGTYPE_UDP) && (!isr00t)) {
|
||||||
fatal("Sorry, UDP Ping (-PU) only works if you are root (because we need to read raw responses off the wire)");
|
fatal("Sorry, UDP Ping (-PU) only works if " YOU_ARE_ROOT " (because we need to read raw responses off the wire)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pingtype & PINGTYPE_SCTP_INIT) && (!isr00t)) {
|
if ((pingtype & PINGTYPE_SCTP_INIT) && (!isr00t)) {
|
||||||
fatal("Sorry, SCTP INIT Ping (-PY) only works if you are root (because we need to read raw responses off the wire)");
|
fatal("Sorry, SCTP INIT Ping (-PY) only works if " YOU_ARE_ROOT " (because we need to read raw responses off the wire)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pingtype & PINGTYPE_PROTO) && (!isr00t)) {
|
if ((pingtype & PINGTYPE_PROTO) && (!isr00t)) {
|
||||||
fatal("Sorry, IPProto Ping (-PO) only works if you are root (because we need to read raw responses off the wire)");
|
fatal("Sorry, IPProto Ping (-PO) only works if " YOU_ARE_ROOT " (because we need to read raw responses off the wire)");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipprotscan && (TCPScan() || UDPScan() || SCTPScan())) {
|
if (ipprotscan && (TCPScan() || UDPScan() || SCTPScan())) {
|
||||||
|
|||||||
19
nmap.cc
19
nmap.cc
@@ -393,7 +393,11 @@ void validate_scan_lists(scan_lists &vports, NmapOps &vo) {
|
|||||||
|
|
||||||
if (!vo.isr00t) {
|
if (!vo.isr00t) {
|
||||||
if (vo.pingtype & (PINGTYPE_ICMP_PING | PINGTYPE_ICMP_MASK | PINGTYPE_ICMP_TS)) {
|
if (vo.pingtype & (PINGTYPE_ICMP_PING | PINGTYPE_ICMP_MASK | PINGTYPE_ICMP_TS)) {
|
||||||
|
#ifdef WIN32
|
||||||
|
error("Warning: Npcap not detected -- using TCP pingscan rather than ICMP");
|
||||||
|
#else
|
||||||
error("Warning: You are not root -- using TCP pingscan rather than ICMP");
|
error("Warning: You are not root -- using TCP pingscan rather than ICMP");
|
||||||
|
#endif
|
||||||
vo.pingtype &= ~(PINGTYPE_ICMP_PING | PINGTYPE_ICMP_MASK | PINGTYPE_ICMP_TS);
|
vo.pingtype &= ~(PINGTYPE_ICMP_PING | PINGTYPE_ICMP_MASK | PINGTYPE_ICMP_TS);
|
||||||
vo.pingtype |= PINGTYPE_TCP;
|
vo.pingtype |= PINGTYPE_TCP;
|
||||||
if (vports.syn_ping_count == 0) {
|
if (vports.syn_ping_count == 0) {
|
||||||
@@ -1567,8 +1571,13 @@ void apply_delayed_options() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (o.traceroute && !o.isr00t)
|
if (o.traceroute && !o.isr00t) {
|
||||||
|
#ifdef WIN32
|
||||||
|
fatal("Traceroute requires Npcap, which was not detected.");
|
||||||
|
#else
|
||||||
fatal("Traceroute has to be run as root");
|
fatal("Traceroute has to be run as root");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (o.traceroute && o.idlescan)
|
if (o.traceroute && o.idlescan)
|
||||||
fatal("Traceroute does not support idle scan");
|
fatal("Traceroute does not support idle scan");
|
||||||
|
|
||||||
@@ -1800,7 +1809,13 @@ void apply_delayed_options() {
|
|||||||
if (delayed_options.raw_scan_options && (!o.isr00t || o.connectscan)) {
|
if (delayed_options.raw_scan_options && (!o.isr00t || o.connectscan)) {
|
||||||
error("You have specified some options that require raw socket access.\n"
|
error("You have specified some options that require raw socket access.\n"
|
||||||
"These options will not be honored %s.",
|
"These options will not be honored %s.",
|
||||||
o.isr00t ? "for TCP Connect scan" : "without the necessary privileges");
|
o.isr00t ? "for TCP Connect scan" :
|
||||||
|
#ifdef WIN32
|
||||||
|
"since Npcap was not detected"
|
||||||
|
#else
|
||||||
|
"without the necessary privileges"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user