From 0d47952611198ef6b1163f366dc03922d20b1475 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 09:42:04 +0200 Subject: Adding upstream version 7.94+git20230807.3be01efb1+dfsg. Signed-off-by: Daniel Baumann --- scripts/hbase-master-info.nse | 145 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 scripts/hbase-master-info.nse (limited to 'scripts/hbase-master-info.nse') diff --git a/scripts/hbase-master-info.nse b/scripts/hbase-master-info.nse new file mode 100644 index 0000000..8a3ac13 --- /dev/null +++ b/scripts/hbase-master-info.nse @@ -0,0 +1,145 @@ +local http = require "http" +local nmap = require "nmap" +local shortport = require "shortport" +local stdnse = require "stdnse" +local string = require "string" +local table = require "table" +local target = require "target" + +description = [[ +Retrieves information from an Apache HBase (Hadoop database) master HTTP status page. + +Information gathered: +* Hbase version +* Hbase compile date +* Hbase root directory +* Hadoop version +* Hadoop compile date +* Average load +* Zookeeper quorum server +* Associated region servers +]] + +--- +-- @usage +-- nmap --script hbase-master-info -p 60010 host +-- +-- @output +-- | hbase-master-info: +-- | Hbase Version: 0.90.1 +-- | Hbase Compiled: Wed May 11 22:33:44 PDT 2011, bob +-- | HBase Root Directory: hdfs://master.example.com:8020/hbase +-- | Hadoop Version: 0.20 f415ef415ef415ef415ef415ef415ef415ef415e +-- | Hadoop Compiled: Wed May 11 22:33:44 PDT 2011, bob +-- | Average Load: 0.12 +-- | Zookeeper Quorum: zookeeper.example.com:2181 +-- | Region Servers: +-- | region1.example.com:60030 +-- |_ region2.example.com:60030 +-- @xmloutput +-- 0.90.1 +-- Wed May 11 22:33:44 PDT 2011, bob +-- hdfs://master.example.com:8020/hbase +-- 0.20 f415ef415ef415ef415ef415ef415ef415ef415e +-- Wed May 11 22:33:44 PDT 2011, bob +-- 0.12 +-- zookeeper.example.com:2181 +-- +-- region1.example.com:60030 +-- region2.example.com:60030 +--
+ + +author = "John R. Bond" +license = "Simplified (2-clause) BSD license--See https://nmap.org/svn/docs/licenses/BSD-simplified" +categories = {"default", "discovery", "safe"} + + +portrule = function(host, port) + -- Run for the special port number, or for any HTTP-like service that is + -- not on a usual HTTP port. + return shortport.port_or_service ({60010}, "hbase-master")(host, port) + or (shortport.service(shortport.LIKELY_HTTP_SERVICES)(host, port) and not shortport.portnumber(shortport.LIKELY_HTTP_PORTS)(host, port)) +end + +action = function( host, port ) + + local result = stdnse.output_table() + local region_servers = {} + local uri = "/master.jsp" + stdnse.debug1("HTTP GET %s:%s%s", host.targetname or host.ip, port.number, uri) + local response = http.get( host, port, uri ) + stdnse.debug1("Status %s",response['status-line'] or "No Response") + if not (response['status-line'] and response['status-line']:match("200%s+OK") and response['body']) then + return nil + end + local body = response['body']:gsub("%%","%%%%") + stdnse.debug2("Body %s\n",body) + if body:match("HBase%s+Version([^][<]+)") then + local version = body:match("HBase%s+Version([^][<]+)"):gsub("%s+", " ") + stdnse.debug1("Hbase Version %s",version) + result["Hbase Version"] = version + port.version.version = version + end + if body:match("HBase%s+Compiled([^][<]+)") then + local compiled = body:match("HBase%s+Compiled([^][<]+)"):gsub("%s+", " ") + stdnse.debug1("Hbase Compiled %s",compiled) + result["Hbase Compiled"] = compiled + end + if body:match("Directory([^][<]+)") then + local compiled = body:match("Directory([^][<]+)"):gsub("%s+", " ") + stdnse.debug1("HBase RootDirectory %s",compiled) + result["HBase Root Directory"] = compiled + end + if body:match("Hadoop%s+Version([^][<]+)") then + local version = body:match("Hadoop%s+Version([^][<]+)"):gsub("%s+", " ") + stdnse.debug1("Hadoop Version %s",version) + result["Hadoop Version"] = version + end + if body:match("Hadoop%s+Compiled([^][<]+)") then + local compiled = body:match("Hadoop%s+Compiled([^][<]+)"):gsub("%s+", " ") + stdnse.debug1("Hadoop Compiled %s",compiled) + result["Hadoop Compiled"] = compiled + end + if body:match("average([^][<]+)") then + local average = body:match("average([^][<]+)"):gsub("%s+", " ") + stdnse.debug1("Average Load %s",average) + result["Average Load"] = average + end + if body:match("Quorum([^][<]+)") then + local quorum = body:match("Quorum([^][<]+)"):gsub("%s+", " ") + stdnse.debug1("Zookeeper Quorum %s",quorum) + result["Zookeeper Quorum"] = quorum + if target.ALLOW_NEW_TARGETS then + if quorum:match("([%w%.]+)") then + local newtarget = quorum:match("([%w%.]+)") + stdnse.debug1("Added target: %s", newtarget) + local status,err = target.add(newtarget) + end + end + end + for line in string.gmatch(body, "[^\n]+") do + stdnse.debug3("Line %s\n",line) + if line:match("maxHeap") then + local region_server= line:match("\">([^][<]+)") + stdnse.debug1("Region Server %s",region_server) + table.insert(region_servers, region_server) + if target.ALLOW_NEW_TARGETS then + if region_server:match("([%w%.]+)") then + local newtarget = region_server:match("([%w%.]+)") + stdnse.debug1("Added target: %s", newtarget) + local status,err = target.add(newtarget) + end + end + end + end + if next(region_servers) then + result["Region Servers"] = region_servers + end + if #result > 0 then + port.version.name = "hbase-master" + port.version.product = "Apache Hadoop Hbase" + nmap.set_port_version(host, port) + return result + end +end -- cgit v1.2.3