mirror of
https://github.com/nmap/nmap.git
synced 2025-12-30 19:39:07 +00:00
Enable Nmap, Nping to use Npcap over Winpcap if available.
This commit is contained in:
17
nse_dnet.cc
17
nse_dnet.cc
@@ -19,6 +19,10 @@ extern "C" {
|
||||
#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),
|
||||
@@ -153,7 +157,11 @@ static int ethernet_open (lua_State *L)
|
||||
const char *interface_name = luaL_checkstring(L, 2);
|
||||
struct interface_info *ii = getInterfaceByName(interface_name, o.af());
|
||||
|
||||
if (ii == NULL || ii->device_type != devt_ethernet)
|
||||
if (ii == NULL || ii->device_type != devt_ethernet
|
||||
#ifdef WIN32
|
||||
&& !(g_has_npcap_loopback && ii->device_type == devt_loopback)
|
||||
#endif
|
||||
)
|
||||
return luaL_argerror(L, 2, "device is not valid ethernet interface");
|
||||
|
||||
udata->eth = open_eth_cached(L, 1, interface_name);
|
||||
@@ -252,8 +260,13 @@ static int ip_send (lua_State *L)
|
||||
|
||||
Strncpy(dev, route.ii.devname, sizeof(dev));
|
||||
|
||||
if (route.ii.device_type != devt_ethernet)
|
||||
if (! (route.ii.device_type == devt_ethernet
|
||||
#ifdef WIN32
|
||||
|| (g_has_npcap_loopback && route.ii.device_type == devt_loopback)
|
||||
#endif
|
||||
) ) {
|
||||
goto usesock;
|
||||
}
|
||||
|
||||
/* above we fallback to using the raw socket if we can't find an (ethernet)
|
||||
* route to the host. From here on out it's ethernet all the way.
|
||||
|
||||
Reference in New Issue
Block a user