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 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] thenHello 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 function? David Fifield _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Re: [NSE] Draft - targets-sniffer.nse David Fifield (Apr 01)
- Re: [NSE] Draft - targets-sniffer.nse Djalal Harouni (Apr 02)
- Re: [NSE] Draft - targets-sniffer.nse Nick Nikolaou (Apr 03)
- Re: [NSE] Draft - targets-sniffer.nse Djalal Harouni (Apr 03)
- Re: [NSE] Draft - targets-sniffer.nse Nick Nikolaou (Apr 04)
- Re: [NSE] Draft - targets-sniffer.nse David Fifield (Apr 04)
- Re: [NSE] Draft - targets-sniffer.nse Nick Nikolaou (Apr 04)
- Re: [NSE] Draft - targets-sniffer.nse David Fifield (Apr 04)
- Re: [NSE] Draft - targets-sniffer.nse Djalal Harouni (Apr 23)
- Re: [NSE] Draft - targets-sniffer.nse Nick Nikolaou (Apr 03)
- Re: [NSE] Draft - targets-sniffer.nse Djalal Harouni (Apr 02)
- Re: [NSE] Draft - targets-sniffer.nse David Fifield (Apr 04)