fix: guard _ping() against proxy-ARP false positives
Verify that the ICMP reply source IP matches the target before reporting a host as alive. Prevents scan from returning the entire CIDR range when a gateway answers ARP requests on behalf of all IPs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,12 @@ def _ping(ip: str) -> bool:
|
||||
capture_output=True,
|
||||
timeout=3,
|
||||
)
|
||||
return r.returncode == 0
|
||||
if r.returncode != 0:
|
||||
return False
|
||||
# Guard against proxy-ARP / gateway false positives: verify the ICMP
|
||||
# reply actually came from the target IP and not an intermediate node.
|
||||
stdout = r.stdout.decode(errors="ignore")
|
||||
return f"from {ip}:" in stdout or f"from {ip} " in stdout
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user