diff --git a/NmapOps.cc b/NmapOps.cc index a86022519..64cc0b37d 100644 --- a/NmapOps.cc +++ b/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\ will open a UAC dialog where you can start the service if you have\n\ administrator privileges."; + +#define YOU_ARE_ROOT "Npcap is installed" +#else +#define YOU_ARE_ROOT "you are root" #endif @@ -403,15 +407,15 @@ administrator privileges."; } 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)) { - 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)) { - 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())) { diff --git a/nmap.cc b/nmap.cc index 523bce16c..bbc2fb0a7 100644 --- a/nmap.cc +++ b/nmap.cc @@ -393,7 +393,11 @@ void validate_scan_lists(scan_lists &vports, NmapOps &vo) { if (!vo.isr00t) { 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"); +#endif vo.pingtype &= ~(PINGTYPE_ICMP_PING | PINGTYPE_ICMP_MASK | PINGTYPE_ICMP_TS); vo.pingtype |= PINGTYPE_TCP; if (vports.syn_ping_count == 0) { @@ -1567,8 +1571,13 @@ void apply_delayed_options() { } #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"); +#endif + } if (o.traceroute && o.idlescan) 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)) { error("You have specified some options that require raw socket access.\n" "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 + ); } }