From e525388f36de525225ffef8463c67a0047670542 Mon Sep 17 00:00:00 2001 From: dmiller Date: Wed, 23 Jul 2014 22:01:35 +0000 Subject: [PATCH] Make -Pn override all other -P* types This was a case where order of arguments affected the outcome: if -PE came before -Pn, then -Pn took precedence. Otherwise, -PE took precedence (except that o.pingtype would also contain PINGTYPE_NONE... not sure how that affected things). This cleans things up by letting PINGTYPE_NONE be OR'd into o.opingtype, then checking for it after all options have been processed and clearing out the other types if it is found. --- nmap.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nmap.cc b/nmap.cc index 20c33e4ac..a5be648f1 100644 --- a/nmap.cc +++ b/nmap.cc @@ -1145,7 +1145,7 @@ void parse_options(int argc, char **argv) { else if (*optarg == 'P') o.pingtype |= PINGTYPE_ICMP_TS; else if (*optarg == 'n' || *optarg == '0' || *optarg == 'N' || *optarg == 'D') - o.pingtype = PINGTYPE_NONE; + o.pingtype |= PINGTYPE_NONE; else if (*optarg == 'R') o.pingtype |= PINGTYPE_ARP; else if (*optarg == 'S') { @@ -1272,7 +1272,7 @@ void parse_options(int argc, char **argv) { case 'L': o.listscan = 1; o.noportscan = 1; - o.pingtype = PINGTYPE_NONE; + o.pingtype |= PINGTYPE_NONE; break; case 'M': o.maimonscan = 1; @@ -1430,6 +1430,10 @@ void apply_delayed_options() { o.os_labels_ipv6 = load_fp_matches(); } + // Must check and change this before validate_scan_lists + if (o.pingtype & PINGTYPE_NONE) + o.pingtype = PINGTYPE_NONE; + validate_scan_lists(ports, o); o.ValidateOptions();