1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Ensure all UDP payloads get sent before giving up on a port.

This commit is contained in:
dmiller
2021-01-18 22:23:55 +00:00
parent 58617a79f7
commit 6310b7d9e3
3 changed files with 21 additions and 1 deletions

View File

@@ -363,3 +363,17 @@ const char *get_udp_payload(u16 dport, size_t *length, u8 tryno) {
return udp_port2payload(dport, length, tryno);
}
}
size_t udp_payload_count(u16 dport) {
std::map<struct proto_dport, std::vector<struct payload> >::iterator portPayloadIterator;
proto_dport key(IPPROTO_UDP, dport);
size_t portPayloadVectorSize = 0;
portPayloadIterator = portPayloads.find(key);
if (portPayloadIterator != portPayloads.end()) {
portPayloadVectorSize = portPayloadIterator->second.size();
}
return portPayloadVectorSize;
}

View File

@@ -68,6 +68,7 @@
const char *get_udp_payload(u16 dport, size_t *length, u8 tryno);
const char *udp_port2payload(u16 dport, size_t *length, u8 tryno);
size_t udp_payload_count(u16 dport);
int init_payloads(void);
#endif /* PAYLOAD_H */

View File

@@ -2454,7 +2454,12 @@ static void doAnyOutstandingRetransmits(UltraScanInfo *USI) {
probeI--;
probe = *probeI;
if (probe->timedout && !probe->retransmitted &&
maxtries > probe->tryno && !probe->isPing()) {
(maxtries > probe->tryno ||
// We may exceed maxtries if this is UDP...
((USI->udp_scan || (USI->ping_scan && USI->ptech.rawudpscan))
// ...and there are more payloads we haven't tried.
&& udp_payload_count(probe->dport()) > probe->tryno)
) && !probe->isPing()) {
/* For rate limit detection, we delay the first time a new tryno
is seen, as long as we are scanning at least 2 ports */
if (probe->tryno + 1 > (int) host->rld.max_tryno_sent &&