Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: [NSE] Draft - targets-sniffer.nse
From: David Fifield <david () bamsoftware com>
Date: Mon, 4 Apr 2011 13:38:50 -0700

On Mon, Apr 04, 2011 at 06:53:35PM +0100, Nick Nikolaou wrote:
Good evening folks,

Please find attached the latest version of the targets-sniffer script.

The two main changes are:

- The script prints the IP addresses when the newtargets argument is not
present. It also prints the total number of unique IP addresses and packets
captured.

Thanks Nick, this looks good. But don't use io.write to display
information--the proper way for scripts to communicate is to return a
string. Then it will appear properly labeled and will also go in the XML
output.

The output should look like this:

Pre-scan script results:
| targets-sniffer:
| 192.168.0.1
| 192.168.0.15
| ...
|_192.168.0.100

The script should always return this string, whether newtargets is set
or not. This is as easy as
        return stdnse.format_output(true, all_addresses)
except that you should do the check_if_unique and check_if_valid when
adding an address to all_addresses, not at the end with output.

In check_if_unique, store seen addresses as table keys (mapped to true),
not as array values. Then you don't have to look at the whole list to
check if an address has been seen already. In other words, you're doing
this:
        table.insert(unique_addresses, addr)
        if check_if_unique(addr) then
You should do this instead:
        unique_addresses[addr] = true
        if unique_addresses[addr] then

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


  By Date           By Thread  

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