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

Treat a service named "unknown" as if it were not named in nmap-services for

purposes of output. What this means is that the port name will not be
"unknown?" or "ssl/unknown?" if version detection failed to find a match, but
simply "unknown" or "ssl/unknown".
This commit is contained in:
david
2009-03-03 18:56:21 +00:00
parent 72d3ffe636
commit 5ed0e17ea0
2 changed files with 15 additions and 26 deletions

View File

@@ -4,7 +4,7 @@ o Version detection used to omit the "ssl/" service name prefix if an
SSL-tunneled port didn't respond to any version probes. Now it keeps
"ssl/" as an indication that SSL was discovered, even if the service
behind it wasn't identified. Kristof Boeynaems reported the problem
and contributed a patch.
and contributed a patch. [David]
o [Ncat] The --talk option has been renamed --chat. --talk remains as an
undocumented alias.

View File

@@ -455,36 +455,25 @@ int print_iflist(void) {
namebuf to 0 length if there is no room.*/
static void getNmapServiceName(struct serviceDeductions *sd, int state,
char *namebuf, int buflen) {
char *dst = namebuf;
int lenremaining = buflen;
const char *tunnel_prefix;
int len;
if (buflen < 1) return;
if (sd->service_tunnel == SERVICE_TUNNEL_SSL) {
if (lenremaining < 5) goto overflow;
strncpy(dst, "ssl/", lenremaining);
dst += 4;
lenremaining -= 4;
}
if (sd->service_tunnel == SERVICE_TUNNEL_SSL)
tunnel_prefix = "ssl/";
else
tunnel_prefix = "";
if (sd->name && (sd->service_tunnel != SERVICE_TUNNEL_SSL ||
sd->dtype == SERVICE_DETECTION_PROBED)) {
if (sd->name != NULL && strcmp(sd->name, "unknown") != 0) {
/* The port has a name and the name is not "unknown". How confident are we? */
if (o.servicescan && state == PORT_OPEN && sd->name_confidence <= 5)
len = Snprintf(dst, lenremaining, "%s?", sd->name);
else len = Snprintf(dst, lenremaining, "%s", sd->name);
len = Snprintf(namebuf, buflen, "%s%s?", tunnel_prefix, sd->name);
else
len = Snprintf(namebuf, buflen, "%s%s", tunnel_prefix, sd->name);
} else {
len = Snprintf(dst, lenremaining, "%s", "unknown");
len = Snprintf(namebuf, buflen, "%sunknown", tunnel_prefix);
}
if (len > lenremaining || len < 0) goto overflow;
dst += len;
lenremaining -= len;
if (lenremaining < 1) goto overflow;
*dst = '\0';
return;
overflow:
*namebuf = '\0';
if (len >= buflen || len < 0)
namebuf[0] = '\0';
}
#ifndef NOLUA