mirror of
https://github.com/nmap/nmap.git
synced 2025-12-18 05:29:02 +00:00
Cache dnet names not found in addition to found names. http://seclists.org/nmap-dev/2015/q1/251
This commit is contained in:
@@ -161,6 +161,9 @@ o [NSE] Remove db2-discover, as its functionality was performed by service
|
|||||||
broadcast-db2-discover. http://seclists.org/nmap-dev/2014/q3/415 [Daniel
|
broadcast-db2-discover. http://seclists.org/nmap-dev/2014/q3/415 [Daniel
|
||||||
Miller]
|
Miller]
|
||||||
|
|
||||||
|
o Cache dnet names not found on Windows when enumerating interfaces in the
|
||||||
|
Windows Registry. Reduces startup times. [Elon Natovich]
|
||||||
|
|
||||||
o [NSE] Make smb-ls able to leverage results from smb-enum-shares or list of
|
o [NSE] Make smb-ls able to leverage results from smb-enum-shares or list of
|
||||||
shares specified on command line. [Pierre Lalet]
|
shares specified on command line. [Pierre Lalet]
|
||||||
|
|
||||||
|
|||||||
@@ -3960,6 +3960,11 @@ int DnetName2PcapName(const char *dnetdev, char *pcapdev, int pcapdevlen) {
|
|||||||
} *NCC = NULL;
|
} *NCC = NULL;
|
||||||
static int NCCsz = 0;
|
static int NCCsz = 0;
|
||||||
static int NCCcapacity = 0;
|
static int NCCcapacity = 0;
|
||||||
|
static struct NameNotFoundCache {
|
||||||
|
char dnetd[64];
|
||||||
|
} *NNFC = NULL;
|
||||||
|
static int NNFCsz = 0;
|
||||||
|
static int NNFCcapacity = 0;
|
||||||
int i;
|
int i;
|
||||||
char tmpdev[128];
|
char tmpdev[128];
|
||||||
|
|
||||||
@@ -3971,6 +3976,13 @@ int DnetName2PcapName(const char *dnetdev, char *pcapdev, int pcapdevlen) {
|
|||||||
sizeof(*NCC));
|
sizeof(*NCC));
|
||||||
NCCsz = 0;
|
NCCsz = 0;
|
||||||
}
|
}
|
||||||
|
if (!NNFC) {
|
||||||
|
NNFCcapacity = 5;
|
||||||
|
NNFC =
|
||||||
|
(struct NameNotFoundCache *) safe_zalloc(NNFCcapacity *
|
||||||
|
sizeof(*NNFC));
|
||||||
|
NNFCsz = 0;
|
||||||
|
}
|
||||||
// First check if the name is already in the cache
|
// First check if the name is already in the cache
|
||||||
for (i = 0; i < NCCsz; i++) {
|
for (i = 0; i < NCCsz; i++) {
|
||||||
if (strcmp(NCC[i].dnetd, dnetdev) == 0) {
|
if (strcmp(NCC[i].dnetd, dnetdev) == 0) {
|
||||||
@@ -3978,12 +3990,28 @@ int DnetName2PcapName(const char *dnetdev, char *pcapdev, int pcapdevlen) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Check if the name is already in the name not found cache
|
||||||
// OK, so it isn't in the cache. Let's ask dnet for it.
|
for (i = 0; i < NNFCsz; i++) {
|
||||||
/* Converts a dnet interface name (ifname) to its pcap equivalent, which is stored in
|
if (strcmp(NNFC[i].dnetd, dnetdev) == 0) {
|
||||||
pcapdev (up to a length of pcapdevlen). Returns 0 and fills in pcapdev if successful. */
|
|
||||||
if (eth_get_pcap_devname(dnetdev, tmpdev, sizeof(tmpdev)) != 0)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// OK, so it isn't in the cache. Let's ask dnet for it.
|
||||||
|
/* Converts a dnet interface name (ifname) to its pcap equivalent, which is stored in
|
||||||
|
pcapdev (up to a length of pcapdevlen). Returns 1 and fills in pcapdev if successful. */
|
||||||
|
if (eth_get_pcap_devname(dnetdev, tmpdev, sizeof(tmpdev)) != 0) {
|
||||||
|
// We've got it. Let's add it to the not found cache
|
||||||
|
if (NNFCsz >= NNFCcapacity) {
|
||||||
|
NNFCcapacity <<= 2;
|
||||||
|
NNFC =
|
||||||
|
(struct NameNotFoundCache *) safe_realloc(NNFC,
|
||||||
|
NNFCcapacity *
|
||||||
|
sizeof(*NNFC));
|
||||||
|
}
|
||||||
|
Strncpy(NNFC[NNFCsz].dnetd, dnetdev, sizeof(NNFC[0].dnetd));
|
||||||
|
NNFCsz++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// We've got it. Let's add it to the cache
|
// We've got it. Let's add it to the cache
|
||||||
if (NCCsz >= NCCcapacity) {
|
if (NCCsz >= NCCcapacity) {
|
||||||
|
|||||||
Reference in New Issue
Block a user