From db328f191fbebde2019a7a076932f9e6d8f04c5b Mon Sep 17 00:00:00 2001 From: david Date: Fri, 30 Apr 2010 17:21:38 +0000 Subject: [PATCH] Look up the service name whenever service detection doesn't find a match, not only for PROBESTATE_EXCLUDED. Otherwise a serviceDeductions gets allocated but its name doesn't get set. Later, when a serviceDeductions is present with no name, XML output doesn't print the service element. --- portlist.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/portlist.cc b/portlist.cc index 05ec7dfa7..06ca20dce 100644 --- a/portlist.cc +++ b/portlist.cc @@ -330,7 +330,15 @@ void PortList::setServiceProbeResults(u16 portno, int protocol, || sres == PROBESTATE_FINISHED_SOFTMATCHED) { port->service->dtype = SERVICE_DETECTION_PROBED; port->service->name_confidence = 10; - } else if (sres == PROBESTATE_EXCLUDED) { + } else if (sres == PROBESTATE_FINISHED_TCPWRAPPED) { + port->service->dtype = SERVICE_DETECTION_PROBED; + if (sname == NULL) + sname = "tcpwrapped"; + port->service->dtype = SERVICE_DETECTION_TABLE; + port->service->name_confidence = 8; + } else { + /* PROBESTATE_FINISHED_NOMATCH, PROBESTATE_EXCLUDED, PROBESTATE_INCOMPLETE. + Just look up the service name if none is provided. */ if (sname == NULL) { struct servent *service; service = nmap_getservbyport(htons(portno), IPPROTO2STR(protocol)); @@ -339,12 +347,6 @@ void PortList::setServiceProbeResults(u16 portno, int protocol, } port->service->dtype = SERVICE_DETECTION_TABLE; port->service->name_confidence = 2; // Since we didn't even check it, we aren't very confident - } else if (sres == PROBESTATE_FINISHED_TCPWRAPPED) { - port->service->dtype = SERVICE_DETECTION_PROBED; - if (sname == NULL) - sname = "tcpwrapped"; - port->service->dtype = SERVICE_DETECTION_TABLE; - port->service->name_confidence = 8; } // port->serviceprobe_results = sres;