Nmap Development mailing list archives
[PATCH] Fix error message for -sO -p [>255]
From: Kris Katterjohn <katterjohn () gmail com>
Date: Sun, 17 Dec 2006 19:00:40 -0600
The attached patch fixes an error message bug when scanning IP protocols and the only protocol numbers specified are > 255. It was quitting with the "No ports specified" message because it just excluded anything >255 and if all the protocol numbers were over (even if only one is give), it failed to exit and just eventually hit an if() that gives a wrong message. If one number was <256 and others weren't, it just dropped them without saying anything. I don't know if my patch accomplishes it the best way possible, but it seems to work for it just fine. It's a diff against 4.21ALPHA1 Thanks, Kris Katterjohn
--- x/nmap.cc 2006-12-10 18:34:36.000000000 -0600 +++ y/nmap.cc 2006-12-17 18:47:54.000000000 -0600 @@ -1903,8 +1903,12 @@ struct scan_lists *getpts(char *origexpr } else if (isdigit((int) *current_range)) { rangestart = strtol(current_range, &endptr, 10); - if (rangestart < 0 || rangestart > 65535) { - fatal("Ports to be scanned must be between 0 and 65535 inclusive"); + if (o.ipprotscan) { + if (rangestart < 0 || rangestart > 255) + fatal("Protocols to be scanned must be between 0 and 255 inclusive"); + } else { + if (rangestart < 0 || rangestart > 65535) + fatal("Ports to be scanned must be between 0 and 65535 inclusive"); } /* if (rangestart == 0) { error("WARNING: Scanning \"port 0\" is supported, but unusual."); @@ -1925,8 +1929,12 @@ struct scan_lists *getpts(char *origexpr rangeend = 65535; } else if (isdigit((int) *current_range)) { rangeend = strtol(current_range, &endptr, 10); - if (rangeend < 0 || rangeend > 65535) { - fatal("Ports to be scanned must be between 0 and 65535 inclusive"); + if (o.ipprotscan) { + if (rangeend < 0 || rangeend > 255) + fatal("Protocols to be scanned must be between 0 and 255 inclusive"); + } else { + if (rangeend < 0 || rangeend > 65535) + fatal("Ports to be scanned must be between 0 and 65535 inclusive"); } current_range = endptr; } else { @@ -1948,7 +1956,7 @@ struct scan_lists *getpts(char *origexpr tcpportcount++; if (range_type & SCAN_UDP_PORT) udpportcount++; - if (range_type & SCAN_PROTOCOLS && rangestart < 256) + if (range_type & SCAN_PROTOCOLS) protcount++; porttbl[rangestart] |= range_type; }
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- [PATCH] Fix error message for -sO -p [>255] Kris Katterjohn (Dec 17)