From 25215ce9bac6a7f0302015b353c41cc43436b5df Mon Sep 17 00:00:00 2001 From: david Date: Wed, 30 Jul 2008 00:15:57 +0000 Subject: [PATCH] Add --max-rate to go with --min-rate. --- CHANGELOG | 2 ++ NmapOps.cc | 5 +++++ NmapOps.h | 2 ++ docs/refguide.xml | 29 +++++++++++++++++++++++++++ nmap.cc | 8 +++++++- scan_engine.cc | 51 ++++++++++++++++++++++++++++++++++++++--------- 6 files changed, 87 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ceb0f6562..48d32b52d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -113,6 +113,8 @@ o Nmap's makefile will now install menu items for launching zenmap as o Nmap will no longer misreport a localhost-responce during -PN scans [Michael] +o There is a new --max-rate option complementary to --min-rate. [David] + Nmap 4.68 [2008-6-28] o Doug integrated all of your version detection submissions and diff --git a/NmapOps.cc b/NmapOps.cc index 10ef7cf70..ef273bcdc 100644 --- a/NmapOps.cc +++ b/NmapOps.cc @@ -192,6 +192,7 @@ void NmapOps::Initialize() { debugging = 0; verbose = 0; min_packet_send_rate = 0.0; /* Unset. */ + max_packet_send_rate = 0.0; /* Unset. */ randomize_hosts = 0; sendpref = PACKET_SEND_NOPREF; spoofsource = 0; @@ -443,6 +444,10 @@ void NmapOps::ValidateOptions() { if (max_parallelism && min_parallelism && (min_parallelism > max_parallelism)) { fatal("--min-parallelism=%i must be less than or equal to --max-parallelism=%i",min_parallelism,max_parallelism); } + + if (min_packet_send_rate != 0.0 && max_packet_send_rate != 0.0 && min_packet_send_rate > max_packet_send_rate) { + fatal("--min-rate=%g must be less than or equal to --max-rate=%g", min_packet_send_rate, max_packet_send_rate); + } if (af() == AF_INET6 && (numdecoys|osscan|bouncescan|fragscan|ackscan|finscan|idlescan|ipprotscan|maimonscan|nullscan|synscan|udpscan|windowscan|xmasscan)) { fatal("Sorry -- IPv6 support is currently only available for connect() scan (-sT), ping scan (-sP), and list scan (-sL). OS detection and decoys are also not supported with IPv6. Further support is under consideration."); diff --git a/NmapOps.h b/NmapOps.h index ecdb12b05..a56739dca 100644 --- a/NmapOps.h +++ b/NmapOps.h @@ -180,6 +180,8 @@ class NmapOps { int verbose; /* The requested minimum packet sending rate, or 0.0 if unset. */ float min_packet_send_rate; + /* The requested maximum packet sending rate, or 0.0 if unset. */ + float max_packet_send_rate; int randomize_hosts; int spoofsource; /* -S used */ int fastscan; diff --git a/docs/refguide.xml b/docs/refguide.xml index cd13d429f..dcc2898f7 100644 --- a/docs/refguide.xml +++ b/docs/refguide.xml @@ -2460,6 +2460,35 @@ timing. + + + + (Specify a maximum scanning rate) + + + + +Complementary to is +, which limits a scan's sending rate to a +given maximum. Use , for example, to +limit sending to 100 packets per second on a fast network. Use + for a slow scan of one packet every ten +seconds. + +, like , is +a global option affecting an entire scan. It affects only port and host +discovery scans. Unlike , which is a +best-effort option, is a hard +upper bound on the scanning rate. + +Nmap may go slower than the maximum rate if conditions require it. +To keep the sending rate within a specified range, use + and +together. + + + + diff --git a/nmap.cc b/nmap.cc index 0b2d7fe04..c58ff24ac 100644 --- a/nmap.cc +++ b/nmap.cc @@ -279,6 +279,7 @@ printf("%s %s ( %s )\n" " --host-timeout