mirror of
https://github.com/nmap/nmap.git
synced 2026-01-05 22:19:03 +00:00
Only change the port state to PORT_OPEN during service scan if it is not
already open. Rob Nicholls pointed out that setting the state unconditionally results in multiple messages per port: Discovered open port 3389/tcp Discovered open port 3389/tcp Discovered open port 3389/tcp Discovered open port 3389/tcp This is because setPortState has the side effect of printing a message.
This commit is contained in:
@@ -1700,13 +1700,13 @@ static void adjustPortStateIfNeccessary(ServiceNFO *svc) {
|
||||
char host[128];
|
||||
|
||||
oldstate = svc->target->ports.getPortState(svc->portno, svc->proto);
|
||||
svc->target->ports.setPortState(svc->portno, svc->proto, PORT_OPEN);
|
||||
if (svc->proto == IPPROTO_TCP)
|
||||
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_TCPRESPONSE, 0, 0);
|
||||
if (svc->proto == IPPROTO_UDP)
|
||||
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_UDPRESPONSE, 0, 0);
|
||||
|
||||
if (oldstate != PORT_OPEN) {
|
||||
svc->target->ports.setPortState(svc->portno, svc->proto, PORT_OPEN);
|
||||
if (svc->proto == IPPROTO_TCP)
|
||||
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_TCPRESPONSE, 0, 0);
|
||||
if (svc->proto == IPPROTO_UDP)
|
||||
svc->target->ports.setStateReason(svc->portno, svc->proto, ER_UDPRESPONSE, 0, 0);
|
||||
|
||||
if (o.verbose || o.debugging > 1) {
|
||||
svc->target->NameIP(host, sizeof(host));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user