1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-25 08:59:01 +00:00

Merging my UDP localhost patch. It fixes the UDP scan on localhost picking up it's own port. It also fixes the TCP one so that it doesn't print a message (with -d) about receiving a response with unexpected flags (like getting a SYN for a SYN scan because it's our port). The problem was that the IP ID wasn't ntohs()'d while checking for this, so we still saw our port on UDP. I simply copied this to the TCP part to avoid the message.

This commit is contained in:
kris
2007-01-20 22:15:49 +00:00
parent 6da0b2a534
commit 24e30769e8

View File

@@ -2957,6 +2957,13 @@ static bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
} else if (USI->scantype == ACK_SCAN) {
newstate = PORT_UNFILTERED;
} else newstate = PORT_CLOSED;
} else if (probe->dport() == probe->sport() &&
ip->ip_src.s_addr == ip->ip_dst.s_addr &&
probe->ipid() == ntohs(ip->ip_id)) {
/* Sometimes we get false results when scanning localhost with
-p- because we scan localhost with src port = dst port and
see our outgoing packet and think it is a response. */
continue;
} else {
if (o.debugging)
error("Received scan response with unexpected TCP flags: %d\n", tcp->th_flags);
@@ -3120,7 +3127,7 @@ static bool get_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
see our outgoing packet and think it is a response. */
if (probe->dport() == probe->sport() &&
ip->ip_src.s_addr == ip->ip_dst.s_addr &&
probe->ipid() == ip->ip_id)
probe->ipid() == ntohs(ip->ip_id))
continue; /* We saw the packet we ourselves sent */
newstate = PORT_OPEN;