mirror of
https://github.com/nmap/nmap.git
synced 2025-12-23 16:09:02 +00:00
Unconditionally set the port state to PORT_OPEN when receiving a service
scan response, instead of checking for a current state of PORT_OPENFILTERED. The code calls getPortState, but the port may not have been assigned a state, again because of the new Port allocation architecture, so the function returns -1. It would make sense to have getPortState return the default port state if a Port has not been allocated, but there are two other places it is used where the code relies on it returning -1 to indicate that a port has not received a state yet.
This commit is contained in:
@@ -533,6 +533,9 @@ void PortList::setPortState(u16 portno, u8 protocol, int state) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the current port state, if a Port has been allocated for this port.
|
||||||
|
Returns -1 if the port hasn't had anything about it set yet--in particular,
|
||||||
|
this function does not return the default port state by default. */
|
||||||
int PortList::getPortState(u16 portno, u8 protocol) {
|
int PortList::getPortState(u16 portno, u8 protocol) {
|
||||||
const Port *port;
|
const Port *port;
|
||||||
|
|
||||||
|
|||||||
@@ -1693,25 +1693,25 @@ ServiceGroup::~ServiceGroup() {
|
|||||||
delete SPM;
|
delete SPM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called if data is read for a service or a TCP connection made. If
|
/* Called if data is read for a service or a TCP connection made. Sets the port
|
||||||
the port state is currently PORT_UNFILTERED, changes to
|
state to PORT_OPEN. */
|
||||||
PORT_OPEN. */
|
|
||||||
static void adjustPortStateIfNeccessary(ServiceNFO *svc) {
|
static void adjustPortStateIfNeccessary(ServiceNFO *svc) {
|
||||||
|
int oldstate;
|
||||||
char host[128];
|
char host[128];
|
||||||
|
|
||||||
if (svc->target->ports.getPortState(svc->portno, svc->proto) == PORT_OPENFILTERED) {
|
oldstate = svc->target->ports.getPortState(svc->portno, svc->proto);
|
||||||
svc->target->ports.setPortState(svc->portno, svc->proto, PORT_OPEN);
|
svc->target->ports.setPortState(svc->portno, svc->proto, PORT_OPEN);
|
||||||
if (svc->proto == IPPROTO_TCP)
|
if (svc->proto == IPPROTO_TCP)
|
||||||
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_TCPRESPONSE, 0, 0);
|
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_TCPRESPONSE, 0, 0);
|
||||||
if (svc->proto == IPPROTO_UDP)
|
if (svc->proto == IPPROTO_UDP)
|
||||||
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_UDPRESPONSE, 0, 0);
|
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_UDPRESPONSE, 0, 0);
|
||||||
|
|
||||||
|
if (oldstate != PORT_OPEN) {
|
||||||
if (o.verbose || o.debugging > 1) {
|
if (o.verbose || o.debugging > 1) {
|
||||||
svc->target->NameIP(host, sizeof(host));
|
svc->target->NameIP(host, sizeof(host));
|
||||||
|
|
||||||
log_write(LOG_STDOUT, "Discovered open|filtered port %hu/%s on %s is actually open\n",
|
log_write(LOG_STDOUT, "Discovered %s port %hu/%s on %s is actually open\n",
|
||||||
svc->portno, proto2ascii(svc->proto), host);
|
statenum2str(oldstate), svc->portno, proto2ascii(svc->proto), host);
|
||||||
log_flush(LOG_STDOUT);
|
log_flush(LOG_STDOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user