Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: Stupid patch... autostat every x seconds
From: David Fifield <david () bamsoftware com>
Date: Mon, 16 Feb 2009 17:52:12 -0700

On Tue, Jan 06, 2009 at 10:28:33PM +0100, Aleksandar Petrinic wrote:
Now I have write a very little patch for nmap that enables another option...
--auto-stats <seconds> that print a stats every <seconds> seconds.
I don't know if it could be usefull for someone, but I have tried. The diff
is in the attachment.

Well, maybe it's not the cleaner, but works(it isn't much accurate too). One
thing that confuse me it's where I have to put a temporary global variable,
for now I put it in the NmapOps, even if I immagine that it's not properly
the right place. With this patch I can syncronize a progress bar with nmap's
stats fine.

I made another patch, based on yours, with a few changes. I changed the
option name to --stats-every. It takes a time specification like all the
other timing options, defaulting to milliseconds and allowing a 's',
'm', 'h' suffix. This implementation only adds one new member to
NmapOps. State is limited to the scope of one function. The scheduler is
accurate. Output goes all the same places it normally goes when you
press a key, including XML output. It looks like

$ nmap scanme.nmap.org -p- --stats-every 5s

Starting Nmap 4.85BETA3 ( http://nmap.org ) at 2009-02-16 17:45 MST
Stats: 0:00:05 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 0.83% done
Stats: 0:00:10 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 1.63% done; ETC: 17:55 (0:10:02 remaining)
Stats: 0:00:15 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 3.24% done; ETC: 17:53 (0:07:27 remaining)
Stats: 0:00:20 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 5.32% done; ETC: 17:51 (0:05:56 remaining)
Stats: 0:00:25 elapsed; 0 hosts completed (1 up), 1 undergoing Connect Scan
Connect Scan Timing: About 7.76% done; ETC: 17:50 (0:04:57 remaining)

What do you all think? What's your opinion of the option name?
--stats-every maybe doesn't make sense in isolation but it works really
well if you read the command to yourself. My primary misgiving is
putting this in the function keyWasPressed in nmap_tty.cc. That function
already does more than its name suggests:
  1. Check for a keypress.
  2. If it's one of the runtime interaction keys, do the corresponding
     function and return false.
  3. If not, print a global status message and return true, indicating
     that the caller should print a status message too.
But the way in which keyWasPressed is used:
  if (keyWasPressed()) {
    USI->SPM->printStats(USI->getCompletionFraction(), NULL);
  }
made it hard to find a better name.

David Fifield

Attachment: stats-every.diff
Description:


_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

  By Date           By Thread  

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