Nmap Development mailing list archives
Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July)
From: David Fifield <david () bamsoftware com>
Date: Fri, 20 Jul 2012 08:00:22 -0700
On Fri, Jul 20, 2012 at 10:54:32AM -0400, Patrick Donnelly wrote:
On Thu, Jul 19, 2012 at 7:08 PM, David Fifield <david () bamsoftware com> wrote:I can deal with the field names being lower-case and identifier-like; maybe people will even prefer them that way. But the fact that "md5" and "sha1" are not on adjacent lines is galling. Maybe a special kind of table format that keeps order (i.e., an array of name-value pairs)? That would seem to require a higher-level function with which to set output values.You can get an ordered dictionary in Lua with some metamethod magic:
Right, thanks for that. I don't doubt that it can be done. I'm asking if
it's a reasonable model for setting script output.
I'm attaching a copy of ssl-cert.nse modified to return a structured
table. It's the same one used to create the most recent output example
on the wiki page. This, I think, is about as nice as setting structured
output is going to get, and it would be nice if this method could
provide nice ordered output.
-- Convert a cert (which is a kind of userdata object) into a normal Lua table.
local function to_table(cert)
return {
subject = cert.subject,
issuer = cert.issuer,
pubkey = cert.pubkey,
validity = cert.validity,
md5 = stdnse.tohex(cert:digest("md5")),
sha1 = stdnse.tohex(cert:digest("sha1")),
-- pem = cert.pem,
}
end
David Fifield
Attachment:
ssl-cert.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:
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 19)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 19)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) Patrick Donnelly (Jul 20)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 20)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) Patrick Donnelly (Jul 20)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 20)
- Re: [RFC][patch] XML structured script output (Nmap-script-XML as of 15 July) David Fifield (Jul 20)
- Re: XML structured script output (storing results per script instance) David Fifield (Jul 31)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Jul 31)
- Re: XML structured script output (storing results per script instance) David Fifield (Jul 31)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Aug 01)
- Re: XML structured script output (storing results per script instance) Daniel Miller (Aug 01)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Aug 01)
- Re: XML structured script output (storing results per script instance) Daniel Miller (Aug 02)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Aug 03)
- Re: XML structured script output (storing results per script instance) Patrick Donnelly (Jul 31)
