diff --git a/nselib/vnc.lua b/nselib/vnc.lua index 120eabd61..cff830804 100644 --- a/nselib/vnc.lua +++ b/nselib/vnc.lua @@ -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, diff --git a/scripts/vnc-info.nse b/scripts/vnc-info.nse index 583da63ab..99f1623eb 100644 --- a/scripts/vnc-info.nse +++ b/scripts/vnc-info.nse @@ -21,6 +21,18 @@ categories = {"default", "discovery", "safe"} -- | Mac OS X security type (30) -- |_ Mac OS X security type (35) -- +-- @xmloutput +-- 3.8 +-- +--
+-- Ultra +-- 17 +--
+-- +-- VNC Authentication +-- 2 +--
+-- -- 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