From cfd1c5fe654104edb2561f8585b4ff9447672310 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 2 Jul 2014 15:35:12 +0000 Subject: [PATCH] Set reasons when connect() comes back immediately In sendConnectScanProbe, the usual method is to start a non-blocking connect() and then do select() on the sockets until we get a result. On some platforms and in some circumstances, connect() either blocks or comes back immediately. We handled this by setting the port state appropriately, but we didn't set the reason, yielding results like "Host is up, received no-response" and "80/tcp open http no-response" --- scan_engine.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scan_engine.cc b/scan_engine.cc index ccab7a86b..65c475ce7 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -3209,12 +3209,15 @@ static UltraProbe *sendConnectScanProbe(UltraScanInfo *USI, HostScanStats *hss, /* Connection succeeded! */ if (USI->ping_scan) { ultrascan_host_probe_update(USI, hss, probeI, HOST_UP, &USI->now); + hss->target->reason.reason_id = ER_CONACCEPT; /* If the host is up, we can forget our other probes. */ hss->destroyAllOutstandingProbes(); } else if (probe->isPing()) ultrascan_ping_update(USI, hss, probeI, &USI->now); - else + else { ultrascan_port_probe_update(USI, hss, probeI, PORT_OPEN, &USI->now); + hss->target->ports.setStateReason(probe->pspec()->pd.tcp.dport, probe->protocol(), ER_CONACCEPT, 0, NULL); + } probe = NULL; } else if (connect_errno == EINPROGRESS || connect_errno == EAGAIN) { USI->gstats->CSI->watchSD(CP->sd); @@ -3260,6 +3263,7 @@ static UltraProbe *sendConnectScanProbe(UltraScanInfo *USI, HostScanStats *hss, hss->destroyAllOutstandingProbes(); } else if (!USI->ping_scan && port_state != PORT_UNKNOWN) { ultrascan_port_probe_update(USI, hss, probeI, port_state, &USI->now); + hss->target->ports.setStateReason(probe->pspec()->pd.tcp.dport, probe->protocol(), port_state, 0, NULL); } else { hss->destroyOutstandingProbe(probeI); }