Home page logo
/

nmap-dev logo Nmap Development mailing list archives

Re: [NSE] Draft - targets-sniffer.nse
From: Nick Nikolaou <nikolasnikolaou1 () gmail com>
Date: Tue, 5 Apr 2011 00:59:38 +0100

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


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

Thanks again for your time.


Nick

Attachment: targets-sniffer.nse
Description:

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