Nmap Development mailing list archives
Re: [NSE] NTP info gathering script...
From: Richard Sammet <richard.sammet () googlemail com>
Date: Sat, 12 Dec 2009 18:49:54 +0100
Hi David, thanks a lot for your valuable input. I tried to follow all of your hints but for the one about testing an array/table for an element I was not able to implement it like you noted. It looks like this only works for "hashes" but not for "arrays": [quote]
t = {"test1", "test2", "test3"} if t["test2"] then print "foo" end t = {test1="test1", test2="test2", test3="test3"} if t["test2"] then print "foo" end
foo
[/quote] That's the reason why I still use my function findINtable in the source. I would be more than happy to get rid of that function as it is only used once... but I was also not able to find anything useful with this in the lua manuals and ebooks... I also added to the script that it fetches the time from the server - well, this is most obvious when testing a NTP server, isn't it? ;) For the variables argument - As the variables available really depends on the implementation of the NTP service (depending on the vendor there might be some variables we are not aware of yet) I think its a very useful thing to have the option to print all variables received. Please find the fixed version attached for an additional review. Thanks a lot in advance... Greetings, Richard On Sat, Dec 12, 2009 at 9:14 AM, David Fifield <david () bamsoftware com> wrote:
On Tue, Dec 01, 2009 at 06:29:44PM +0100, Richard Sammet wrote:Well, the next bunch of changes is implemented: - some more documentation - Added the function get_timeout() which enables the script to consider the global nmap timing setting (-T*) - Changed it to make use of stdnse.format_output instead of fiddling around with a string - Added nmap.set_port_state() - because if the script receives valuable data, the port should be in state=open ;)Hi Richard, the script looks good and it is straightforward. I want you to comment some of the values used in the script: string.char(0x16, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) buffer = try(comm.exchange(host, port, request, {lines=16, proto=port.protocol, timeout=timeout})) buffer = string.sub(buffer, 13) You need to say where the packet payload, and the numbers 16 and 13 come from. If possible, provide a link to online documentation of this packet. The test to see if a field should be printed can be done faster and clearer without the findINtable function: local wlist = {"version", "processor", "system", "refid", "stratum"} for k, v in string.gmatch(buffer, "(%w+)=\"?([^\",]+)\"?") do if wlist[k] then table.insert(info, string.format("%s: %s", k, v)) end end You could include the test against "any" here but I think script args for this script is overkill. Just include the fields that people are going to want to see by default. Same with the timeout--just use a good default.I will freeze it at this stage until public testing is done. And I really hope that I considered all the requirements for nse scripts to be added to the bundle... (are there any detailed nse coding guidelines available?)The best are http://nmap.org/book/nse-tutorial.html http://nmap.org/book/nsedoc.html You have a few minor problems in your documentation. You must use "@usage" instead of "@sample execution". You don't need to write "@param (void)" when a function takes no arguments--just don't use any @param. David Fifield
Attachment:
ntp-info.nse
Description:
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- [NSE] NTP info gathering script... Richard Sammet (Nov 29)
- Re: [NSE] NTP info gathering script... Matt Selsky (Nov 29)
- Re: [NSE] NTP info gathering script... Richard Sammet (Nov 30)
- Re: [NSE] NTP info gathering script... Richard Sammet (Nov 30)
- Re: [NSE] NTP info gathering script... Matt Selsky (Nov 30)
- Re: [NSE] NTP info gathering script... Richard Sammet (Dec 01)
- Re: [NSE] NTP info gathering script... David Fifield (Dec 12)
- Re: [NSE] NTP info gathering script... Richard Sammet (Dec 12)
- Re: [NSE] NTP info gathering script... Richard Sammet (Dec 12)
- Re: [NSE] NTP info gathering script... David Fifield (Dec 12)
- Re: [NSE] NTP info gathering script... Richard Sammet (Dec 13)
- Re: [NSE] NTP info gathering script... Richard Sammet (Dec 14)
- Re: [NSE] NTP info gathering script... David Fifield (Dec 21)
- Re: [NSE] NTP info gathering script... Richard Sammet (Nov 30)
- Re: [NSE] NTP info gathering script... Matt Selsky (Nov 29)