mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 06:01:28 +00:00
Add an n parameter to ServiceProbe::testMatch to enable getting all of
the available matches.
This commit is contained in:
@@ -1175,7 +1175,7 @@ void AllProbes::service_scan_free(void)
|
|||||||
|
|
||||||
|
|
||||||
// If the buf (of length buflen) matches one of the regexes in this
|
// If the buf (of length buflen) matches one of the regexes in this
|
||||||
// ServiceProbe, returns the details of the match (service name,
|
// ServiceProbe, returns the details of nth match (service name,
|
||||||
// version number if applicable, and whether this is a "soft" match.
|
// version number if applicable, and whether this is a "soft" match.
|
||||||
// If the buf doesn't match, the serviceName field in the structure
|
// If the buf doesn't match, the serviceName field in the structure
|
||||||
// will be NULL. The MatchDetails returned is only valid until the
|
// will be NULL. The MatchDetails returned is only valid until the
|
||||||
@@ -1183,14 +1183,17 @@ void AllProbes::service_scan_free(void)
|
|||||||
// serviceName field can be saved throughought program execution. If
|
// serviceName field can be saved throughought program execution. If
|
||||||
// no version matched, that field will be NULL. This function may
|
// no version matched, that field will be NULL. This function may
|
||||||
// return NULL if there are no match lines at all in this probe.
|
// return NULL if there are no match lines at all in this probe.
|
||||||
const struct MatchDetails *ServiceProbe::testMatch(const u8 *buf, int buflen) {
|
const struct MatchDetails *ServiceProbe::testMatch(const u8 *buf, int buflen, int n = 0) {
|
||||||
vector<ServiceProbeMatch *>::iterator vi;
|
vector<ServiceProbeMatch *>::iterator vi;
|
||||||
const struct MatchDetails *MD;
|
const struct MatchDetails *MD;
|
||||||
|
|
||||||
for(vi = matches.begin(); vi != matches.end(); vi++) {
|
for(vi = matches.begin(); vi != matches.end(); vi++) {
|
||||||
MD = (*vi)->testMatch(buf, buflen);
|
MD = (*vi)->testMatch(buf, buflen);
|
||||||
if (MD->serviceName)
|
if (MD->serviceName) {
|
||||||
return MD;
|
if (n == 0)
|
||||||
|
return MD;
|
||||||
|
n--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ class ServiceProbe {
|
|||||||
void addMatch(const char *match, int lineno);
|
void addMatch(const char *match, int lineno);
|
||||||
|
|
||||||
// If the buf (of length buflen) matches one of the regexes in this
|
// If the buf (of length buflen) matches one of the regexes in this
|
||||||
// ServiceProbe, returns the details of the match (service name,
|
// ServiceProbe, returns the details of the nth match (service name,
|
||||||
// version number if applicable, and whether this is a "soft" match.
|
// version number if applicable, and whether this is a "soft" match.
|
||||||
// If the buf doesn't match, the serviceName field in the structure
|
// If the buf doesn't match, the serviceName field in the structure
|
||||||
// will be NULL. The MatchDetails returned is only valid until the
|
// will be NULL. The MatchDetails returned is only valid until the
|
||||||
@@ -287,7 +287,7 @@ class ServiceProbe {
|
|||||||
// serviceName field can be saved throughought program execution. If
|
// serviceName field can be saved throughought program execution. If
|
||||||
// no version matched, that field will be NULL. This function may
|
// no version matched, that field will be NULL. This function may
|
||||||
// return NULL if there are no match lines at all in this probe.
|
// return NULL if there are no match lines at all in this probe.
|
||||||
const struct MatchDetails *testMatch(const u8 *buf, int buflen);
|
const struct MatchDetails *testMatch(const u8 *buf, int buflen, int n);
|
||||||
|
|
||||||
char *fallbackStr;
|
char *fallbackStr;
|
||||||
ServiceProbe *fallbacks[MAXFALLBACKS+1];
|
ServiceProbe *fallbacks[MAXFALLBACKS+1];
|
||||||
|
|||||||
Reference in New Issue
Block a user