1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Remove unneeded g_has_npcap_loopback

This commit is contained in:
dmiller
2025-04-16 00:00:05 +00:00
parent 40b5bda3ac
commit 42170b067f
8 changed files with 12 additions and 47 deletions

View File

@@ -76,8 +76,6 @@ extern NmapOps o;
#ifdef WIN32
/* Need DnetName2PcapName */
#include "libnetutil/netutil.h"
/* from libdnet's intf-win32.c */
extern "C" int g_has_npcap_loopback;
#endif
#include <math.h>
@@ -159,7 +157,7 @@ void FPNetworkControl::init(const char *ifname, devtype iftype) {
/* Obtain raw socket or check that we can obtain an eth descriptor. */
if ((o.sendpref & PACKET_SEND_ETH) && (iftype == devt_ethernet
#ifdef WIN32
|| (g_has_npcap_loopback && iftype == devt_loopback)
|| (o.have_pcap && iftype == devt_loopback)
#endif
) && ifname != NULL) {
/* We don't need to store the eth handler because FPProbes come with a
@@ -1810,7 +1808,7 @@ int FPHost6::build_probe_list() {
/* ICMP Probe #3: Neighbor Solicitation. (only sent to on-link targets) */
if (this->target_host->directlyConnected()
#ifdef WIN32
&& !(g_has_npcap_loopback && this->target_host->ifType() == devt_loopback)
&& this->target_host->ifType() != devt_loopback
#endif
) {
ip6 = new IPv6Header();

View File

@@ -107,10 +107,6 @@
#include <stdio.h>
extern NmapOps o;
#ifdef WIN32
/* from libdnet's intf-win32.c */
extern "C" int g_has_npcap_loopback;
#endif
struct idle_proxy_info {
Target host; /* contains name, IP, source IP, timing info, etc. */
@@ -605,7 +601,7 @@ static void initialize_idleproxy(struct idle_proxy_info *proxy, char *proxyName,
/* First we need a raw socket ... */
if ((o.sendpref & PACKET_SEND_ETH) && (proxy->host.ifType() == devt_ethernet
#ifdef WIN32
|| (g_has_npcap_loopback && proxy->host.ifType() == devt_loopback)
|| (o.have_pcap && proxy->host.ifType() == devt_loopback)
#endif
)) {
if (!setTargetNextHopMAC(&proxy->host))

View File

@@ -70,10 +70,6 @@
#include "common_modified.h"
extern NpingOps o;
#ifdef WIN32
/* from libdnet's intf-win32.c */
extern "C" int g_has_npcap_loopback;
#endif
NpingTargets::NpingTargets(){
memset(specs, 0, 1024*(sizeof(char *)) );
@@ -251,7 +247,7 @@ int NpingTargets::processSpecs(){
continue;
}
#ifdef WIN32
if (g_has_npcap_loopback == 0 && rnfo.ii.device_type == devt_loopback){
if (!o.havePcap() && rnfo.ii.device_type == devt_loopback){
nping_warning(QT_2, "Skipping %s because Windows does not allow localhost scans (try --unprivileged).", mytarget->getTargetIPstr() );
delete mytarget;
continue;
@@ -287,7 +283,7 @@ int NpingTargets::processSpecs(){
/* Determine next hop MAC address and target MAC address */
if( o.sendEth() ){
#ifdef WIN32
if (g_has_npcap_loopback == 1 && rnfo.ii.device_type == devt_loopback) {
if (o.havePcap() && rnfo.ii.device_type == devt_loopback) {
mytarget->setNextHopMACAddress(mytarget->getSrcMACAddress());
}
else {

View File

@@ -14,10 +14,6 @@
#include <assert.h>
extern NmapOps o;
#ifdef WIN32
/* from libdnet's intf-win32.c */
extern "C" int g_has_npcap_loopback;
#endif
enum {
DNET_METATABLE = lua_upvalueindex(1),
@@ -169,7 +165,7 @@ static int ethernet_open (lua_State *L)
if (ii == NULL || ii->device_type != devt_ethernet
#ifdef WIN32
&& !(g_has_npcap_loopback && ii->device_type == devt_loopback)
&& ii->device_type != devt_loopback
#endif
)
return luaL_argerror(L, 2, "device is not valid ethernet interface");
@@ -314,7 +310,7 @@ static int ip_send (lua_State *L)
if (! (route.ii.device_type == devt_ethernet
#ifdef WIN32
|| (g_has_npcap_loopback && route.ii.device_type == devt_loopback)
|| (o.have_pcap && route.ii.device_type == devt_loopback)
#endif
) ) {
goto usesock;
@@ -339,7 +335,7 @@ static int ip_send (lua_State *L)
// Only determine mac addr info if it's not the Npcap Loopback Adapter.
// Npcap loopback doesn't have a MAC address and isn't an ethernet device,
// so getNextHopMAC crashes.
if (!(g_has_npcap_loopback && route.ii.device_type == devt_loopback)) {
if (route.ii.device_type != devt_loopback) {
#endif
if (!getNextHopMAC(route.ii.devfullname, route.ii.mac, &hdr.src, nexthop, dstmac))
return luaL_error(L, "failed to determine next hop MAC address");

View File

@@ -80,10 +80,6 @@
#include <math.h>
extern NmapOps o;
#ifdef WIN32
/* from libdnet's intf-win32.c */
extern "C" int g_has_npcap_loopback;
#endif
/* 8 options:
* 0~5: six options for SEQ/OPS/WIN/T1 probes.
@@ -1342,7 +1338,7 @@ HostOsScan::HostOsScan(Target *t) {
if ((o.sendpref & PACKET_SEND_ETH) && (t->ifType() == devt_ethernet
#ifdef WIN32
|| (g_has_npcap_loopback && t->ifType() == devt_loopback)
|| (o.have_pcap && t->ifType() == devt_loopback)
#endif
)) {
if ((ethsd = eth_open_cached(t->deviceName())) == NULL)
@@ -3283,13 +3279,6 @@ OsScanInfo::OsScanInfo(std::vector<Target *> &Targets) {
continue;
}
#ifdef WIN32
if (g_has_npcap_loopback == 0 && Targets[targetno]->ifType() == devt_loopback) {
log_write(LOG_STDOUT, "Skipping OS Scan against %s because it doesn't work against your own machine (localhost)\n", Targets[targetno]->NameIP());
continue;
}
#endif
if (Targets[targetno]->ports.getStateCounts(IPPROTO_TCP, PORT_OPEN) == 0 ||
(Targets[targetno]->ports.getStateCounts(IPPROTO_TCP, PORT_CLOSED) == 0 &&
Targets[targetno]->ports.getStateCounts(IPPROTO_TCP, PORT_UNFILTERED) == 0)) {

View File

@@ -92,10 +92,6 @@
#include <map>
extern NmapOps o;
#ifdef WIN32
/* from libdnet's intf-win32.c */
extern "C" int g_has_npcap_loopback;
#endif
/* How long extra to wait before retransmitting for rate-limit detection */
#define RLD_TIME_MS 1000
@@ -956,7 +952,7 @@ void UltraScanInfo::Init(std::vector<Target *> &Targets, const struct scan_lists
if (ping_scan_arp || (ping_scan_nd && o.sendpref != PACKET_SEND_IP_STRONG) || ((o.sendpref & PACKET_SEND_ETH) &&
(Targets[0]->ifType() == devt_ethernet
#ifdef WIN32
|| (g_has_npcap_loopback && Targets[0]->ifType() == devt_loopback)
|| (Targets[0]->ifType() == devt_loopback)
#endif
))) {
/* We'll send ethernet packets with dnet */
@@ -2755,7 +2751,7 @@ void ultra_scan(std::vector<Target *> &Targets, const struct scan_lists *ports,
}
#ifdef WIN32
if (g_has_npcap_loopback == 0 && scantype != CONNECT_SCAN && Targets[0]->ifType() == devt_loopback) {
if (!o.have_pcap && scantype != CONNECT_SCAN && Targets[0]->ifType() == devt_loopback) {
log_write(LOG_STDOUT, "Skipping %s against %s because Windows does not support scanning your own machine (localhost) this way.\n", scantype2str(scantype), Targets[0]->NameIP());
return;
}

View File

@@ -77,10 +77,6 @@
#include "output.h"
extern NmapOps o;
#ifdef WIN32
/* from libdnet's intf-win32.c */
extern "C" int g_has_npcap_loopback;
#endif
/* Conducts an ARP ping sweep of the given hosts to determine which ones
are up on a local ethernet network */
@@ -378,7 +374,7 @@ static Target *setup_target(const HostGroupState *hs,
t->setSrcMACAddress(rnfo.ii.mac);
}
#ifdef WIN32
else if (g_has_npcap_loopback && rnfo.ii.device_type == devt_loopback) {
else if (o.have_pcap && rnfo.ii.device_type == devt_loopback) {
if (o.spoofMACAddress())
t->setSrcMACAddress(o.spoofMACAddress());
else

View File

@@ -836,8 +836,6 @@ TracerouteState::TracerouteState(std::vector<Target *> &targets) {
assert(targets.size() > 0);
if ((o.sendpref & PACKET_SEND_ETH) && targets[0]->ifType() == devt_ethernet) {
/* No need to check for g_has_npcap_loopback on WIN32 because devt_loopback
* is checked earlier. */
ethsd = eth_open_cached(targets[0]->deviceName());
if (ethsd == NULL)
fatal("dnet: failed to open device %s", targets[0]->deviceName());