diff --git a/scripts/flume-master-info.nse b/scripts/flume-master-info.nse index 1b3beea0c..69fc10baa 100644 --- a/scripts/flume-master-info.nse +++ b/scripts/flume-master-info.nse @@ -149,8 +149,6 @@ action = function( host, port ) local body = response['body']:gsub("%%","%%%%") local capacity = {} stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body)) - port.version.name = "flume-master" - port.version.product = "Apache Flume" if body:match("Version:%s*([^][,]+)") then local version = body:match("Version:%s*([^][,]+)") stdnse.print_debug(1, ("%s: Version %s"):format(SCRIPT_NAME,version)) @@ -208,7 +206,11 @@ action = function( host, port ) result[#result+1] = "Config: " result[#result+1] = vars end - nmap.set_port_version(host, port) + if #result > 0 then + port.version.name = "flume-master" + port.version.product = "Apache Flume" + nmap.set_port_version(host, port) + end return stdnse.format_output(true, result) end end diff --git a/scripts/hadoop-datanode-info.nse b/scripts/hadoop-datanode-info.nse index e1b79ef31..30864a499 100644 --- a/scripts/hadoop-datanode-info.nse +++ b/scripts/hadoop-datanode-info.nse @@ -48,12 +48,12 @@ action = function( host, port ) local response = http.get( host, port, uri ) stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response")) if response['status-line'] and response['status-line']:match("200%s+OK") and response['body'] then - port.version.name = "hadoop-datanode" - port.version.product = "Apache Hadoop" - nmap.set_port_version(host, port) local body = response['body']:gsub("%%","%%%%") stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body)) if body:match("([^][\"]+)\">Log") then + port.version.name = "hadoop-datanode" + port.version.product = "Apache Hadoop" + nmap.set_port_version(host, port) local logs = body:match("([^][\"]+)\">Log") stdnse.print_debug(1, ("%s: Logs %s"):format(SCRIPT_NAME,logs)) table.insert(result, ("Logs: %s"):format(logs)) diff --git a/scripts/hadoop-jobtracker-info.nse b/scripts/hadoop-jobtracker-info.nse index 8f9312071..46542fe48 100644 --- a/scripts/hadoop-jobtracker-info.nse +++ b/scripts/hadoop-jobtracker-info.nse @@ -115,8 +115,6 @@ action = function( host, port ) stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response")) if response['status-line'] and response['status-line']:match("200%s+OK") and response['body'] then stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,response['body'])) - port.version.name = "hadoop-jobtracker" - port.version.product = "Apache Hadoop" if response['body']:match("State:%s*([^][<]+)") then local state = response['body']:match("State:%s*([^][<]+)") stdnse.print_debug(1, ("%s: State %s"):format(SCRIPT_NAME,state)) @@ -150,7 +148,6 @@ action = function( host, port ) stdnse.print_debug(1, ("%s: Log Files %s"):format(SCRIPT_NAME,logfiles)) table.insert(result, ("Log Files: %s"):format(logfiles)) end - nmap.set_port_version(host, port) local tasktrackers = get_tasktrackers (host, port) if next(tasktrackers) then table.insert(result, "Tasktrackers: ") @@ -161,6 +158,11 @@ action = function( host, port ) table.insert(result, "Userhistory: ") table.insert(result, userhistory) end + if #result > 0 then + port.version.name = "hadoop-jobtracker" + port.version.product = "Apache Hadoop" + nmap.set_port_version(host, port) + end return stdnse.format_output(true, result) end end diff --git a/scripts/hadoop-namenode-info.nse b/scripts/hadoop-namenode-info.nse index a2068d285..bf6a70416 100644 --- a/scripts/hadoop-namenode-info.nse +++ b/scripts/hadoop-namenode-info.nse @@ -95,8 +95,6 @@ action = function( host, port ) local body = response['body']:gsub("%%","%%%%") local capacity = {} stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body)) - port.version.name = "hadoop-namenode" - port.version.product = "Apache Hadoop" if body:match("Started:%s*([^][<]+)") then local start = body:match("Started:%s*([^][<]+)") stdnse.print_debug(1, ("%s: Started %s"):format(SCRIPT_NAME,start)) @@ -139,7 +137,6 @@ action = function( host, port ) table.insert(result,"Total\tUsed (DFS)\tUsed (Non DFS)\tRemaining") table.insert(result, ("%s\t%s\t%s\t%s"):format(capacity[3],capacity[4],capacity[5],capacity[6])) end - nmap.set_port_version(host, port) local datanodes_live = get_datanodes(host,port, "LIVE") if next(datanodes_live) then table.insert(result, "Datanodes (Live): ") @@ -150,6 +147,11 @@ action = function( host, port ) table.insert(result, "Datanodes (Dead): ") table.insert(result, datanodes_dead) end + if #result > 0 then + port.version.name = "hadoop-namenode" + port.version.product = "Apache Hadoop" + nmap.set_port_version(host, port) + end return stdnse.format_output(true, result) end end diff --git a/scripts/hadoop-secondary-namenode-info.nse b/scripts/hadoop-secondary-namenode-info.nse index 59da027d3..4a816c9fc 100644 --- a/scripts/hadoop-secondary-namenode-info.nse +++ b/scripts/hadoop-secondary-namenode-info.nse @@ -65,8 +65,6 @@ action = function( host, port ) local body = response['body']:gsub("%%","%%%%") local stats = {} stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body)) - port.version.name = "hadoop-secondary-namenode" - port.version.product = "Apache Hadoop" -- Page isn't valid html :( for i in string.gmatch(body,"\n[%w%s]+:%s+[^][\n]+") do table.insert(stats,i:match(":%s+([^][\n]+)")) @@ -101,7 +99,11 @@ action = function( host, port ) table.insert(result, ("Checkpoint Period: %s"):format(stats[4])) table.insert(result, ("Checkpoint: Size %s"):format(stats[5])) end - nmap.set_port_version(host, port) + if #result > 0 then + port.version.name = "hadoop-secondary-namenode" + port.version.product = "Apache Hadoop" + nmap.set_port_version(host, port) + end if target.ALLOW_NEW_TARGETS then if stats[1]:match("([^][/]+)") then local newtarget = stats[1]:match("([^][/]+)") diff --git a/scripts/hadoop-tasktracker-info.nse b/scripts/hadoop-tasktracker-info.nse index b7b56a420..342b65183 100644 --- a/scripts/hadoop-tasktracker-info.nse +++ b/scripts/hadoop-tasktracker-info.nse @@ -54,8 +54,6 @@ action = function( host, port ) if response['status-line'] and response['status-line']:match("200%s+OK") and response['body'] then local body = response['body']:gsub("%%","%%%%") stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body)) - port.version.name = "hadoop-tasktracker" - port.version.product = "Apache Hadoop" if response['body']:match("Version:%s*([^][<]+)") then local version = response['body']:match("Version:%s*([^][<]+)") local versionNo = version:match("([^][,]+)") @@ -74,7 +72,11 @@ action = function( host, port ) stdnse.print_debug(1, ("%s: Logs %s"):format(SCRIPT_NAME,logs)) table.insert(result, ("Logs: %s"):format(logs)) end - nmap.set_port_version(host, port) + if #result > 0 then + port.version.name = "hadoop-tasktracker" + port.version.product = "Apache Hadoop" + nmap.set_port_version(host, port) + end return stdnse.format_output(true, result) end end diff --git a/scripts/hbase-master-info.nse b/scripts/hbase-master-info.nse index 5a0ef543d..0efd34b76 100644 --- a/scripts/hbase-master-info.nse +++ b/scripts/hbase-master-info.nse @@ -67,8 +67,6 @@ action = function( host, port ) if response['status-line'] and response['status-line']:match("200%s+OK") and response['body'] then local body = response['body']:gsub("%%","%%%%") stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body)) - port.version.name = "hbase-master" - port.version.product = "Apache Hadoop Hbase" if body:match("HBase%s+Version([^][<]+)") then local version = body:match("HBase%s+Version([^][<]+)"):gsub("%s+", " ") stdnse.print_debug(1, ("%s:Hbase Version %s"):format(SCRIPT_NAME,version)) @@ -127,11 +125,15 @@ action = function( host, port ) end end end - nmap.set_port_version(host, port) if next(region_servers) then table.insert(result,"Region Servers:") table.insert(result,region_servers) end + if #result > 0 then + port.version.name = "hbase-master" + port.version.product = "Apache Hadoop Hbase" + nmap.set_port_version(host, port) + end return stdnse.format_output(true, result) end end diff --git a/scripts/hbase-region-info.nse b/scripts/hbase-region-info.nse index 130745179..490c51e77 100644 --- a/scripts/hbase-region-info.nse +++ b/scripts/hbase-region-info.nse @@ -62,8 +62,6 @@ action = function( host, port ) if response['status-line'] and response['status-line']:match("200%s+OK") and response['body'] then local body = response['body']:gsub("%%","%%%%") stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body)) - port.version.name = "hbase-region" - port.version.product = "Apache Hadoop Hbase" if body:match("HBase%s+Version([^][<]+)") then local version = body:match("HBase%s+Version([^][<]+)"):gsub("%s+", " ") stdnse.print_debug(1, ("%s:Hbase Version %s"):format(SCRIPT_NAME,version)) @@ -92,7 +90,11 @@ action = function( host, port ) end end end - nmap.set_port_version(host, port) + if #result > 0 then + port.version.name = "hbase-region" + port.version.product = "Apache Hadoop Hbase" + nmap.set_port_version(host, port) + end return stdnse.format_output(true, result) end end