1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-01 20:39:02 +00:00

Better handling for ICMP Host Unreachable

This commit is contained in:
dmiller
2020-10-29 23:02:30 +00:00
parent 15726a0be1
commit 9ac591f9db
3 changed files with 47 additions and 27 deletions

View File

@@ -2014,8 +2014,8 @@ static bool ultrascan_host_pspec_update(UltraScanInfo *USI, HostScanStats *hss,
int oldstate = hss->target->flags;
/* If the host is already up, ignore any further updates. */
if (hss->target->flags != HOST_UP) {
assert(newstate == HOST_UP || newstate == HOST_DOWN);
hss->target->flags = newstate;
// don't allow HOST_UNKNOWN to override a known state.
hss->target->flags = (newstate == HOST_UNKNOWN ? oldstate : newstate);
/* For port scans (not -sn) where output may be delayed until more scan
* phases are done, emit a hosthint element during host discovery when a
* target is found to be up. */
@@ -2066,12 +2066,12 @@ void ultrascan_host_probe_update(UltraScanInfo *USI, HostScanStats *hss,
bool adjust_timing = adjust_timing_hint;
bool adjust_ping = adjust_timing_hint;
/* If we got a response that meant "down", then it was an ICMP error. These
/* If we got a response that meant "down" or "unknown", then it was an ICMP error. These
are often rate-limited (RFC 1812) or generated by a different host. We only
allow such responses to increase, not decrease, scanning speed by
disallowing drops (probe->tryno > 0), and we don't allow changing the ping
probe to something that's likely to get dropped. */
if (rcvdtime != NULL && newstate == HOST_DOWN) {
if (rcvdtime != NULL && newstate != HOST_UP) {
if (probe->tryno > 0) {
if (adjust_timing && o.debugging > 1)
log_write(LOG_PLAIN, "Response for %s means new state is down; not adjusting timing.\n", hss->target->targetipstr());