diff --git a/output.cc b/output.cc index 185a28944..166dc1d5a 100644 --- a/output.cc +++ b/output.cc @@ -290,6 +290,7 @@ int print_iflist(void) { int numifs = 0, numroutes = 0; struct interface_info *iflist; struct sys_route *routes; + pcap_if_t *p_ifaces, *p_iface_iter; NmapOutputTable *Tbl = NULL; iflist = getinterfaces(&numifs); int i; @@ -325,6 +326,25 @@ int print_iflist(void) { log_flush_all(); delete Tbl; } + + /* Display windows device names */ + if((p_ifaces = getpcapinterfaces()) != NULL && numifs > 0) { + Tbl = new NmapOutputTable(3, numifs); + Tbl->addItem(0, 0, false, "DEV"); + Tbl->addItem(0, 1, false, "WINDEVICE"); + i = numifs-1; + + for(p_iface_iter = p_ifaces; p_iface_iter != NULL && i >= 0; i--) { + Tbl->addItem(i+1, 0, false, iflist[i].devname); + Tbl->addItem(i+1, 1, false, p_iface_iter->name); + p_iface_iter = p_iface_iter->next; + } + + log_write(LOG_NORMAL|LOG_SKID|LOG_STDOUT, "%s\n", Tbl->printableTable(NULL)); + log_flush_all(); + delete Tbl; + pcap_freealldevs(p_ifaces); + } /* OK -- time to handle routes */ routes = getsysroutes(&numroutes); diff --git a/tcpip.cc b/tcpip.cc index 5940bfb2e..c1870dc8d 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -2615,6 +2615,19 @@ static int collect_dnet_interfaces(const struct intf_entry *entry, void *arg) { } #endif /* WIN32 */ +pcap_if_t *getpcapinterfaces() { + #ifndef WIN32 + return NULL; + #endif + pcap_if_t *p_ifaces; + + if((pcap_findalldevs(&p_ifaces, NULL)) == -1) { + fatal("pcap_findalldevs() : Cannot retrieve pcap interfaces"); + return NULL; + } + return p_ifaces; +} + struct interface_info *getinterfaces(int *howmany) { static bool initialized = 0; static struct interface_info *mydevs; @@ -2644,7 +2657,6 @@ int sd; #if WIN32 /* On Win32 we just use Dnet to determine the interface list */ - dcrn.routes = NULL; dcrn.numroutes = 0; dcrn.capacity = ii_capacity; // I'm reusing this struct for ii now diff --git a/tcpip.h b/tcpip.h index 2f851b8ca..b8d92a47c 100644 --- a/tcpip.h +++ b/tcpip.h @@ -648,6 +648,7 @@ struct interface_info *getInterfaceByIP(struct sockaddr_storage *ss); struct interface_info *getInterfaceByName(char *iname); /* Where the above 4 functions get their info */ struct interface_info *getinterfaces(int *howmany); +pcap_if_t *getpcapinterfaces(); /* Parse the system routing table, converting each route into a sys_route entry. Returns an array of sys_routes. numroutes is set