mirror of
https://github.com/nmap/nmap.git
synced 2025-12-09 14:11:29 +00:00
Added diman's portlist changes
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
# Nmap Changelog ($Id$); -*-text-*-
|
# Nmap Changelog ($Id$); -*-text-*-
|
||||||
|
|
||||||
|
o portlist.cc was refactored to remove some code duplication. Thanks
|
||||||
|
to Diman Todorov for the patch.
|
||||||
|
|
||||||
Nmap 4.11
|
Nmap 4.11
|
||||||
|
|
||||||
o Added a dozens of more detailed SSH version detection signatures, thanks
|
o Added a dozens of more detailed SSH version detection signatures, thanks
|
||||||
|
|||||||
109
portlist.cc
109
portlist.cc
@@ -264,6 +264,29 @@ int Port::getServiceDeductions(struct serviceDeductions *sd) {
|
|||||||
// one is available and the user should submit it. tunnel must be
|
// one is available and the user should submit it. tunnel must be
|
||||||
// SERVICE_TUNNEL_NULL (normal) or SERVICE_TUNNEL_SSL (means ssl was
|
// SERVICE_TUNNEL_NULL (normal) or SERVICE_TUNNEL_SSL (means ssl was
|
||||||
// detected and we tried to tunnel through it ).
|
// detected and we tried to tunnel through it ).
|
||||||
|
|
||||||
|
char* Port::cstringSanityCheck(const char* string, int len) {
|
||||||
|
char* result;
|
||||||
|
int slen;
|
||||||
|
unsigned char *p;
|
||||||
|
|
||||||
|
if(!string)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
slen = strlen(string);
|
||||||
|
if (slen > len) slen = len;
|
||||||
|
result = (char *) safe_malloc(slen + 1);
|
||||||
|
memcpy(result, string, slen);
|
||||||
|
result[slen] = '\0';
|
||||||
|
p = (unsigned char *) result;
|
||||||
|
while(*p) {
|
||||||
|
if (!isprint((int)*p)) *p = '.';
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void Port::setServiceProbeResults(enum serviceprobestate sres,
|
void Port::setServiceProbeResults(enum serviceprobestate sres,
|
||||||
const char *sname,
|
const char *sname,
|
||||||
enum service_tunnel_type tunnel,
|
enum service_tunnel_type tunnel,
|
||||||
@@ -272,91 +295,17 @@ void Port::setServiceProbeResults(enum serviceprobestate sres,
|
|||||||
const char *ostype, const char *devicetype,
|
const char *ostype, const char *devicetype,
|
||||||
const char *fingerprint) {
|
const char *fingerprint) {
|
||||||
|
|
||||||
int slen;
|
|
||||||
serviceprobe_results = sres;
|
serviceprobe_results = sres;
|
||||||
unsigned char *p;
|
|
||||||
serviceprobe_tunnel = tunnel;
|
serviceprobe_tunnel = tunnel;
|
||||||
if (sname) serviceprobe_service = strdup(sname);
|
if (sname) serviceprobe_service = strdup(sname);
|
||||||
if (fingerprint) serviceprobe_fp = strdup(fingerprint);
|
if (fingerprint) serviceprobe_fp = strdup(fingerprint);
|
||||||
|
|
||||||
if (product) {
|
serviceprobe_product = cstringSanityCheck(product, 64);
|
||||||
slen = strlen(product);
|
serviceprobe_version = cstringSanityCheck(version, 64);
|
||||||
if (slen > 64) slen = 64;
|
serviceprobe_extrainfo = cstringSanityCheck(extrainfo, 128);
|
||||||
serviceprobe_product = (char *) safe_malloc(slen + 1);
|
serviceprobe_hostname = cstringSanityCheck(hostname, 64);
|
||||||
memcpy(serviceprobe_product, product, slen);
|
serviceprobe_ostype = cstringSanityCheck(ostype, 64);
|
||||||
serviceprobe_product[slen] = '\0';
|
serviceprobe_devicetype = cstringSanityCheck(devicetype, 64);
|
||||||
p = (unsigned char *) serviceprobe_product;
|
|
||||||
while(*p) {
|
|
||||||
if (!isprint((int)*p)) *p = '.';
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version) {
|
|
||||||
slen = strlen(version);
|
|
||||||
if (slen > 64) slen = 64;
|
|
||||||
serviceprobe_version = (char *) safe_malloc(slen + 1);
|
|
||||||
memcpy(serviceprobe_version, version, slen);
|
|
||||||
serviceprobe_version[slen] = '\0';
|
|
||||||
p = (unsigned char *) serviceprobe_version;
|
|
||||||
while(*p) {
|
|
||||||
if (!isprint((int)*p)) *p = '.';
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extrainfo) {
|
|
||||||
slen = strlen(extrainfo);
|
|
||||||
if (slen > 128) slen = 128;
|
|
||||||
serviceprobe_extrainfo = (char *) safe_malloc(slen + 1);
|
|
||||||
memcpy(serviceprobe_extrainfo, extrainfo, slen);
|
|
||||||
serviceprobe_extrainfo[slen] = '\0';
|
|
||||||
p = (unsigned char *) serviceprobe_extrainfo;
|
|
||||||
while(*p) {
|
|
||||||
if (!isprint((int)*p)) *p = '.';
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hostname) {
|
|
||||||
slen = strlen(hostname);
|
|
||||||
if (slen > 64) slen = 64;
|
|
||||||
serviceprobe_hostname = (char *) safe_malloc(slen + 1);
|
|
||||||
memcpy(serviceprobe_hostname, hostname, slen);
|
|
||||||
serviceprobe_hostname[slen] = '\0';
|
|
||||||
p = (unsigned char *) serviceprobe_hostname;
|
|
||||||
while(*p) {
|
|
||||||
if (!isprint((int)*p)) *p = '.';
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ostype) {
|
|
||||||
slen = strlen(ostype);
|
|
||||||
if (slen > 64) slen = 64;
|
|
||||||
serviceprobe_ostype = (char *) safe_malloc(slen + 1);
|
|
||||||
memcpy(serviceprobe_ostype, ostype, slen);
|
|
||||||
serviceprobe_ostype[slen] = '\0';
|
|
||||||
p = (unsigned char *) serviceprobe_ostype;
|
|
||||||
while(*p) {
|
|
||||||
if (!isprint((int)*p)) *p = '.';
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (devicetype) {
|
|
||||||
slen = strlen(devicetype);
|
|
||||||
if (slen > 64) slen = 64;
|
|
||||||
serviceprobe_devicetype = (char *) safe_malloc(slen + 1);
|
|
||||||
memcpy(serviceprobe_devicetype, devicetype, slen);
|
|
||||||
serviceprobe_devicetype[slen] = '\0';
|
|
||||||
p = (unsigned char *) serviceprobe_devicetype;
|
|
||||||
while(*p) {
|
|
||||||
if (!isprint((int)*p)) *p = '.';
|
|
||||||
p++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sets the results of an RPC scan. if rpc_status is not
|
/* Sets the results of an RPC scan. if rpc_status is not
|
||||||
|
|||||||
@@ -208,6 +208,8 @@ class Port {
|
|||||||
const char *ostype, const char *devicetype,
|
const char *ostype, const char *devicetype,
|
||||||
const char *extrainfo, const char *fingerprint);
|
const char *extrainfo, const char *fingerprint);
|
||||||
|
|
||||||
|
char* cstringSanityCheck(const char* string, int len);
|
||||||
|
|
||||||
/* Sets the results of an RPC scan. if rpc_status is not
|
/* Sets the results of an RPC scan. if rpc_status is not
|
||||||
RPC_STATUS_GOOD_PROGRAM, pass 0 for the other args. This function
|
RPC_STATUS_GOOD_PROGRAM, pass 0 for the other args. This function
|
||||||
takes care of setting the port's service and version
|
takes care of setting the port's service and version
|
||||||
|
|||||||
Reference in New Issue
Block a user