Home page logo

nmap-dev logo Nmap Development mailing list archives

Re: Review: Angry IP Scanner
From: Brandon Enright <bmenrigh () ucsd edu>
Date: Fri, 6 Jun 2008 08:12:31 +0000

Hash: SHA1

On Fri, 6 Jun 2008 00:28:31 -0700 or thereabouts doug () hcsw org wrote:

On Fri, Jun 06, 2008 at 02:05:52AM +0000 or thereabouts, Brandon
Enright wrote:
I'm not aware of any generic algorithm, method, or technique that
could generate numbers in some arbitrary set of ranges without
duplicates that is both fast and memory efficient.

Out-of-core sorting. Here's what I do if I need a random ordering of
10+ million records:

cat input | perl -ne 'print int(rand()*99999999)." $_"' | sort -n |
perl -ne 's/^\d+ // and print' > output

I call it the frax0r-shuffle (tm) patentz pending all rights
reserved ;)


PS. There are ways of pipelining operations in and improving disk
IO but I think I've given the script kidz too much info already.

Hi Doug,

Creative.  I'd say though that prepending a random number to your
target list to sort isn't memory efficient.  Even if Gnu sort is good
about sorting in chunks, you still need your entire list to be sorted
stored somewhere.

The problem I was getting at is this:

Say you wanted to scan 5000 random IPs from:


Note that I don't intend the /24 get 1/2 of the scans, I mean it
should get 1/256 of the target IPs.  It may be reasonable to randomly
sort 65536+256 IPs and then pick from the top.  It wouldn't be
reasonable though if you wanted to scan 5000 out of

Even if duplicates were fine, I can't think of a very clean way to
generate numbers uniformly in a set of ranges like that.  There is a
clean solution if the ranges are on nice power-of-two boundaries like
the example above but random IPs in uglier ranges like:


Start to get rather messy.

One way to do it would be to limit to one specified range at a time and
allow for a bit mask (CIDR would be optional short-hand).

a.b.0.0/ (a /16)

Or a messier but just as easy to implement range:

We /could/ solve this and implement it but we'd be taking care of a
pretty rare edge-case.  -sL and random sorting is probably best despite
its drawbacks.


Version: GnuPG v2.0.9 (GNU/Linux)


Sent through the nmap-dev mailing list
Archived at http://SecLists.Org

  By Date           By Thread  

Current thread:
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]