diff -urpb nmap-3.78/nmap.cc nmap-3.78mm/nmap.cc --- nmap-3.78/nmap.cc 2004-12-12 01:46:18.000000000 +0100 +++ nmap-3.78mm/nmap.cc 2004-12-19 13:30:43.000000000 +0100 @@ -254,6 +254,7 @@ int nmap_main(int argc, char *argv[]) { {"host_timeout", required_argument, 0, 0}, {"scan_delay", required_argument, 0, 0}, {"max_scan_delay", required_argument, 0, 0}, + {"max_retransmissions", required_argument, 0, 0}, {"oA", required_argument, 0, 0}, {"oN", required_argument, 0, 0}, {"oM", required_argument, 0, 0}, @@ -408,6 +409,11 @@ int nmap_main(int argc, char *argv[]) { } o.setMaxTCPScanDelay(scand); o.setMaxUDPScanDelay(scand); + } else if (strcmp(long_options[option_index].name, "max_retransmissions") == 0) { + int num_retrans = atoi(optarg); + if (num_retrans < 1) + fatal("max_retransmissions must be at least 1"); + o.setMaxRetransmissions(num_retrans); } else if (strcmp(long_options[option_index].name, "randomize_hosts") == 0 || strcmp(long_options[option_index].name, "rH") == 0) { o.randomize_hosts = 1; @@ -713,6 +719,7 @@ int nmap_main(int argc, char *argv[]) { o.setMaxRttTimeout(1250); o.setInitialRttTimeout(500); o.setMaxTCPScanDelay(10); + o.setMaxRetransmissions(4); } else if (*optarg == '5' || (strcasecmp(optarg, "Insane") == 0)) { o.timing_level = 5; o.setMinRttTimeout(50); @@ -720,6 +727,7 @@ int nmap_main(int argc, char *argv[]) { o.setInitialRttTimeout(250); o.host_timeout = 900000; o.setMaxTCPScanDelay(5); + o.setMaxRetransmissions(2); } else { fatal("Unknown timing mode (-T argment). Use either \"Paranoid\", \"Sneaky\", \"Polite\", \"Normal\", \"Aggressive\", \"Insane\" or a number from 0 (Paranoid) to 5 (Insane)"); } diff -urpb nmap-3.78/nmap.h nmap-3.78mm/nmap.h --- nmap-3.78/nmap.h 2004-10-18 18:59:37.000000000 +0200 +++ nmap-3.78mm/nmap.h 2004-12-19 13:30:43.000000000 +0100 @@ -327,6 +327,10 @@ void *realloc(); #define INITIAL_RTT_TIMEOUT 1000 /* Allow 1 second initially for packet responses */ #define HOST_TIMEOUT 0 /* By default allow unlimited time to scan each host */ +#ifndef MAX_RETRANSMISSIONS +#define MAX_RETRANSMISSIONS 9 /* 10 probes to port at maximum */ +#endif + /* If nmap is called with one of the names below, it will start up in interactive mode -- alternatively, you can rename Nmap any of the following names to have it start up interactivey by default. */ #define INTERACTIVE_NAMES { "BitchX", "Calendar", "X", "awk", "bash", "bash2", "calendar", "cat", "csh", "elm", "emacs", "ftp", "fvwm", "g++", "gcc", "gimp", "httpd", "irc", "man", "mutt", "nc", "ncftp", "netscape", "perl", "pine", "ping", "sleep", "slirp", "ssh", "sshd", "startx", "tcsh", "telnet", "telnetd", "tia", "top", "vi", "vim", "xdvi", "xemacs", "xterm", "xv" } diff -urpb nmap-3.78/NmapOps.cc nmap-3.78mm/NmapOps.cc --- nmap-3.78/NmapOps.cc 2004-12-19 13:38:06.000000000 +0100 +++ nmap-3.78mm/NmapOps.cc 2004-12-19 13:37:27.000000000 +0100 @@ -205,6 +205,7 @@ void NmapOps::Initialize() { max_rtt_timeout = MAX_RTT_TIMEOUT; min_rtt_timeout = MIN_RTT_TIMEOUT; initial_rtt_timeout = INITIAL_RTT_TIMEOUT; + max_retransmissions = MAX_RETRANSMISSIONS; min_host_group_sz = 1; max_host_group_sz = 100000; // don't want to be restrictive unles user sets max_tcp_scan_delay = MAX_TCP_SCAN_DELAY; @@ -440,6 +441,14 @@ void NmapOps::setInitialRttTimeout(int r if (rtt < min_rtt_timeout) min_rtt_timeout = rtt; } +void NmapOps::setMaxRetransmissions(int max_retransmit) +{ + if (max_retransmit < 1) + fatal("NmapOps::setMaxRetransmissions(): minimal value is 1"); + max_retransmissions = max_retransmit; +} + + void NmapOps::setMinHostGroupSz(unsigned int sz) { if (sz > max_host_group_sz) fatal("Minimum host group size may not be set to greater than maximum size (currently %d)\n", max_host_group_sz); diff -urpb nmap-3.78/NmapOps.h nmap-3.78mm/NmapOps.h --- nmap-3.78/NmapOps.h 2004-10-18 18:59:36.000000000 +0200 +++ nmap-3.78mm/NmapOps.h 2004-12-19 13:30:43.000000000 +0100 @@ -176,6 +176,8 @@ class NmapOps { void setMaxRttTimeout(int rtt); void setMinRttTimeout(int rtt); void setInitialRttTimeout(int rtt); + void setMaxRetransmissions(int max_retransmit); + int getMaxRetransmissions() { return max_retransmissions; } /* Similar functions for Host group size */ int minHostGroupSz() { return min_host_group_sz; } @@ -242,6 +244,7 @@ class NmapOps { int max_rtt_timeout; int min_rtt_timeout; int initial_rtt_timeout; + int max_retransmissions; unsigned int max_tcp_scan_delay; unsigned int max_udp_scan_delay; unsigned int min_host_group_sz; diff -urpb nmap-3.78/scan_engine.cc nmap-3.78mm/scan_engine.cc --- nmap-3.78/scan_engine.cc 2004-11-24 21:13:01.000000000 +0100 +++ nmap-3.78mm/scan_engine.cc 2004-12-19 13:30:43.000000000 +0100 @@ -913,7 +913,7 @@ static void init_perf_values(struct ultr perf->group_drop_cwnd_divisor = 2.0; perf->group_drop_ccthresh_divisor = (o.timing_level < 4)? 2.0 : 1.5; perf->host_drop_ccthresh_divisor = (o.timing_level < 4)? 2.0 : 1.5; - perf->tryno_cap = 12; + perf->tryno_cap = o.getMaxRetransmissions(); } /* Order of initializations in this function CAN BE IMPORTANT, so be careful