mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +00:00
Update 14 scripts with XML structured output
This commit is contained in:
parent
6d421b2e67
commit
3c5137e7e7
14 changed files with 358 additions and 191 deletions
|
|
@ -18,18 +18,33 @@ Obtains information from a Bitcoin server by calling <code>getinfo</code> on its
|
|||
-- @output
|
||||
-- 8332/tcp open unknown
|
||||
-- | bitcoinrpc-info.nse:
|
||||
-- | USER: root
|
||||
-- | connections: 36
|
||||
-- | hashespersec: 0
|
||||
-- | generate: false
|
||||
-- | keypoololdest: 1309381827
|
||||
-- | difficulty: 1379223.4296725
|
||||
-- | root:
|
||||
-- | balance: 0
|
||||
-- | version: 32100
|
||||
-- | blocks: 135041
|
||||
-- | connections: 36
|
||||
-- | difficulty: 1379223.4296725
|
||||
-- | generate: false
|
||||
-- | genproclimit: -1
|
||||
-- | hashespersec: 0
|
||||
-- | keypoololdest: 1309381827
|
||||
-- | paytxfee: 0
|
||||
-- | testnet: false
|
||||
-- | blocks: 135041
|
||||
-- |_ genproclimit: -1
|
||||
-- |_ version: 32100
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <table key="root">
|
||||
-- <elem key="balance">0</elem>
|
||||
-- <elem key="blocks">135041</elem>
|
||||
-- <elem key="connections">36</elem>
|
||||
-- <elem key="difficulty">1379223.4296725</elem>
|
||||
-- <elem key="generate">false</elem>
|
||||
-- <elem key="genproclimit">-1</elem>
|
||||
-- <elem key="hashespersec">0</elem>
|
||||
-- <elem key="keypoololdest">1309381827</elem>
|
||||
-- <elem key="paytxfee">0</elem>
|
||||
-- <elem key="testnet">false</elem>
|
||||
-- <elem key="version">32100</elem>
|
||||
-- </table>
|
||||
|
||||
author = "Toni Ruottu"
|
||||
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
||||
|
|
@ -108,11 +123,12 @@ local function decode_bitcoin_version(n)
|
|||
end
|
||||
|
||||
local function formatpairs(info)
|
||||
local result = {}
|
||||
for k, v in pairs(info) do
|
||||
if v ~= "" then
|
||||
local line = k .. ": " .. tostring(v)
|
||||
table.insert(result, line)
|
||||
local result = stdnse.output_table()
|
||||
local keys = stdnse.keys(info)
|
||||
table.sort(keys)
|
||||
for _, k in ipairs(keys) do
|
||||
if info[k] ~= "" then
|
||||
result[k] = info[k]
|
||||
end
|
||||
end
|
||||
return result
|
||||
|
|
@ -125,15 +141,14 @@ local function getinfo(host, port, user, pass)
|
|||
end
|
||||
|
||||
action = function(host, port)
|
||||
local response = {}
|
||||
local response = stdnse.output_table()
|
||||
local c = creds.Credentials:new(creds.ALL_DATA, host, port)
|
||||
local states = creds.State.VALID + creds.State.PARAM
|
||||
for cred in c:getCredentials(states) do
|
||||
local info = getinfo(host, port, cred.user, cred.pass)
|
||||
if info then
|
||||
local result = formatpairs(info)
|
||||
result["name"] = "USER: " .. cred.user
|
||||
table.insert(response, result)
|
||||
response[cred.user] = result
|
||||
|
||||
port.version.name = "http"
|
||||
port.version.product = "Bitcoin JSON-RPC"
|
||||
|
|
@ -144,6 +159,6 @@ action = function(host, port)
|
|||
end
|
||||
end
|
||||
|
||||
return stdnse.format_output(true, response)
|
||||
return response
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,10 @@ Discovers Versant object databases using the broadcast srvloc protocol.
|
|||
-- | broadcast-versant-locate:
|
||||
-- |_ vod://192.168.200.222:5019
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <table>
|
||||
-- <elem>vod://192.168.200.222:5019</elem>
|
||||
-- </table>
|
||||
|
||||
|
||||
author = "Patrik Karlsson"
|
||||
|
|
@ -34,5 +38,5 @@ action = function()
|
|||
for _, v in ipairs(result) do
|
||||
table.insert(output, v:match("^service:odbms.versant:vod://(.*)$"))
|
||||
end
|
||||
return stdnse.format_output(true, output)
|
||||
return output
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ http://cassandra.apache.org/
|
|||
-- | Cluster name: Test Cluster
|
||||
-- |_ Version: 19.10.0
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <elem key="Cluster name">Test Cluster</elem>
|
||||
-- <elem key="Version">19.10.0</elem>
|
||||
|
||||
-- version 0.1
|
||||
-- Created 14/09/2012 - v0.1 - created by Vlatko Kosturjak <kost@linux.hr>
|
||||
|
|
@ -52,7 +55,7 @@ function action(host,port)
|
|||
|
||||
try( socket:connect(host, port) )
|
||||
|
||||
local results = {}
|
||||
local results = stdnse.output_table()
|
||||
|
||||
-- ugliness to allow creds.cassandra to work, as the port is not recognized
|
||||
-- as cassandra even when service scan was run, taken from mongodb
|
||||
|
|
@ -61,7 +64,7 @@ function action(host,port)
|
|||
local c = creds.Credentials:new(creds.ALL_DATA, host, port)
|
||||
for cred in c:getCredentials(creds.State.VALID + creds.State.PARAM) do
|
||||
local status, err = cassandra.login(socket, cred.user, cred.pass)
|
||||
table.insert(results, ("Using credentials: %s"):format(cred.user.."/"..cred.pass))
|
||||
results["Using credentials"] = cred.user.."/"..cred.pass
|
||||
if ( not(status) ) then
|
||||
return err
|
||||
end
|
||||
|
|
@ -77,7 +80,7 @@ function action(host,port)
|
|||
port.version.product='Cassandra'
|
||||
port.version.name_confidence = 10
|
||||
nmap.set_port_version(host,port)
|
||||
table.insert(results, ("Cluster name: %s"):format(val))
|
||||
results["Cluster name"] = val
|
||||
|
||||
local status, val = cassandra.describe_version(socket,cassinc)
|
||||
if (not(status)) then
|
||||
|
|
@ -86,7 +89,7 @@ function action(host,port)
|
|||
cassinc = cassinc + 1
|
||||
port.version.product='Cassandra ('..val..')'
|
||||
nmap.set_port_version(host,port)
|
||||
table.insert(results, ("Version: %s"):format(val))
|
||||
results["Version"] = val
|
||||
|
||||
return stdnse.format_output(true, results)
|
||||
return results
|
||||
end
|
||||
|
|
|
|||
|
|
@ -79,6 +79,61 @@ the Nmap scan queue.
|
|||
--| mapred.job.tracker.retiredjobs.cache.size: 1000
|
||||
--| mapred.task.tracker.http.address: 0.0.0.0:50060
|
||||
--|_ mapred.task.tracker.report.address: 127.0.0.1:0
|
||||
--
|
||||
--@xmloutput
|
||||
-- <elem key="Version">0.9.4-cdh3u3</elem>
|
||||
-- <elem key="ServerID">0</elem>
|
||||
-- <table key="Flume nodes">
|
||||
-- <elem>node1.example.com</elem>
|
||||
-- <elem>node2.example.com</elem>
|
||||
-- <elem>node5.example.com</elem>
|
||||
-- <elem>node6.example.com</elem>
|
||||
-- <elem>node3.example.com</elem>
|
||||
-- <elem>node4.example.com</elem>
|
||||
-- </table>
|
||||
-- <table key="Zookeeper Master">
|
||||
-- <elem>master1.example.com</elem>
|
||||
-- </table>
|
||||
-- <table key="Hbase Master Master">
|
||||
-- <elem>hdfs://master1.example.com:8020/hbase</elem>
|
||||
-- </table>
|
||||
-- <table key="Enviroment">
|
||||
-- <elem key="java.runtime.name">Java(TM) SE Runtime Environment</elem>
|
||||
-- <elem key="java.runtime.version">1.6.0_36-a01</elem>
|
||||
-- <elem key="java.version">1.6.0_36</elem>
|
||||
-- <elem key="java.vm.name">Java HotSpot(TM) 64-Bit Server VM</elem>
|
||||
-- <elem key="java.vm.vendor">Sun Microsystems Inc.</elem>
|
||||
-- <elem key="java.vm.version">14.0-b12</elem>
|
||||
-- <elem key="os.arch">amd64</elem>
|
||||
-- <elem key="os.name">Linux</elem>
|
||||
-- <elem key="os.version">2.6.32-220.4.2.el6.x86_64</elem>
|
||||
-- <elem key="user.country">US</elem>
|
||||
-- <elem key="user.name">flume</elem>
|
||||
-- </table>
|
||||
-- <table key="Config">
|
||||
-- <elem key="dfs.datanode.address">0.0.0.0:50010</elem>
|
||||
-- <elem key="dfs.datanode.http.address">0.0.0.0:50075</elem>
|
||||
-- <elem key="dfs.datanode.https.address">0.0.0.0:50475</elem>
|
||||
-- <elem key="dfs.datanode.ipc.address">0.0.0.0:50020</elem>
|
||||
-- <elem key="dfs.http.address">master1.example.com:50070</elem>
|
||||
-- <elem key="dfs.https.address">0.0.0.0:50470</elem>
|
||||
-- <elem key="dfs.secondary.http.address">0.0.0.0:50090</elem>
|
||||
-- <elem key="flume.collector.dfs.dir">hdfs://master1.example.com/user/flume/collected</elem>
|
||||
-- <elem key="flume.collector.event.host">node1.example.com</elem>
|
||||
-- <elem key="flume.master.servers">master1.example.com</elem>
|
||||
-- <elem key="fs.default.name">hdfs://master1.example.com:8020</elem>
|
||||
-- <elem key="mapred.job.tracker">master1.example.com:9001</elem>
|
||||
-- <elem key="mapred.job.tracker.handler.count">10</elem>
|
||||
-- <elem key="mapred.job.tracker.http.address">0.0.0.0:50030</elem>
|
||||
-- <elem key="mapred.job.tracker.http.address">0.0.0.0:50030</elem>
|
||||
-- <elem key="mapred.job.tracker.jobhistory.lru.cache.size">5</elem>
|
||||
-- <elem key="mapred.job.tracker.persist.jobstatus.active">false</elem>
|
||||
-- <elem key="mapred.job.tracker.persist.jobstatus.dir">/jobtracker/jobsInfo</elem>
|
||||
-- <elem key="mapred.job.tracker.persist.jobstatus.hours">0</elem>
|
||||
-- <elem key="mapred.job.tracker.retiredjobs.cache.size">1000</elem>
|
||||
-- <elem key="mapred.task.tracker.http.address">0.0.0.0:50060</elem>
|
||||
-- <elem key="mapred.task.tracker.report.address">127.0.0.1:0</elem>
|
||||
-- </table>
|
||||
|
||||
author = "John R. Bond"
|
||||
license = "Simplified (2-clause) BSD license--See http://nmap.org/svn/docs/licenses/BSD-simplified"
|
||||
|
|
@ -111,7 +166,7 @@ function table_count(tt, item)
|
|||
end
|
||||
|
||||
parse_page = function( host, port, uri, interesting_keys )
|
||||
local result = {}
|
||||
local result = stdnse.output_table()
|
||||
local response = http.get( host, port, uri )
|
||||
stdnse.debug1("Status %s", response['status-line'] or "No Response")
|
||||
if response['status-line'] and response['status-line']:match("200%s+OK")
|
||||
|
|
@ -121,11 +176,11 @@ parse_page = function( host, port, uri, interesting_keys )
|
|||
"<tr><th>([^][<]+)</th>%s*<td><div%sclass=[^][>]+>([^][<]+)") do
|
||||
stdnse.debug1("%s=%s ", name, value:gsub("^%s*(.-)%s*$", "%1"))
|
||||
if nmap.verbosity() > 1 then
|
||||
result[#result+1] = ("%s: %s"):format(name,value:gsub("^%s*(.-)%s*$", "%1"))
|
||||
result[name] = value:gsub("^%s*(.-)%s*$", "%1")
|
||||
else
|
||||
for i,v in ipairs(interesting_keys) do
|
||||
if name:match(("^%s"):format(v)) then
|
||||
result[#result+1] = ("%s: %s"):format(name,value:gsub("^%s*(.-)%s*$", "%1"))
|
||||
result[name] = value:gsub("^%s*(.-)%s*$", "%1")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -136,7 +191,7 @@ end
|
|||
|
||||
action = function( host, port )
|
||||
|
||||
local result = {}
|
||||
local result = stdnse.output_table()
|
||||
local uri = "/flumemaster.jsp"
|
||||
local env_uri = "/masterenv.jsp"
|
||||
local config_uri = "/masterstaticconfig.jsp"
|
||||
|
|
@ -182,18 +237,18 @@ action = function( host, port )
|
|||
if body:match("Version:%s*</b>([^][,]+)") then
|
||||
local version = body:match("Version:%s*</b>([^][,]+)")
|
||||
stdnse.debug1("Version %s", version)
|
||||
result[#result+1] = ("Version: %s"):format(version)
|
||||
result["Version"] = version
|
||||
port.version.version = version
|
||||
end
|
||||
if body:match("Compiled:%s*</b>([^][<]+)") then
|
||||
local compiled = body:match("Compiled:%s*</b>([^][<]+)")
|
||||
stdnse.debug1("Compiled %s", compiled)
|
||||
result[#result+1] = ("Compiled: %s"):format(compiled)
|
||||
result["Compiled"] = compiled
|
||||
end
|
||||
if body:match("ServerID:%s*([^][<]+)") then
|
||||
local upgrades = body:match("ServerID:%s*([^][<]+)")
|
||||
stdnse.debug1("ServerID %s", upgrades)
|
||||
result[#result] = ("ServerID: %s"):format(upgrades)
|
||||
result["ServerID"] = upgrades
|
||||
end
|
||||
for logical,physical,hostname in string.gmatch(body,
|
||||
"<tr><td>([%w%.-_:]+)</td><td>([%w%.]+)</td><td>([%w%.]+)</td>") do
|
||||
|
|
@ -204,8 +259,7 @@ action = function( host, port )
|
|||
end
|
||||
end
|
||||
if next(nodes) ~= nil then
|
||||
table.insert(result, "Flume nodes:")
|
||||
result[#result+1] = nodes
|
||||
result["Flume nodes"] = nodes
|
||||
end
|
||||
for zookeeper in string.gmatch(body,"Dhbase.zookeeper.quorum=([^][\"]+)") do
|
||||
if (table_count(zookeepers, zookeeper) == 0) then
|
||||
|
|
@ -214,8 +268,7 @@ action = function( host, port )
|
|||
end
|
||||
end
|
||||
if next(zookeepers) ~= nil then
|
||||
result[#result+1] = "Zookeeper Master:"
|
||||
result[#result+1] = zookeepers
|
||||
result["Zookeeper Master"] = zookeepers
|
||||
end
|
||||
for hbasemaster in string.gmatch(body,"Dhbase.rootdir=([^][\"]+)") do
|
||||
if (table_count(hbasemasters, hbasemaster) == 0) then
|
||||
|
|
@ -224,24 +277,21 @@ action = function( host, port )
|
|||
end
|
||||
end
|
||||
if next(hbasemasters) ~= nil then
|
||||
result[#result+1] = "Hbase Master Master:"
|
||||
result[#result+1] = hbasemasters
|
||||
result["Hbase Masters"] = hbasemasters
|
||||
end
|
||||
local vars = parse_page(host, port, env_uri, env_keys )
|
||||
if next(vars) ~= nil then
|
||||
result[#result+1] = "Enviroment: "
|
||||
result[#result+1] = vars
|
||||
result["Environment"] = vars
|
||||
end
|
||||
local vars = parse_page(host, port, config_uri, config_keys )
|
||||
if next(vars) ~= nil then
|
||||
result[#result+1] = "Config: "
|
||||
result[#result+1] = vars
|
||||
result["Config"] = vars
|
||||
end
|
||||
if #result > 0 then
|
||||
port.version.name = "flume-master"
|
||||
port.version.product = "Apache Flume"
|
||||
nmap.set_port_version(host, port)
|
||||
return result
|
||||
end
|
||||
return stdnse.format_output(true, result)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,6 +19,23 @@ categories = {"default", "discovery", "safe"}
|
|||
-- | Object: Hello
|
||||
-- | Context: Test
|
||||
-- |_ Object: GoodBye
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <table>
|
||||
-- <enum key="enum">0</enum>
|
||||
-- <enum key="id">Hello</enum>
|
||||
-- <enum key="kind">18</enum>
|
||||
-- </table>
|
||||
-- <table>
|
||||
-- <enum key="enum">1</enum>
|
||||
-- <enum key="id">Test</enum>
|
||||
-- <enum key="kind">0</enum>
|
||||
-- </table>
|
||||
-- <table>
|
||||
-- <enum key="enum">0</enum>
|
||||
-- <enum key="id">Goodbye</enum>
|
||||
-- <enum key="kind">18</enum>
|
||||
-- </table>
|
||||
|
||||
|
||||
-- Version 0.1
|
||||
|
|
@ -28,11 +45,24 @@ categories = {"default", "discovery", "safe"}
|
|||
|
||||
portrule = shortport.port_or_service( {2809,1050,1049} , "giop", "tcp", "open")
|
||||
|
||||
local fmt_meta = {
|
||||
__tostring = function (t)
|
||||
local tmp = "Unknown"
|
||||
if ( t.enum == 0 ) then
|
||||
tmp = "Object"
|
||||
elseif( t.enum == 1 ) then
|
||||
tmp = "Context"
|
||||
end
|
||||
|
||||
-- TODO: Handle t.kind? May require IDL.
|
||||
return ("%s: %s"):format(tmp, t.id)
|
||||
end
|
||||
}
|
||||
|
||||
action = function(host, port)
|
||||
|
||||
local helper = giop.Helper:new( host, port )
|
||||
local ctx, objs, status, err
|
||||
local result = {}
|
||||
|
||||
status, err = helper:Connect()
|
||||
if ( not(status) ) then return err end
|
||||
|
|
@ -44,18 +74,8 @@ action = function(host, port)
|
|||
if ( not(status) ) then return " \n ERROR: " .. objs end
|
||||
|
||||
for _, obj in ipairs( objs ) do
|
||||
local tmp = ""
|
||||
|
||||
if ( obj.enum == 0 ) then
|
||||
tmp = "Object: "
|
||||
elseif( obj.enum == 1 ) then
|
||||
tmp = "Context: "
|
||||
else
|
||||
tmp = "Unknown: "
|
||||
end
|
||||
|
||||
table.insert(result, tmp .. obj.id )
|
||||
setmetatable(obj, fmt_meta)
|
||||
end
|
||||
|
||||
return stdnse.format_output(true, result)
|
||||
return objs
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ For more information about hadoop, see:
|
|||
-- 50075/tcp open hadoop-datanode syn-ack
|
||||
-- | hadoop-datanode-info:
|
||||
-- |_ Logs: /logs/
|
||||
---
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <elem key="Logs">/logs/</elem>
|
||||
|
||||
|
||||
author = "John R. Bond"
|
||||
|
|
@ -42,7 +44,7 @@ end
|
|||
|
||||
action = function( host, port )
|
||||
|
||||
local result = {}
|
||||
local result = stdnse.output_table()
|
||||
local uri = "/browseDirectory.jsp"
|
||||
stdnse.debug1("HTTP GET %s:%s%s", host.targetname or host.ip, port.number, uri)
|
||||
local response = http.get( host, port, uri )
|
||||
|
|
@ -56,8 +58,8 @@ action = function( host, port )
|
|||
nmap.set_port_version(host, port)
|
||||
local logs = body:match("([^][\"]+)\">Log")
|
||||
stdnse.debug1("Logs %s",logs)
|
||||
table.insert(result, ("Logs: %s"):format(logs))
|
||||
result["Logs"] = logs
|
||||
end
|
||||
return stdnse.format_output(true, result)
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -42,6 +42,15 @@ For more information about Hadoop, see:
|
|||
-- | Checkpoint Period: 3600 seconds
|
||||
-- |_ Checkpoint Size: 12345678 MB
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <elem key="Start">Wed May 11 22:33:44 PDT 2011</elem>
|
||||
-- <elem key="Version">0.20.2, f415ef415ef415ef415ef415ef415ef415ef415e</elem>
|
||||
-- <elem key="Compiled">Wed May 11 22:33:44 PDT 2011 by bob from unknown</elem>
|
||||
-- <elem key="Log">/logs/</elem>
|
||||
-- <elem key="namenode">namenode1.example.com/192.0.1.1:8020</elem>
|
||||
-- <elem key="Last Checkpoint">Wed May 11 22:33:44 PDT 2011</elem>
|
||||
-- <elem key="Checkpoint Period">3600 seconds</elem>
|
||||
-- <elem key="Checkpoint Size">12345678 MB</elem>
|
||||
|
||||
author = "John R. Bond"
|
||||
license = "Simplified (2-clause) BSD license--See http://nmap.org/svn/docs/licenses/BSD-simplified"
|
||||
|
|
@ -57,7 +66,7 @@ end
|
|||
|
||||
action = function( host, port )
|
||||
|
||||
local result = {}
|
||||
local result = stdnse.output_table()
|
||||
local uri = "/status.jsp"
|
||||
stdnse.debug1("HTTP GET %s:%s%s", host.targetname or host.ip, port.number, uri)
|
||||
local response = http.get( host, port, uri )
|
||||
|
|
@ -76,34 +85,29 @@ action = function( host, port )
|
|||
stdnse.debug1("Last Checkpoint %s",stats[3])
|
||||
stdnse.debug1("Checkpoint Period %s",stats[4])
|
||||
stdnse.debug1("Checkpoint Size %s",stats[5])
|
||||
table.insert(result, ("Start: %s"):format(stats[2]))
|
||||
result["Start"] = stats[2]
|
||||
end
|
||||
if body:match("Version:%s*</td><td>([^][\n]+)") then
|
||||
local version = body:match("Version:%s*</td><td>([^][\n]+)")
|
||||
stdnse.debug1("Version %s",version)
|
||||
table.insert(result, ("Version: %s"):format(version))
|
||||
result["Version"] = version
|
||||
port.version.version = version
|
||||
end
|
||||
if body:match("Compiled:%s*</td><td>([^][\n]+)") then
|
||||
local compiled = body:match("Compiled:%s*</td><td>([^][\n]+)")
|
||||
stdnse.debug1("Compiled %s",compiled)
|
||||
table.insert(result, ("Compiled: %s"):format(compiled))
|
||||
result["Compiled"] = compiled
|
||||
end
|
||||
if body:match("([^][\"]+)\">Logs") then
|
||||
local logs = body:match("([^][\"]+)\">Logs")
|
||||
stdnse.debug1("Logs %s",logs)
|
||||
table.insert(result, ("Logs: %s"):format(logs))
|
||||
result["Logs"] = logs
|
||||
end
|
||||
if #stats == 5 then
|
||||
table.insert(result, ("Namenode: %s"):format(stats[1]))
|
||||
table.insert(result, ("Last Checkpoint: %s"):format(stats[3]))
|
||||
table.insert(result, ("Checkpoint Period: %s"):format(stats[4]))
|
||||
table.insert(result, ("Checkpoint: Size %s"):format(stats[5]))
|
||||
end
|
||||
if #result > 0 then
|
||||
port.version.name = "hadoop-secondary-namenode"
|
||||
port.version.product = "Apache Hadoop"
|
||||
nmap.set_port_version(host, port)
|
||||
result["Namenode"] = stats[1]
|
||||
result["Last Checkpoint"] = stats[3]
|
||||
result["Checkpoint Period"] = stats[4]
|
||||
result["Checkpoint"] = stats[5]
|
||||
end
|
||||
if target.ALLOW_NEW_TARGETS then
|
||||
if stats[1]:match("([^][/]+)") then
|
||||
|
|
@ -112,7 +116,12 @@ action = function( host, port )
|
|||
local status,err = target.add(newtarget)
|
||||
end
|
||||
end
|
||||
if #result > 0 then
|
||||
port.version.name = "hadoop-secondary-namenode"
|
||||
port.version.product = "Apache Hadoop"
|
||||
nmap.set_port_version(host, port)
|
||||
return result
|
||||
end
|
||||
|
||||
end
|
||||
return stdnse.format_output(true, result)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ end
|
|||
|
||||
action = function( host, port )
|
||||
|
||||
local result = {}
|
||||
local region_servers = {}
|
||||
local result = stdnse.output_table()
|
||||
-- uri was previously "/regionserver.jsp". See
|
||||
-- http://seclists.org/nmap-dev/2012/q3/903.
|
||||
local uri = "/rs-status"
|
||||
|
|
@ -65,23 +64,23 @@ action = function( host, port )
|
|||
if body:match("HBase%s+Version</td><td>([^][<]+)") then
|
||||
local version = body:match("HBase%s+Version</td><td>([^][<]+)"):gsub("%s+", " ")
|
||||
stdnse.debug1("Hbase Version %s",version)
|
||||
table.insert(result, ("Hbase Version: %s"):format(version))
|
||||
result["Hbase Version"] = version
|
||||
port.version.version = version
|
||||
end
|
||||
if body:match("HBase%s+Compiled</td><td>([^][<]+)") then
|
||||
local compiled = body:match("HBase%s+Compiled</td><td>([^][<]+)"):gsub("%s+", " ")
|
||||
stdnse.debug1("Hbase Compiled %s",compiled)
|
||||
table.insert(result, ("Hbase Compiled: %s"):format(compiled))
|
||||
result["Hbase Compiled"] = compiled
|
||||
end
|
||||
if body:match("Metrics</td><td>([^][<]+)") then
|
||||
local metrics = body:match("Metrics</td><td>([^][<]+)"):gsub("%s+", " ")
|
||||
stdnse.debug1("Metrics %s",metrics)
|
||||
table.insert(result, ("Metrics %s"):format(metrics))
|
||||
result["Metrics"] = metrics
|
||||
end
|
||||
if body:match("Quorum</td><td>([^][<]+)") then
|
||||
local quorum = body:match("Quorum</td><td>([^][<]+)"):gsub("%s+", " ")
|
||||
stdnse.debug1("Zookeeper Quorum %s",quorum)
|
||||
table.insert(result, ("Zookeeper Quorum: %s"):format(quorum))
|
||||
result["Zookeeper Quorum"] = quorum
|
||||
if target.ALLOW_NEW_TARGETS then
|
||||
if quorum:match("([%w%.]+)") then
|
||||
local newtarget = quorum:match("([%w%.]+)")
|
||||
|
|
@ -94,7 +93,7 @@ action = function( host, port )
|
|||
port.version.name = "hbase-region"
|
||||
port.version.product = "Apache Hadoop Hbase"
|
||||
nmap.set_port_version(host, port)
|
||||
return result
|
||||
end
|
||||
return stdnse.format_output(true, result)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,22 @@ Reads hard disk information (such as brand, model, and sometimes temperature) fr
|
|||
--
|
||||
-- @output
|
||||
-- 7634/tcp open hddtemp
|
||||
-- |_hddtemp-info: /dev/sda: WDC WD2500JS-60MHB1: 38 C
|
||||
-- | hddtemp-info:
|
||||
-- |_ /dev/sda: WDC WD2500JS-60MHB1: 38 C
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <table>
|
||||
-- <elem key="label">WDC WD2500JS-60MHB1</elem>
|
||||
-- <elem key="unit">C</elem>
|
||||
-- <elem key="device">/dev/sda</elem>
|
||||
-- <elem key="temperature">38</elem>
|
||||
-- </table>
|
||||
-- <table>
|
||||
-- <elem key="label">WDC WD3200BPVT-75JJ5T0</elem>
|
||||
-- <elem key="unit">C</elem>
|
||||
-- <elem key="device">/dev/sdb</elem>
|
||||
-- <elem key="temperature">41</elem>
|
||||
-- </table>
|
||||
|
||||
author = "Toni Ruottu"
|
||||
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
||||
|
|
@ -24,6 +39,11 @@ categories = {"default", "discovery", "safe"}
|
|||
|
||||
portrule = shortport.port_or_service (7634, "hddtemp", {"tcp"})
|
||||
|
||||
local fmt_meta = {
|
||||
__tostring = function (t)
|
||||
return string.format("%s: %s: %s %s", t.device, t.label, t.temperature, t.unit)
|
||||
end
|
||||
}
|
||||
action = function( host, port )
|
||||
-- 5000B should be enough for 100 disks
|
||||
local status, data = comm.get_banner(host, port, {bytes=5000})
|
||||
|
|
@ -36,12 +56,14 @@ action = function( host, port )
|
|||
local disks = math.floor((# fields) / 5)
|
||||
for i = 0, (disks - 1) do
|
||||
local start = i * 5
|
||||
local device = fields[start + 2]
|
||||
local label = fields[start + 3]
|
||||
local temperature = fields[start + 4]
|
||||
local unit = fields[start + 5]
|
||||
local formatted = string.format("%s: %s: %s %s", device, label, temperature, unit)
|
||||
table.insert(info, formatted)
|
||||
local diskinfo = {
|
||||
device = fields[start + 2],
|
||||
label = fields[start + 3],
|
||||
temperature = fields[start + 4],
|
||||
unit = fields[start + 5],
|
||||
}
|
||||
setmetatable(diskinfo, fmt_meta)
|
||||
table.insert(info, diskinfo)
|
||||
end
|
||||
return stdnse.format_output(true, info)
|
||||
return info
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,7 +30,17 @@ hostnames)".
|
|||
-- | ipv6-node-info:
|
||||
-- | Hostnames: mac-mini.local
|
||||
-- | IPv6 addresses: fe80::a8bb:ccff:fedd:eeff, 2001:db8:1234:1234::3
|
||||
-- |_ IPv4 addresses: (actually hostnames) mac-mini.local
|
||||
-- |_ IPv4 addresses: mac-mini.local
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <elem key="Hostnames">mac-mini.local</elem>
|
||||
-- <table key="IPv6 addresses">
|
||||
-- <elem>fe80::a8bb:ccff:fedd:eeff</elem>
|
||||
-- <elem>2001:db8:1234:1234::3</elem>
|
||||
-- </table>
|
||||
-- <table key="IPv4 addresses">
|
||||
-- <elem>mac-mini.local</elem>
|
||||
-- </table>
|
||||
|
||||
categories = {"default", "discovery", "safe"}
|
||||
|
||||
|
|
@ -147,27 +157,31 @@ local function stringify_noop(flags, data)
|
|||
return "replied"
|
||||
end
|
||||
|
||||
local commasep = {
|
||||
__tostring = function (t)
|
||||
return stdnse.strjoin(", ", t)
|
||||
end
|
||||
}
|
||||
|
||||
-- RFC 4620, section 6.3.
|
||||
local function stringify_nodename(flags, data)
|
||||
local status, names
|
||||
local text
|
||||
|
||||
status, names = try_decode_nodenames(data)
|
||||
if empty(names) then
|
||||
return
|
||||
end
|
||||
text = stdnse.strjoin(", ", names)
|
||||
if not status then
|
||||
text = text .. " (parsing error)"
|
||||
names[#names+1] = "(parsing error)"
|
||||
end
|
||||
|
||||
return text
|
||||
setmetatable(names, commasep)
|
||||
return names
|
||||
end
|
||||
|
||||
-- RFC 4620, section 6.3.
|
||||
local function stringify_nodeaddresses(flags, data)
|
||||
local ttl, binaddr
|
||||
local text
|
||||
local addrs = {}
|
||||
local pos = nil
|
||||
|
||||
|
|
@ -182,12 +196,12 @@ local function stringify_nodeaddresses(flags, data)
|
|||
return
|
||||
end
|
||||
|
||||
text = stdnse.strjoin(", ", addrs)
|
||||
if bit.band(flags, 0x01) ~= 0 then
|
||||
text = text .. " (more omitted for space reasons)"
|
||||
addrs[#addrs+1] = "(more omitted for space reasons)"
|
||||
end
|
||||
|
||||
return text
|
||||
setmetatable(addrs, commasep)
|
||||
return addrs
|
||||
end
|
||||
|
||||
-- RFC 4620, section 6.4.
|
||||
|
|
@ -202,14 +216,14 @@ end
|
|||
local function stringify_nodeipv4addresses(flags, data)
|
||||
local status, names
|
||||
local ttl, binaddr
|
||||
local text
|
||||
local addrs = {}
|
||||
local pos = nil
|
||||
|
||||
-- Check for DNS names.
|
||||
status, names = try_decode_nodenames(data .. "\0\0")
|
||||
if status then
|
||||
return "(actually hostnames) " .. stdnse.strjoin(", ", names)
|
||||
setmetatable(names, commasep)
|
||||
return names
|
||||
end
|
||||
|
||||
-- Okay, looks like it's really IP addresses.
|
||||
|
|
@ -224,12 +238,12 @@ local function stringify_nodeipv4addresses(flags, data)
|
|||
return
|
||||
end
|
||||
|
||||
text = stdnse.strjoin(", ", addrs)
|
||||
if bit.band(flags, 0x01) ~= 0 then
|
||||
text = text .. " (more omitted for space reasons)"
|
||||
addrs[#addrs+1] = "(more omitted for space reasons)"
|
||||
end
|
||||
|
||||
return text
|
||||
setmetatable(addrs, commasep)
|
||||
return addrs
|
||||
end
|
||||
|
||||
local STRINGIFY = {
|
||||
|
|
@ -279,14 +293,14 @@ local function format_results(results)
|
|||
}
|
||||
local output
|
||||
|
||||
output = {}
|
||||
output = stdnse.output_table()
|
||||
for _, qtype in ipairs(QTYPE_ORDER) do
|
||||
if results[qtype] then
|
||||
output[#output + 1] = QTYPE_STRINGS[qtype] .. ": " .. results[qtype]
|
||||
output[QTYPE_STRINGS[qtype]] = results[qtype]
|
||||
end
|
||||
end
|
||||
|
||||
return stdnse.format_output(true, output)
|
||||
return output
|
||||
end
|
||||
|
||||
function action(host)
|
||||
|
|
|
|||
|
|
@ -13,12 +13,23 @@ Collects and displays information from remote iSCSI targets.
|
|||
-- 3260/tcp open iscsi
|
||||
-- | iscsi-info:
|
||||
-- | iqn.2006-01.com.openfiler:tsn.c8c08cad469d
|
||||
-- | Target address: 192.168.56.5:3260,1
|
||||
-- | Address: 192.168.56.5:3260,1
|
||||
-- | Authentication: NOT required
|
||||
-- | iqn.2006-01.com.openfiler:tsn.6aea7e052952
|
||||
-- | Target address: 192.168.56.5:3260,1
|
||||
-- |_ Authentication: required
|
||||
-- | Address: 192.168.56.5:3260,1
|
||||
-- | Authentication: required
|
||||
-- |_ Auth reason: Authentication failure
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <table key="iqn.2006-01.com.openfiler:tsn.c8c08cad469d">
|
||||
-- <elem key="Address">192.168.56.5:3260,1</elem>
|
||||
-- <elem key="Authentication">NOT required</elem>
|
||||
-- </table>
|
||||
-- <table key="iqn.2006-01.com.openfiler:tsn.6aea7e052952">
|
||||
-- <elem key="Address">192.168.56.5:3260,1</elem>
|
||||
-- <elem key="Authentication">required</elem>
|
||||
-- <elem key="Auth reason">Authentication failure</elem>
|
||||
-- </table>
|
||||
|
||||
-- Version 0.2
|
||||
-- Created 2010/11/18 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
|
||||
|
|
@ -76,21 +87,21 @@ action = function( host, port )
|
|||
status = helper:logout()
|
||||
status = helper:close()
|
||||
|
||||
local result = {}
|
||||
local result = stdnse.output_table()
|
||||
for _, record in ipairs(records) do
|
||||
local result_part = {}
|
||||
result_part.name = ("Target: %s"):format(record.name)
|
||||
local result_part = stdnse.output_table()
|
||||
for _, addr in ipairs( record.addr ) do
|
||||
table.insert(result_part, ("Address: %s"):format(addr) )
|
||||
result_part["Address"] = addr
|
||||
end
|
||||
|
||||
local status, err = requiresAuth( host, port, record.name )
|
||||
if ( not(status) ) then
|
||||
table.insert(result_part, "Authentication: " .. err )
|
||||
result_part["Authentication"] = "required"
|
||||
result_part["Auth reason"] = err
|
||||
else
|
||||
table.insert(result_part, "Authentication: No authentication required")
|
||||
result_part["Authentication"] = "NOT required"
|
||||
end
|
||||
table.insert(result, result_part)
|
||||
result[record.name] = result_part
|
||||
end
|
||||
return stdnse.format_output( true, result )
|
||||
return result
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,12 +16,20 @@ Parses and displays the banner information of an OpenLookup (network key-value s
|
|||
-- @output
|
||||
-- 5850/tcp open openlookup
|
||||
-- | openlookup-info:
|
||||
-- | sync port: 5850
|
||||
-- | name: Paradise, Arizona
|
||||
-- | your address: 127.0.0.1:50162
|
||||
-- | timestamp: 1305977167.52 (2011-05-21 11:26:07 UTC)
|
||||
-- | version: 2.7
|
||||
-- |_ http port: 5851
|
||||
-- | sync port: 5850
|
||||
-- | name: Paradise, Arizona
|
||||
-- | your address: 127.0.0.1:50162
|
||||
-- | timestamp: 2011-05-21T11:26:07
|
||||
-- | version: 2.7
|
||||
-- |_ http port: 5851
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <elem key="sync port">5850</elem>
|
||||
-- <elem key="name">Paradise, Arizona</elem>
|
||||
-- <elem key="your address">127.0.0.1:50162</elem>
|
||||
-- <elem key="timestamp">2011-05-21T11:26:07</elem>
|
||||
-- <elem key="version">2.7</elem>
|
||||
-- <elem key="http port">5851</elem>
|
||||
|
||||
author = "Toni Ruottu"
|
||||
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
||||
|
|
@ -166,13 +174,7 @@ local function formattime(data)
|
|||
if not time then
|
||||
return
|
||||
end
|
||||
local human = stdnse.format_timestamp(time)
|
||||
return time .. " (" .. human .. ")"
|
||||
end
|
||||
|
||||
local function formatkey(key)
|
||||
local parts = stdnse.strsplit("_", key)
|
||||
return stdnse.strjoin(" ", parts)
|
||||
return stdnse.format_timestamp(time)
|
||||
end
|
||||
|
||||
local function formatvalue(key, nson)
|
||||
|
|
@ -190,12 +192,6 @@ local function formatvalue(key, nson)
|
|||
return value
|
||||
end
|
||||
|
||||
local function format(rawkey, nson)
|
||||
local key = formatkey(rawkey)
|
||||
local value = formatvalue(rawkey, nson)
|
||||
return key .. ": " .. value
|
||||
end
|
||||
|
||||
function formatoptions(header)
|
||||
local msg = parsedict(header)
|
||||
if not msg then
|
||||
|
|
@ -218,18 +214,7 @@ function formatoptions(header)
|
|||
if not rawopts then
|
||||
return {}
|
||||
end
|
||||
local options = parsedict(rawopts)
|
||||
if not options then
|
||||
return
|
||||
end
|
||||
local formatted = {}
|
||||
for key, nson in pairs(options) do
|
||||
local tmp = format(key, nson)
|
||||
if tmp then
|
||||
table.insert(formatted, tmp)
|
||||
end
|
||||
end
|
||||
return formatted
|
||||
return parsedict(rawopts)
|
||||
end
|
||||
|
||||
action = function(host, port)
|
||||
|
|
@ -254,8 +239,6 @@ action = function(host, port)
|
|||
if #options < 1 then
|
||||
return
|
||||
end
|
||||
local response = {}
|
||||
table.insert(response, options)
|
||||
return stdnse.format_output(true, response)
|
||||
return options
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,13 @@ Determines which methods are supported by the RTSP (real time streaming protocol
|
|||
-- | rtsp-methods:
|
||||
-- |_ DESCRIBE, SETUP, PLAY, TEARDOWN, OPTIONS
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <elem>DESCRIBE</elem>
|
||||
-- <elem>SETUP</elem>
|
||||
-- <elem>PLAY</elem>
|
||||
-- <elem>TEARDOWN</elem>
|
||||
-- <elem>OPTIONS</elem>
|
||||
--
|
||||
-- @args rtsp-methods.path the path to query, defaults to "*" which queries
|
||||
-- the server itself, rather than a specific url.
|
||||
--
|
||||
|
|
@ -44,6 +51,7 @@ action = function(host, port)
|
|||
status, response = helper:options(path)
|
||||
helper:close()
|
||||
if ( status ) then
|
||||
return stdnse.format_output(true, response.headers['Public'])
|
||||
local opts = response.headers['Public']
|
||||
return stdnse.strsplit(",%s*", opts), opts
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,25 +13,53 @@ Attempts to enumerate running processes through SNMP.
|
|||
-- nmap -sU -p 161 --script=snmp-processes <target>
|
||||
-- @output
|
||||
-- | snmp-processes:
|
||||
-- | System Idle Process
|
||||
-- | PID: 1
|
||||
-- | System
|
||||
-- | PID: 4
|
||||
-- | smss.exe
|
||||
-- | 1:
|
||||
-- | Name: System Idle Process
|
||||
-- | 4:
|
||||
-- | Name: System
|
||||
-- | 256:
|
||||
-- | Name: smss.exe
|
||||
-- | Path: \SystemRoot\System32\
|
||||
-- | PID: 256
|
||||
-- | csrss.exe
|
||||
-- | 308:
|
||||
-- | Name: csrss.exe
|
||||
-- | Path: C:\WINDOWS\system32\
|
||||
-- | Params: ObjectDirectory=\Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserS
|
||||
-- | PID: 308
|
||||
-- | winlogon.exe
|
||||
-- | PID: 332
|
||||
-- | services.exe
|
||||
-- | 332:
|
||||
-- | Name: winlogon.exe
|
||||
-- | 380:
|
||||
-- | Name: services.exe
|
||||
-- | Path: C:\WINDOWS\system32\
|
||||
-- | PID: 380
|
||||
-- | lsass.exe
|
||||
-- | Path: C:\WINDOWS\system32\
|
||||
-- |_ PID: 392
|
||||
-- | 392:
|
||||
-- | Name: lsass.exe
|
||||
-- |_ Path: C:\WINDOWS\system32\
|
||||
--
|
||||
-- @xmloutput
|
||||
-- <table key="1">
|
||||
-- <elem key="Name">System Idle Process</elem>
|
||||
-- </table>
|
||||
-- <table key="4">
|
||||
-- <elem key="Name">System</elem>
|
||||
-- </table>
|
||||
-- <table key="256">
|
||||
-- <elem key="Name">smss.exe</elem>
|
||||
-- <elem key="Path">\SystemRoot\System32\</elem>
|
||||
-- </table>
|
||||
-- <table key="308">
|
||||
-- <elem key="Name">csrss.exe</elem>
|
||||
-- <elem key="Path">C:\WINDOWS\system32\</elem>
|
||||
-- <elem key="Params">ObjectDirectory=\Windows SharedSection=1024,3072,512 Windows=On SubSystemType=Windows ServerDll=basesrv,1 ServerDll=winsrv:UserS</elem>
|
||||
-- </table>
|
||||
-- <table key="332">
|
||||
-- <elem key="Name">winlogon.exe</elem>
|
||||
-- </table>
|
||||
-- <table key="380">
|
||||
-- <elem key="Name">services.exe</elem>
|
||||
-- <elem key="Path">C:\WINDOWS\system32\</elem>
|
||||
-- </table>
|
||||
-- <table key="392">
|
||||
-- <elem key="Name">lsass.exe</elem>
|
||||
-- <elem key="Path">C:\WINDOWS\system32\</elem>
|
||||
-- </table>
|
||||
|
||||
author = "Patrik Karlsson"
|
||||
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
||||
|
|
@ -73,36 +101,35 @@ function process_answer( tbl )
|
|||
local swrun_pid = "1.3.6.1.2.1.25.4.2.1.1"
|
||||
local swrun_path = "1.3.6.1.2.1.25.4.2.1.4"
|
||||
local swrun_params = "1.3.6.1.2.1.25.4.2.1.5"
|
||||
local new_tbl = {}
|
||||
local new_tbl = stdnse.output_table()
|
||||
|
||||
for _, v in ipairs( tbl ) do
|
||||
|
||||
if ( v.oid:match("^" .. swrun_name) ) then
|
||||
local item = {}
|
||||
local objid = v.oid:gsub( "^" .. swrun_name, swrun_path)
|
||||
local value = get_value_from_table( tbl, objid )
|
||||
|
||||
if value and value:len() > 0 then
|
||||
table.insert( item, ("Path: %s"):format( value ) )
|
||||
end
|
||||
|
||||
objid = v.oid:gsub( "^" .. swrun_name, swrun_params)
|
||||
value = get_value_from_table( tbl, objid )
|
||||
|
||||
if value and value:len() > 0 then
|
||||
table.insert( item, ("Params: %s"):format( value ) )
|
||||
end
|
||||
|
||||
objid = v.oid:gsub( "^" .. swrun_name, swrun_pid)
|
||||
value = get_value_from_table( tbl, objid )
|
||||
if ( v.oid:match("^" .. swrun_pid) ) then
|
||||
local item = stdnse.output_table()
|
||||
local objid = v.oid:gsub( "^" .. swrun_pid, swrun_name)
|
||||
local value = get_value_from_table( tbl, objid )
|
||||
|
||||
if value then
|
||||
table.insert( item, ("PID: %s"):format( value ) )
|
||||
item["Name"] = value
|
||||
end
|
||||
|
||||
item.name = v.value
|
||||
table.insert( item, value )
|
||||
table.insert( new_tbl, item )
|
||||
objid = v.oid:gsub( "^" .. swrun_pid, swrun_path)
|
||||
value = get_value_from_table( tbl, objid )
|
||||
|
||||
if value and value:len() > 0 then
|
||||
item["Path"] = value
|
||||
end
|
||||
|
||||
objid = v.oid:gsub( "^" .. swrun_pid, swrun_params)
|
||||
value = get_value_from_table( tbl, objid )
|
||||
|
||||
if value and value:len() > 0 then
|
||||
item["Params"] = value
|
||||
end
|
||||
|
||||
-- key (PID) must be a string for output to work.
|
||||
new_tbl[tostring(v.value)] = item
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -135,6 +162,6 @@ action = function(host, port)
|
|||
|
||||
nmap.set_port_state(host, port, "open")
|
||||
|
||||
return stdnse.format_output( true, shares )
|
||||
return shares
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue