1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-26 09:29:01 +00:00

Structured script output.

Scripts may now return a key–value table, or such a table in addition to
a string. The table will be automatically formatted for normal output
and will appear as a hierarchy of elements in XML output.

Some history and discussion of this development can be found at
https://secwiki.org/w/Nmap/Structured_Script_Output.

This is a merge of r29484:29569 from /nmap-exp/david/xml-output.
This commit is contained in:
david
2012-08-14 16:36:25 +00:00
parent 16aa7a938d
commit 0c3e0fcc4d
16 changed files with 680 additions and 99 deletions

View File

@@ -22,6 +22,12 @@ original target.
-- PORT STATE SERVICE
-- 80/tcp open http
-- |_http-title: Go ahead and ScanMe!
--
-- @xmloutput
-- <elem key="title">Go ahead and ScanMe!</elem>
-- @xmloutput
-- <elem key="title">Wikipedia, the free encyclopedia</elem>
-- <elem key="redirect_url">http://en.wikipedia.org/wiki/Main_Page</elem>
author = "Diman Todorov"
@@ -41,7 +47,7 @@ action = function(host, port)
if resp.location then
redirect_url = resp.location[#resp.location]
if resp.status and tostring( resp.status ):match( "30%d" ) then
return ("Did not follow redirect to %s"):format( redirect_url )
return {redirect_url = redirect_url}, ("Did not follow redirect to %s"):format( redirect_url )
end
end
@@ -64,10 +70,14 @@ action = function(host, port)
end
end
local output_tab = stdnse.output_table()
output_tab.title = title
output_tab.redirect_url = redirect_url
local output_str = display_title
if redirect_url then
output_str = output_str .. "\n" .. ("Requested resource was %s"):format( redirect_url )
end
return output_str
return output_tab, output_str
end