1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-12 10:49:02 +00:00

Add xmloutput to vnc-info.nse

This commit is contained in:
dmiller
2013-10-18 16:05:48 +00:00
parent 95585e4008
commit 35dbe4fe37
2 changed files with 31 additions and 13 deletions

View File

@@ -79,8 +79,8 @@ VNC = {
[22]= "Colin Dean xvp",
-- Mac OS X screen sharing uses 30 and 35
[30]= "Mac OS X security type (30)",
[35]= "Mac OS X security type (35)",
[30]= "Mac OS X security type",
[35]= "Mac OS X security type",
},
new = function(self, host, port)
@@ -256,13 +256,20 @@ VNC = {
return true, ""
end,
--- Returns all supported security types as a table of strings
--- Returns all supported security types as a table
--
-- @return table containing a string entry for each security type
getSecTypesAsStringTable = function( self )
-- @return table containing a entry for each security type
getSecTypesAsTable = function( self )
local tmp = {}
local typemt = {
__tostring = function(me)
return ("%s (%s)"):format(me.name, me.type)
end
}
for i=1, self.vncsec.count do
table.insert( tmp, VNC.sectypes_str[self.vncsec.types[i]] or ("Unknown security type (%d)"):format(self.vncsec.types[i]) )
local t = {name=VNC.sectypes_str[self.vncsec.types[i]] or "Unknown security type", type=self.vncsec.types[i]}
setmetatable(t, typemt)
table.insert( tmp, t )
end
return true, tmp
end,

View File

@@ -21,6 +21,18 @@ categories = {"default", "discovery", "safe"}
-- | Mac OS X security type (30)
-- |_ Mac OS X security type (35)
--
-- @xmloutput
-- <elem key="Protocol version">3.8</elem>
-- <table key="Security types">
-- <table>
-- <elem key="name">Ultra</elem>
-- <elem key="type">17</elem>
-- </table>
-- <table>
-- <elem key="name">VNC Authentication</elem>
-- <elem key="type">2</elem>
-- </table>
-- </table>
-- Version 0.2
@@ -34,7 +46,7 @@ action = function(host, port)
local vnc = vnc.VNC:new( host.ip, port.number )
local status, data
local result = {}
local result = stdnse.output_table()
status, data = vnc:connect()
if ( not(status) ) then return " \n ERROR: " .. data end
@@ -42,19 +54,18 @@ action = function(host, port)
status, data = vnc:handshake()
if ( not(status) ) then return " \n ERROR: " .. data end
status, data = vnc:getSecTypesAsStringTable()
status, data = vnc:getSecTypesAsTable()
if ( not(status) ) then return " \n ERROR: " .. data end
table.insert(result, ("Protocol version: %s"):format(vnc:getProtocolVersion()) )
result["Protocol version"] = vnc:getProtocolVersion()
if ( data and #data ~= 0 ) then
data.name = "Security types:"
table.insert( result, data )
result["Security types"] = data
end
if ( vnc:supportsSecType(vnc.sectypes.NONE) ) then
table.insert(result, "WARNING: Server does not require authentication")
result["WARNING"] = "Server does not require authentication"
end
return stdnse.format_output(status, result)
return result
end