From 7a84920e63213178235d424cb8e0a1296a06d588 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 1 May 2009 20:51:52 +0000 Subject: [PATCH] Put some conditions like o.idlescan and o.bouncescan outside of the loops that iterate over targets, not inside them. That prevents having to iterate over every target doing nothing in the common case when those scan types aren't used. --- nmap.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/nmap.cc b/nmap.cc index a3b92128e..09b79554b 100644 --- a/nmap.cc +++ b/nmap.cc @@ -1765,19 +1765,20 @@ int nmap_main(int argc, char *argv[]) { ultra_scan(Targets, &ports, IPPROT_SCAN); /* These lame functions can only handle one target at a time */ - for(targetno = 0; targetno < Targets.size(); targetno++) { - currenths = Targets[targetno]; - if (o.idlescan) { + if (o.idlescan) { + for(targetno = 0; targetno < Targets.size(); targetno++) { o.current_scantype = IDLE_SCAN; keyWasPressed(); // Check if a status message should be printed - idle_scan(currenths, ports.tcp_ports, + idle_scan(Targets[targetno], ports.tcp_ports, ports.tcp_count, idleProxy, &ports); } - if (o.bouncescan) { + } + if (o.bouncescan) { + for(targetno = 0; targetno < Targets.size(); targetno++) { o.current_scantype = BOUNCE_SCAN; keyWasPressed(); // Check if a status message should be printed if (ftp.sd <= 0) ftp_anon_connect(&ftp); - if (ftp.sd > 0) bounce_scan(currenths, ports.tcp_ports, + if (ftp.sd > 0) bounce_scan(Targets[targetno], ports.tcp_ports, ports.tcp_count, &ftp); } } @@ -1797,15 +1798,15 @@ int nmap_main(int argc, char *argv[]) { troute->resolveHops(); } - for(targetno = 0; targetno < Targets.size(); targetno++) { - currenths = Targets[targetno]; - + if (o.servicescan || o.rpcscan) { /* This scantype must be after any TCP or UDP scans since it * get's it's port scan list from the open port list of the current * host rather than port list the user specified. */ - if (o.servicescan || o.rpcscan) pos_scan(currenths, NULL, 0, RPC_SCAN); - } + for(targetno = 0; targetno < Targets.size(); targetno++) + pos_scan(Targets[targetno], NULL, 0, RPC_SCAN); + } + #ifndef NOLUA if(o.script || o.scriptversion) { script_scan(Targets);