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 23:16:00 -0700

On Tue, Apr 05, 2011 at 12:59:38AM +0100, Nick Nikolaou wrote:
On 4 April 2011 21:38, David Fifield <david () bamsoftware com> wrote:

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

The output should look like this:

Pre-scan script results:
| targets-sniffer:
| ...

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
       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

Hello David, I made the necessary changes to the script.

Thanks for being so quick. The script looks very nice now. I have just
committed it and credited you.

Djalal, I also added your get_interface patch. I think you said that it
obsoletes get_interface_link. Would you test that and remove the old

David Fifield
Sent through the nmap-dev mailing list
Archived at http://seclists.org/nmap-dev/

  By Date           By Thread  

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