From 3bce03ad8dad4ce85dfad1095cb8a14a55eee451 Mon Sep 17 00:00:00 2001 From: bmenrigh Date: Wed, 2 Sep 2009 02:03:22 +0000 Subject: [PATCH] This commit adds a new routine to nbase_rnd.c that generates 32bit numbers in a collision-free way for a full 2^32 cycle. This allows Nmap to generate random IPs with -iR that don't have duplicates. See: http://seclists.org/nmap-dev/2009/q3/0695.html How this is done is documented in the code. --- nmap.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nmap.cc b/nmap.cc index 2ab5b4677..4cac84af2 100644 --- a/nmap.cc +++ b/nmap.cc @@ -425,7 +425,7 @@ static char *grab_next_host_spec(FILE *inputfd, int argc, char **fakeargv) { if (o.generate_random_ips) { do { - ip.s_addr = get_random_u32(); + ip.s_addr = get_random_unique_u32(); } while (ip_is_reserved(&ip)); Strncpy(host_spec, inet_ntoa(ip), sizeof(host_spec)); } else if (!inputfd) {