1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Remove useless calls to string.format

stdnse.print_debug accepts a format string and arguments, making
string.format redundant in calls of this form:

stdnse.print_debug(1, string.format("%s: error", SCRIPT_NAME))
stdnse.print_debug(("length %d"):format(#tab))

These can be rewritten as:

stdnse.print_debug(1, "%s: error", SCRIPT_NAME)
stdnse.print_debug("length %d", #tab)
This commit is contained in:
dmiller
2014-02-13 15:47:41 +00:00
parent b73c3aa60f
commit a084340b6d
27 changed files with 440 additions and 430 deletions

View File

@@ -385,8 +385,9 @@ SERVICES = {
if ( octet1 ~= 127 ) then
-- This should'nt happen :P
stdnse.print_debug(string.format(
"The request made to dnsbl.httpbl.org was considered invalid (%i)", octet1))
stdnse.print_debug(
"The request made to dnsbl.httpbl.org was considered invalid (%i)",
octet1)
elseif ( "short" == self.mode ) then
return { state = "ATTACK" }
else
@@ -625,7 +626,7 @@ Helper = {
local svc_result = svc:resp_parser(answer)
if ( not(svc_result) ) then
local resp = ( #answer > 0 and ("UNKNOWN (%s)"):format(answer[1]) or "UNKNOWN" )
stdnse.print_debug(2, ("%s received %s"):format(name, resp))
stdnse.print_debug(2, "%s received %s", name, resp)
end
if ( svc_result ) then

View File

@@ -222,7 +222,7 @@ end
function searchRequest( socket, params )
local searchResEntries = { errorMessage="", resultCode = 0}
local catch = function() socket:close() stdnse.print_debug(string.format("SearchRequest failed")) end
local catch = function() socket:close() stdnse.print_debug("SearchRequest failed") end
local try = nmap.new_try(catch)
local attributes = params.attributes
local request = encode(params.baseObject)
@@ -340,7 +340,7 @@ end
-- @return err string containing error message
function bindRequest( socket, params )
local catch = function() socket:close() stdnse.print_debug(string.format("bindRequest failed")) end
local catch = function() socket:close() stdnse.print_debug("bindRequest failed") end
local try = nmap.new_try(catch)
local ldapAuth = encode( { _ldaptype = 80, params.password } )
local bindReq = encode( params.version ) .. encode( params.username ) .. ldapAuth
@@ -393,7 +393,7 @@ end
function unbindRequest( socket )
local ldapMsg, packet
local catch = function() socket:close() stdnse.print_debug(string.format("bindRequest failed")) end
local catch = function() socket:close() stdnse.print_debug("bindRequest failed") end
local try = nmap.new_try(catch)
local encoder = asn1.ASN1Encoder:new()

View File

@@ -558,7 +558,7 @@ function query(socket, data)
--Create an error handler
local catch = function()
socket:close()
stdnse.print_debug(string.format("Query failed"))
stdnse.print_debug("Query failed")
end
local try = nmap.new_try(catch)

View File

@@ -3926,7 +3926,7 @@ function lsa_enum_users(host)
status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids)
if(status == false) then
stdnse.print_debug(1, string.format("Error looking up RIDs: %s", lookupsids2_result))
stdnse.print_debug(1, "Error looking up RIDs: %s", lookupsids2_result)
else
-- Put the details for each name into an array
-- NOTE: Be sure to mirror any changes here in the next bit!
@@ -3960,7 +3960,7 @@ function lsa_enum_users(host)
-- Try converting this group of RIDs into names
status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids)
if(status == false) then
stdnse.print_debug(1, string.format("Error looking up RIDs: %s", lookupsids2_result))
stdnse.print_debug(1, "Error looking up RIDs: %s", lookupsids2_result)
else
-- Put the details for each name into an array
for j = 1, #lookupsids2_result['names']['names'], 1 do

File diff suppressed because it is too large Load Diff

View File

@@ -89,7 +89,7 @@ v2 =
elseif ( authtype == 0 ) then
response.success = true
else
stdnse.print_debug( ("unknown auth type: %d"):format(authtype) )
stdnse.print_debug("unknown auth type: %d", authtype)
end
response.authtype = authtype
@@ -138,7 +138,7 @@ v2 =
return pos, response
end
else
stdnse.print_debug( ("Missing decoder for %d"):format(ptype) )
stdnse.print_debug("Missing decoder for %d", ptype)
return -1, ("Missing decoder for %d"):format(ptype)
end
return -1, "Decoding failed"
@@ -601,7 +601,7 @@ function printErrorMessage( dberror )
return
end
for k, v in pairs(dberror) do
stdnse.print_debug( ("%s=%s"):format(k, v) )
stdnse.print_debug("%s=%s", k, v)
end
end

View File

@@ -1445,9 +1445,9 @@ local function start_session_extended(smb, log_errors, overrides)
-- Check if they were logged in as a guest
if(log_errors == nil or log_errors == true) then
if(smb['is_guest'] == 1) then
stdnse.print_debug(1, string.format("SMB: Extended login to %s as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", smb['ip'], domain, stdnse.string_or_blank(username)))
stdnse.print_debug(1, "SMB: Extended login to %s as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", smb['ip'], domain, stdnse.string_or_blank(username))
else
stdnse.print_debug(2, string.format("SMB: Extended login to %s as %s\\%s succeeded", smb['ip'], domain, stdnse.string_or_blank(username)))
stdnse.print_debug(2, "SMB: Extended login to %s as %s\\%s succeeded", smb['ip'], domain, stdnse.string_or_blank(username))
end
end

View File

@@ -60,16 +60,16 @@ action = function(host, port)
if not bytes then bytes = 512 else tonumber(bytes) end
-- Connect and retrieve acarsd info in XML format over TCP
stdnse.print_debug(1, ("%s: Connecting to %s:%s [Timeout: %ss]"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, timeout))
stdnse.print_debug(1, "%s: Connecting to %s:%s [Timeout: %ss]", SCRIPT_NAME, host.targetname or host.ip, port.number, timeout)
local status, data = comm.get_banner(host, port, {timeout=timeout*1000,bytes=bytes})
if not status or not data then
stdnse.print_debug(1, ("%s: Retrieving data from %s:%s failed [Timeout expired]"):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: Retrieving data from %s:%s failed [Timeout expired]", SCRIPT_NAME, host.targetname or host.ip, port.number)
return
end
-- Check if retrieved data is valid acarsd data
if not string.match(data, "acarsd") then
stdnse.print_debug(1, ("%s: %s:%s is not an acarsd Daemon."):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: %s:%s is not an acarsd Daemon.", SCRIPT_NAME, host.targetname or host.ip, port.number)
return
end
@@ -85,7 +85,7 @@ action = function(host, port)
-- Check for unrestricted access -- Parse daemon info
else
stdnse.print_debug(1, ("%s: Parsing data from %s:%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: Parsing data from %s:%s", SCRIPT_NAME, host.targetname or host.ip, port.number)
local vars = {
{"Version","Version"},
{"API Version","APIVersion"},

View File

@@ -75,7 +75,7 @@ action = function( host, port )
end
stdnse.print_debug( string.format("Trying %s/%s ...", username, password ) )
stdnse.print_debug("Trying %s/%s ...", username, password)
status, response = helper:Login( username, password )
-- if the response is "Parameter error." we're dealing with Netatalk

View File

@@ -93,7 +93,7 @@ local function getAttributeAsInt( data, name )
pos, len = bin.unpack( ">I", data, pos )
if ( len ~= 4 ) then
stdnse.print_debug( string.format("Unexpected length returned: %d", len ) )
stdnse.print_debug("Unexpected length returned: %d", len )
return
end
@@ -199,7 +199,7 @@ parseItem = function( data, len )
if itemFetcher[name] then
pos, item[name] = itemFetcher[name](data, pos )
else
stdnse.print_debug( string.format("No itemfetcher for: %s", name) )
stdnse.print_debug("No itemfetcher for: %s", name)
break
end

View File

@@ -140,9 +140,9 @@ function parse_db2_packet(packet)
response.info = packet.data:sub(info_offset, info_offset + response.info_length - (info_offset-info_length_offset))
if(nmap.debugging() > 3) then
stdnse.print_debug( string.format("db2-das-info: version: %s", response.version) )
stdnse.print_debug( string.format("db2-das-info: info_length: %d", response.info_length) )
stdnse.print_debug( string.format("db2-das-info: response.info:len(): %d", response.info:len()))
stdnse.print_debug("db2-das-info: version: %s", response.version)
stdnse.print_debug("db2-das-info: info_length: %d", response.info_length)
stdnse.print_debug("db2-das-info: response.info:len(): %d", response.info:len())
end
return response
@@ -198,20 +198,20 @@ function read_db2_packet(socket)
total_len = header_len + packet.header.data_len
if(nmap.debugging() > 3) then
stdnse.print_debug( string.format("db2-das-info: data_len: %d", packet.header.data_len) )
stdnse.print_debug( string.format("db2-das-info: buf_len: %d", buf:len()))
stdnse.print_debug( string.format("db2-das-info: total_len: %d", total_len))
stdnse.print_debug("db2-das-info: data_len: %d", packet.header.data_len)
stdnse.print_debug("db2-das-info: buf_len: %d", buf:len())
stdnse.print_debug("db2-das-info: total_len: %d", total_len)
end
-- do we have all data as specified by data_len?
while total_len > buf:len() do
-- if not read additional bytes
if(nmap.debugging() > 3) then
stdnse.print_debug( string.format("db2-das-info: Reading %d additional bytes", total_len - buf:len()))
stdnse.print_debug("db2-das-info: Reading %d additional bytes", total_len - buf:len())
end
local tmp = try( socket:receive_bytes( total_len - buf:len() ) )
if(nmap.debugging() > 3) then
stdnse.print_debug( string.format("db2-das-info: Read %d bytes", tmp:len()))
stdnse.print_debug("db2-das-info: Read %d bytes", tmp:len())
end
buf = buf .. tmp
end

View File

@@ -20,7 +20,7 @@ Information gathered:
If this script is run wth -v, it will output lots more info.
Use the <code>newtargets</code> script argument to add discovered hosts to
the Nmap scan queue.
the Namp scan queue.
]]
---
@@ -95,7 +95,7 @@ end
function add_target(hostname)
if target.ALLOW_NEW_TARGETS then
stdnse.print_debug(1, ("%s: Added target: %s"):format(SCRIPT_NAME, hostname))
stdnse.print_debug(1, "%s: Added target: %s", SCRIPT_NAME, hostname)
local status,err = target.add(hostname)
end
end
@@ -113,11 +113,15 @@ end
parse_page = function( host, port, uri, intresting_keys )
local result = {}
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
stdnse.print_debug(1, "%s: Status %s",
SCRIPT_NAME, response['status-line'] or "No Response")
if response['status-line'] and response['status-line']:match("200%s+OK")
and response['body'] then
local body = response['body']:gsub("%%","%%%%")
for name,value in string.gmatch(body,"<tr><th>([^][<]+)</th>%s*<td><div%sclass=[^][>]+>([^][<]+)") do
stdnse.print_debug(1, ("%s: %s=%s "):format(SCRIPT_NAME,name,value:gsub("^%s*(.-)%s*$", "%1")))
for name,value in string.gmatch(body,
"<tr><th>([^][<]+)</th>%s*<td><div%sclass=[^][>]+>([^][<]+)") do
stdnse.print_debug(1, "%s: %s=%s ",
SCRIPT_NAME, name, value:gsub("^%s*(.-)%s*$", "%1"))
if nmap.verbosity() > 1 then
result[#result+1] = ("%s: %s"):format(name,value:gsub("^%s*(.-)%s*$", "%1"))
else
@@ -169,31 +173,36 @@ action = function( host, port )
local nodes = { }
local zookeepers = { }
local hbasemasters = { }
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s",
SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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
stdnse.print_debug(1, "%s: Status %s",
SCRIPT_NAME, response['status-line'] or "No Response")
if response['status-line'] and response['status-line']:match("200%s+OK")
and response['body'] then
local body = response['body']:gsub("%%","%%%%")
local capacity = {}
stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME, body)
if body:match("Version:%s*</b>([^][,]+)") then
local version = body:match("Version:%s*</b>([^][,]+)")
stdnse.print_debug(1, ("%s: Version %s"):format(SCRIPT_NAME,version))
stdnse.print_debug(1, "%s: Version %s", SCRIPT_NAME, version)
result[#result+1] = ("Version: %s"):format(version)
port.version.version = version
end
if body:match("Compiled:%s*</b>([^][<]+)") then
local compiled = body:match("Compiled:%s*</b>([^][<]+)")
stdnse.print_debug(1, ("%s: Compiled %s"):format(SCRIPT_NAME,compiled))
stdnse.print_debug(1, "%s: Compiled %s", SCRIPT_NAME, compiled)
result[#result+1] = ("Compiled: %s"):format(compiled)
end
if body:match("ServerID:%s*([^][<]+)") then
local upgrades = body:match("ServerID:%s*([^][<]+)")
stdnse.print_debug(1, ("%s: ServerID %s"):format(SCRIPT_NAME,upgrades))
stdnse.print_debug(1, "%s: ServerID %s", SCRIPT_NAME, upgrades)
result[#result] = ("ServerID: %s"):format(upgrades)
end
for logical,physical,hostname in string.gmatch(body,"<tr><td>([%w%.-_:]+)</td><td>([%w%.]+)</td><td>([%w%.]+)</td>") do
stdnse.print_debug(2, ("%s: %s (%s) %s"):format(SCRIPT_NAME,physical,logical,hostname))
for logical,physical,hostname in string.gmatch(body,
"<tr><td>([%w%.-_:]+)</td><td>([%w%.]+)</td><td>([%w%.]+)</td>") do
stdnse.print_debug(2, "%s: %s (%s) %s",
SCRIPT_NAME, physical, logical, hostname)
if (table_count(nodes, hostname) == 0) then
nodes[#nodes+1] = hostname
add_target(hostname)

View File

@@ -108,16 +108,16 @@ action = function( host, port )
end
-- Retrieve grid data in XML format over TCP
stdnse.print_debug(1, ("%s: Connecting to %s:%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: Connecting to %s:%s", SCRIPT_NAME, host.targetname or host.ip, port.number)
local status, data = comm.get_banner(host, port, {timeout=timeout*1000,bytes=bytes})
if not status then
stdnse.print_debug(1, ("%s: Timeout exceeded for %s:%s (Timeout: %ss)."):format(SCRIPT_NAME, host.targetname or host.ip, port.number, timeout))
stdnse.print_debug(1, "%s: Timeout exceeded for %s:%s (Timeout: %ss).", SCRIPT_NAME, host.targetname or host.ip, port.number, timeout)
return
end
-- Parse daemon info
if not string.match(data, "<!DOCTYPE GANGLIA_XML") then
stdnse.print_debug(1, ("%s: %s:%s is not a Ganglia Daemon."):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: %s:%s is not a Ganglia Daemon.", SCRIPT_NAME, host.targetname or host.ip, port.number)
return
elseif string.match(data, '<GANGLIA_XML VERSION="([^"]*)" SOURCE="gmond"') then
table.insert(result, "Service: Ganglia Monitoring Daemon")
@@ -130,7 +130,7 @@ action = function( host, port )
local grid = string.match(data, '<GRID NAME="([^"]*)" ')
if grid then table.insert(result, string.format("Grid Name: %s", grid)) end
else
stdnse.print_debug(1, ("%s: %s:%s did not supply Ganglia daemon details."):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: %s:%s did not supply Ganglia daemon details.", SCRIPT_NAME, host.targetname or host.ip, port.number)
return
end

View File

@@ -44,18 +44,18 @@ action = function( host, port )
local result = {}
local uri = "/browseDirectory.jsp"
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response"))
stdnse.print_debug(1, "%s: Status %s", SCRIPT_NAME,response['status-line'] or "No Response")
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))
stdnse.print_debug(2, "%s: Body %s\n", 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))
stdnse.print_debug(1, "%s: Logs %s", SCRIPT_NAME,logs)
table.insert(result, ("Logs: %s"):format(logs))
end
return stdnse.format_output(true, result)

View File

@@ -62,18 +62,18 @@ end
get_userhistory = function( host, port )
local results = {}
local uri = "/jobhistory.jsp?pageno=-1&search="
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response"))
stdnse.print_debug(1, "%s: Status %s", SCRIPT_NAME,response['status-line'] or "No Response")
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))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,body)
for line in string.gmatch(body, "[^\n]+") do
stdnse.print_debug(3, ("%s: Line %s\n"):format(SCRIPT_NAME,line))
stdnse.print_debug(3, "%s: Line %s\n", SCRIPT_NAME,line)
if line:match("job_[%d_]+") then
local user = line:match("<td>([^][<>]+)</td></tr>")
local job_time = line:match("</td><td>([^][<]+)")
stdnse.print_debug(1, ("%s: User: %s (%s)"):format(SCRIPT_NAME,user,job_time))
stdnse.print_debug(1, "%s: User: %s (%s)", SCRIPT_NAME,user,job_time)
table.insert( results, ("User: %s (%s)"):format(user,job_time))
end
end
@@ -83,21 +83,21 @@ end
get_tasktrackers = function( host, port )
local results = {}
local uri = "/machines.jsp?type=active"
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response"))
stdnse.print_debug(1, "%s: Status %s", 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']))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,response['body'])
for line in string.gmatch(response['body'], "[^\n]+") do
stdnse.print_debug(3, ("%s: Line %s\n"):format(SCRIPT_NAME,line))
stdnse.print_debug(3, "%s: Line %s\n", SCRIPT_NAME,line)
if line:match("href=\"[%w]+://([%w%.:]+)/\">tracker") then
local tasktracker = line:match("href=\".*//([%w%.:]+)/\">tracker")
stdnse.print_debug(1, ("%s: taskstracker %s"):format(SCRIPT_NAME,tasktracker))
stdnse.print_debug(1, "%s: taskstracker %s", SCRIPT_NAME,tasktracker)
table.insert( results, tasktracker)
if target.ALLOW_NEW_TARGETS then
if tasktracker:match("([%w%.]+)") then
local newtarget = tasktracker:match("([%w%.]+)")
stdnse.print_debug(1, ("%s: Added target: %s"):format(SCRIPT_NAME, newtarget))
stdnse.print_debug(1, "%s: Added target: %s", SCRIPT_NAME, newtarget)
local status,err = target.add(newtarget)
end
end
@@ -110,42 +110,42 @@ action = function( host, port )
local result = {}
local uri = "/jobtracker.jsp"
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response"))
stdnse.print_debug(1, "%s: Status %s", 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']))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,response['body'])
if response['body']:match("State:</b>%s*([^][<]+)") then
local state = response['body']:match("State:</b>%s*([^][<]+)")
stdnse.print_debug(1, ("%s: State %s"):format(SCRIPT_NAME,state))
stdnse.print_debug(1, "%s: State %s", SCRIPT_NAME,state)
table.insert(result, ("State: %s"):format(state))
end
if response['body']:match("Started:</b>%s*([^][<]+)") then
local started = response['body']:match("Started:</b>%s*([^][<]+)")
stdnse.print_debug(1, ("%s: Started %s"):format(SCRIPT_NAME,started))
stdnse.print_debug(1, "%s: Started %s", SCRIPT_NAME,started)
table.insert(result, ("Started: %s"):format(started))
end
if response['body']:match("Version:</b>%s*([^][<]+)") then
local version = response['body']:match("Version:</b>%s*([^][<]+)")
local versionNo = version:match("([^][,]+)")
local versionHash = version:match("[^][,]+%s+(%w+)")
stdnse.print_debug(1, ("%s: Version %s (%s)"):format(SCRIPT_NAME,versionNo,versionHash))
stdnse.print_debug(1, "%s: Version %s (%s)", SCRIPT_NAME,versionNo,versionHash)
table.insert(result, ("Version: %s (%s)"):format(versionNo,versionHash))
port.version.version = versionNo
end
if response['body']:match("Compiled:</b>%s*([^][<]+)") then
local compiled = response['body']:match("Compiled:</b>%s*([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s: Compiled %s"):format(SCRIPT_NAME,compiled))
stdnse.print_debug(1, "%s: Compiled %s", SCRIPT_NAME,compiled)
table.insert(result, ("Compiled: %s"):format(compiled))
end
if response['body']:match("Identifier:</b>%s*([^][<]+)") then
local identifier = response['body']:match("Identifier:</b>%s*([^][<]+)")
stdnse.print_debug(1, ("%s: Identifier %s"):format(SCRIPT_NAME,identifier))
stdnse.print_debug(1, "%s: Identifier %s", SCRIPT_NAME,identifier)
table.insert(result, ("Identifier: %s"):format(identifier))
end
if response['body']:match("([%w/]+)\">Log<") then
local logfiles = response['body']:match("([%w/-_:%%]+)\">Log<")
stdnse.print_debug(1, ("%s: Log Files %s"):format(SCRIPT_NAME,logfiles))
stdnse.print_debug(1, "%s: Log Files %s", SCRIPT_NAME,logfiles)
table.insert(result, ("Log Files: %s"):format(logfiles))
end
local tasktrackers = get_tasktrackers (host, port)

View File

@@ -62,20 +62,20 @@ end
get_datanodes = function( host, port, Status )
local result = {}
local uri = "/dfsnodelist.jsp?whatNodes=" .. Status
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response" ))
stdnse.print_debug(1, "%s: Status %s", SCRIPT_NAME,response['status-line'] or "No Response" )
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))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,body)
for datanodetmp in string.gmatch(body, "[%w%.:-_]+/browseDirectory.jsp") do
local datanode = datanodetmp:gsub("/browseDirectory.jsp","")
stdnse.print_debug(1, ("%s: Datanode %s"):format(SCRIPT_NAME,datanode))
stdnse.print_debug(1, "%s: Datanode %s", SCRIPT_NAME,datanode)
table.insert(result, ("Datanode: %s"):format(datanode))
if target.ALLOW_NEW_TARGETS then
if datanode:match("([%w%.]+)") then
local newtarget = datanode:match("([%w%.]+)")
stdnse.print_debug(1, ("%s: Added target: %s"):format(SCRIPT_NAME, newtarget))
stdnse.print_debug(1, "%s: Added target: %s", SCRIPT_NAME, newtarget)
local status,err = target.add(newtarget)
end
end
@@ -88,51 +88,51 @@ action = function( host, port )
local result = {}
local uri = "/dfshealth.jsp"
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response"))
stdnse.print_debug(1, "%s: Status %s", SCRIPT_NAME,response['status-line'] or "No Response")
if response['status-line'] and response['status-line']:match("200%s+OK") and response['body'] then
local body = response['body']:gsub("%%","%%%%")
local capacity = {}
stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,body)
if body:match("Started:%s*<td>([^][<]+)") then
local start = body:match("Started:%s*<td>([^][<]+)")
stdnse.print_debug(1, ("%s: Started %s"):format(SCRIPT_NAME,start))
stdnse.print_debug(1, "%s: Started %s", SCRIPT_NAME,start)
table.insert(result, ("Started: %s"):format(start))
end
if body:match("Version:%s*<td>([^][<]+)") then
local version = body:match("Version:%s*<td>([^][<]+)")
stdnse.print_debug(1, ("%s: Version %s"):format(SCRIPT_NAME,version))
stdnse.print_debug(1, "%s: Version %s", SCRIPT_NAME,version)
table.insert(result, ("Version: %s"):format(version))
port.version.version = version
end
if body:match("Compiled:%s*<td>([^][<]+)") then
local compiled = body:match("Compiled:%s*<td>([^][<]+)")
stdnse.print_debug(1, ("%s: Compiled %s"):format(SCRIPT_NAME,compiled))
stdnse.print_debug(1, "%s: Compiled %s", SCRIPT_NAME,compiled)
table.insert(result, ("Compiled: %s"):format(compiled))
end
if body:match("Upgrades:%s*<td>([^][<]+)") then
local upgrades = body:match("Upgrades:%s*<td>([^][<]+)")
stdnse.print_debug(1, ("%s: Upgrades %s"):format(SCRIPT_NAME,upgrades))
stdnse.print_debug(1, "%s: Upgrades %s", SCRIPT_NAME,upgrades)
table.insert(result, ("Upgrades: %s"):format(upgrades))
end
if body:match("([^][\"]+)\">Browse") then
local filesystem = body:match("([^][\"]+)\">Browse")
stdnse.print_debug(1, ("%s: Filesystem %s"):format(SCRIPT_NAME,filesystem))
stdnse.print_debug(1, "%s: Filesystem %s", SCRIPT_NAME,filesystem)
table.insert(result, ("Filesystem: %s"):format(filesystem))
end
if body:match("([^][\"]+)\">Namenode") then
local logs = body:match("([^][\"]+)\">Namenode")
stdnse.print_debug(1, ("%s: Logs %s"):format(SCRIPT_NAME,logs))
stdnse.print_debug(1, "%s: Logs %s", SCRIPT_NAME,logs)
table.insert(result, ("Logs: %s"):format(logs))
end
for i in string.gmatch(body, "[%d%.]+%s[KMGTP]B") do
table.insert(capacity,i)
end
if #capacity >= 6 then
stdnse.print_debug(1, ("%s: Total %s"):format(SCRIPT_NAME,capacity[3]))
stdnse.print_debug(1, ("%s: Used DFS (NonDFS) %s (%s)"):format(SCRIPT_NAME,capacity[4],capacity[5]))
stdnse.print_debug(1, ("%s: Remaining %s"):format(SCRIPT_NAME,capacity[6]))
stdnse.print_debug(1, "%s: Total %s", SCRIPT_NAME,capacity[3])
stdnse.print_debug(1, "%s: Used DFS (NonDFS) %s (%s)", SCRIPT_NAME,capacity[4],capacity[5])
stdnse.print_debug(1, "%s: Remaining %s", SCRIPT_NAME,capacity[6])
table.insert(result,"Storage:")
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]))

View File

@@ -59,39 +59,39 @@ action = function( host, port )
local result = {}
local uri = "/status.jsp"
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Resposne"))
stdnse.print_debug(1, "%s: Status %s", SCRIPT_NAME,response['status-line'] or "No Resposne")
if response['status-line'] and response['status-line']:match("200%s+OK") and response['body'] then
local body = response['body']:gsub("%%","%%%%")
local stats = {}
stdnse.print_debug(2, ("%s: Body %s\n"):format(SCRIPT_NAME,body))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,body)
-- Page isn't valid html :(
for i in string.gmatch(body,"\n[%w%s]+:%s+[^][\n]+") do
table.insert(stats,i:match(":%s+([^][\n]+)"))
end
if #stats == 5 then
stdnse.print_debug(1, ("%s: namenode %s"):format(SCRIPT_NAME,stats[1]))
stdnse.print_debug(1, ("%s: Start %s"):format(SCRIPT_NAME,stats[2]))
stdnse.print_debug(1, ("%s: Last Checkpoint %s"):format(SCRIPT_NAME,stats[3]))
stdnse.print_debug(1, ("%s: Checkpoint Period %s"):format(SCRIPT_NAME,stats[4]))
stdnse.print_debug(1, ("%s: Checkpoint Size %s"):format(SCRIPT_NAME,stats[5]))
stdnse.print_debug(1, "%s: namenode %s", SCRIPT_NAME,stats[1])
stdnse.print_debug(1, "%s: Start %s", SCRIPT_NAME,stats[2])
stdnse.print_debug(1, "%s: Last Checkpoint %s", SCRIPT_NAME,stats[3])
stdnse.print_debug(1, "%s: Checkpoint Period %s", SCRIPT_NAME,stats[4])
stdnse.print_debug(1, "%s: Checkpoint Size %s", SCRIPT_NAME,stats[5])
table.insert(result, ("Start: %s"):format(stats[2]))
end
if body:match("Version:%s*</td><td>([^][\n]+)") then
local version = body:match("Version:%s*</td><td>([^][\n]+)")
stdnse.print_debug(1, ("%s: Version %s"):format(SCRIPT_NAME,version))
stdnse.print_debug(1, "%s: Version %s", SCRIPT_NAME,version)
table.insert(result, ("Version: %s"):format(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.print_debug(1, ("%s: Compiled %s"):format(SCRIPT_NAME,compiled))
stdnse.print_debug(1, "%s: Compiled %s", SCRIPT_NAME,compiled)
table.insert(result, ("Compiled: %s"):format(compiled))
end
if body:match("([^][\"]+)\">Logs") then
local logs = body:match("([^][\"]+)\">Logs")
stdnse.print_debug(1, ("%s: Logs %s"):format(SCRIPT_NAME,logs))
stdnse.print_debug(1, "%s: Logs %s", SCRIPT_NAME,logs)
table.insert(result, ("Logs: %s"):format(logs))
end
if #stats == 5 then
@@ -108,7 +108,7 @@ action = function( host, port )
if target.ALLOW_NEW_TARGETS then
if stats[1]:match("([^][/]+)") then
local newtarget = stats[1]:match("([^][/]+)")
stdnse.print_debug(1, ("%s: Added target: %s"):format(SCRIPT_NAME, newtarget))
stdnse.print_debug(1, "%s: Added target: %s", SCRIPT_NAME, newtarget)
local status,err = target.add(newtarget)
end
end

View File

@@ -48,28 +48,28 @@ action = function( host, port )
local result = {}
local uri = "/tasktracker.jsp"
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response"))
stdnse.print_debug(1, "%s: Status %s", SCRIPT_NAME,response['status-line'] or "No Response")
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))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,body)
if response['body']:match("Version:</b>%s*([^][<]+)") then
local version = response['body']:match("Version:</b>%s*([^][<]+)")
local versionNo = version:match("([^][,]+)")
local versionHash = version:match("[^][,]+%s+(%w+)")
stdnse.print_debug(1, ("%s: Version %s (%s)"):format(SCRIPT_NAME,versionNo,versionHash))
stdnse.print_debug(1, "%s: Version %s (%s)", SCRIPT_NAME,versionNo,versionHash)
table.insert(result, ("Version: %s (%s)"):format(versionNo,versionHash))
port.version.version = version
end
if response['body']:match("Compiled:</b>%s*([^][<]+)") then
local compiled = response['body']:match("Compiled:</b>%s*([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s: Compiled %s"):format(SCRIPT_NAME,compiled))
stdnse.print_debug(1, "%s: Compiled %s", SCRIPT_NAME,compiled)
table.insert(result, ("Compiled: %s"):format(compiled))
end
if body:match("([^][\"]+)\">Log") then
local logs = body:match("([^][\"]+)\">Log")
stdnse.print_debug(1, ("%s: Logs %s"):format(SCRIPT_NAME,logs))
stdnse.print_debug(1, "%s: Logs %s", SCRIPT_NAME,logs)
table.insert(result, ("Logs: %s"):format(logs))
end
if #result > 0 then

View File

@@ -61,65 +61,65 @@ action = function( host, port )
local result = {}
local region_servers = {}
local uri = "/master.jsp"
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response"))
stdnse.print_debug(1, "%s: Status %s", SCRIPT_NAME,response['status-line'] or "No Response")
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))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,body)
if body:match("HBase%s+Version</td><td>([^][<]+)") then
local version = body:match("HBase%s+Version</td><td>([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s:Hbase Version %s"):format(SCRIPT_NAME,version))
stdnse.print_debug(1, "%s:Hbase Version %s", SCRIPT_NAME,version)
table.insert(result, ("Hbase Version: %s"):format(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.print_debug(1, ("%s: Hbase Compiled %s"):format(SCRIPT_NAME,compiled))
stdnse.print_debug(1, "%s: Hbase Compiled %s", SCRIPT_NAME,compiled)
table.insert(result, ("Hbase Compiled: %s"):format(compiled))
end
if body:match("Directory</td><td>([^][<]+)") then
local compiled = body:match("Directory</td><td>([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s: HBase RootDirectory %s"):format(SCRIPT_NAME,compiled))
stdnse.print_debug(1, "%s: HBase RootDirectory %s", SCRIPT_NAME,compiled)
table.insert(result, ("HBase Root Directory: %s"):format(compiled))
end
if body:match("Hadoop%s+Version</td><td>([^][<]+)") then
local version = body:match("Hadoop%s+Version</td><td>([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s: Hadoop Version %s"):format(SCRIPT_NAME,version))
stdnse.print_debug(1, "%s: Hadoop Version %s", SCRIPT_NAME,version)
table.insert(result, ("Hadoop Version: %s"):format(version))
end
if body:match("Hadoop%s+Compiled</td><td>([^][<]+)") then
local compiled = body:match("Hadoop%s+Compiled</td><td>([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s: Hadoop Compiled %s"):format(SCRIPT_NAME,compiled))
stdnse.print_debug(1, "%s: Hadoop Compiled %s", SCRIPT_NAME,compiled)
table.insert(result, ("Hadoop Compiled: %s"):format(compiled))
end
if body:match("average</td><td>([^][<]+)") then
local average = body:match("average</td><td>([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s: Average Load %s"):format(SCRIPT_NAME,average))
stdnse.print_debug(1, "%s: Average Load %s", SCRIPT_NAME,average)
table.insert(result, ("Average Load: %s"):format(average))
end
if body:match("Quorum</td><td>([^][<]+)") then
local quorum = body:match("Quorum</td><td>([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s: Zookeeper Quorum %s"):format(SCRIPT_NAME,quorum))
stdnse.print_debug(1, "%s: Zookeeper Quorum %s", SCRIPT_NAME,quorum)
table.insert(result, ("Zookeeper Quorum: %s"):format(quorum))
if target.ALLOW_NEW_TARGETS then
if quorum:match("([%w%.]+)") then
local newtarget = quorum:match("([%w%.]+)")
stdnse.print_debug(1, ("%s: Added target: %s"):format(SCRIPT_NAME, newtarget))
stdnse.print_debug(1, "%s: Added target: %s", SCRIPT_NAME, newtarget)
local status,err = target.add(newtarget)
end
end
end
for line in string.gmatch(body, "[^\n]+") do
stdnse.print_debug(3, ("%s: Line %s\n"):format(SCRIPT_NAME,line))
stdnse.print_debug(3, "%s: Line %s\n", SCRIPT_NAME,line)
if line:match("maxHeap") then
local region_server= line:match("\">([^][<]+)</a>")
stdnse.print_debug(1, ("%s: Region Server %s"):format(SCRIPT_NAME,region_server))
stdnse.print_debug(1, "%s: Region Server %s", SCRIPT_NAME,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.print_debug(1, ("%s: Added target: %s"):format(SCRIPT_NAME, newtarget))
stdnse.print_debug(1, "%s: Added target: %s", SCRIPT_NAME, newtarget)
local status,err = target.add(newtarget)
end
end

View File

@@ -56,36 +56,36 @@ action = function( host, port )
-- uri was previously "/regionserver.jsp". See
-- http://seclists.org/nmap-dev/2012/q3/903.
local uri = "/rs-status"
stdnse.print_debug(1, ("%s:HTTP GET %s:%s%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number, uri))
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
local response = http.get( host, port, uri )
stdnse.print_debug(1, ("%s: Status %s"):format(SCRIPT_NAME,response['status-line'] or "No Response"))
stdnse.print_debug(1, "%s: Status %s", SCRIPT_NAME,response['status-line'] or "No Response")
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))
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,body)
if body:match("HBase%s+Version</td><td>([^][<]+)") then
local version = body:match("HBase%s+Version</td><td>([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s:Hbase Version %s"):format(SCRIPT_NAME,version))
stdnse.print_debug(1, "%s:Hbase Version %s", SCRIPT_NAME,version)
table.insert(result, ("Hbase Version: %s"):format(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.print_debug(1, ("%s: Hbase Compiled %s"):format(SCRIPT_NAME,compiled))
stdnse.print_debug(1, "%s: Hbase Compiled %s", SCRIPT_NAME,compiled)
table.insert(result, ("Hbase Compiled: %s"):format(compiled))
end
if body:match("Metrics</td><td>([^][<]+)") then
local metrics = body:match("Metrics</td><td>([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s: Metrics %s"):format(SCRIPT_NAME,metrics))
stdnse.print_debug(1, "%s: Metrics %s", SCRIPT_NAME,metrics)
table.insert(result, ("Metrics %s"):format(metrics))
end
if body:match("Quorum</td><td>([^][<]+)") then
local quorum = body:match("Quorum</td><td>([^][<]+)"):gsub("%s+", " ")
stdnse.print_debug(1, ("%s: Zookeeper Quorum %s"):format(SCRIPT_NAME,quorum))
stdnse.print_debug(1, "%s: Zookeeper Quorum %s", SCRIPT_NAME,quorum)
table.insert(result, ("Zookeeper Quorum: %s"):format(quorum))
if target.ALLOW_NEW_TARGETS then
if quorum:match("([%w%.]+)") then
local newtarget = quorum:match("([%w%.]+)")
stdnse.print_debug(1, ("%s: Added target: %s"):format(SCRIPT_NAME, newtarget))
stdnse.print_debug(1, "%s: Added target: %s", SCRIPT_NAME, newtarget)
local status,err = target.add(newtarget)
end
end

View File

@@ -92,7 +92,7 @@ action = function(host, port)
local config_file = ""
-- Loop through vulnerable files
stdnse.print_debug(1, ("%s: Connecting to %s:%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: Connecting to %s:%s", SCRIPT_NAME, host.targetname or host.ip, port.number)
for _, path in ipairs(paths) do
-- Retrieve file
@@ -128,7 +128,7 @@ action = function(host, port)
-- No config file found
if config_file == "" then
stdnse.print_debug(1, ("%s: %s:%s is not vulnerable or connection timed out."):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: %s:%s is not vulnerable or connection timed out.", SCRIPT_NAME, host.targetname or host.ip, port.number)
return
end

View File

@@ -52,7 +52,7 @@ action = function(host, port)
local config_file = ""
-- Retrieve file
stdnse.print_debug(1, ("%s: Connecting to %s:%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: Connecting to %s:%s", SCRIPT_NAME, host.targetname or host.ip, port.number)
local data = http.get(host, port, path)
-- Check if file exists
@@ -63,7 +63,7 @@ action = function(host, port)
if string.match(data.body, '<QDocRoot version="[^"]+">') then
config_file = data.body
else
stdnse.print_debug(1, ("%s: %s:%s uses an invalid config file."):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: %s:%s uses an invalid config file.", SCRIPT_NAME, host.targetname or host.ip, port.number)
return
end

View File

@@ -174,7 +174,7 @@ function action(host,port)
local status, errmsg = ldap.bindRequest( socket, bindParam )
if not status then
stdnse.print_debug( string.format("ldap-search failed to bind: %s", errmsg) )
stdnse.print_debug("ldap-search failed to bind: %s", errmsg)
return " \n ERROR: Authentication failed"
end
-- or if ldap-brute found us something
@@ -240,7 +240,7 @@ function action(host,port)
if ( searchResEntries:match("DSID[-]0C090627") and not(username) ) then
return "ERROR: Failed to bind as the anonymous user"
else
stdnse.print_debug( string.format( "ldap.searchRequest returned: %s", searchResEntries ) )
stdnse.print_debug("ldap.searchRequest returned: %s", searchResEntries)
return
end
end

View File

@@ -63,7 +63,7 @@ discover_device_id_recursive = function(host, port, sid, start_id)
local more_follows = string.byte(result, 12)
local next_object_id = string.byte(result, 13)
local number_of_objects = string.byte(result, 14)
stdnse.print_debug(1, ("more = 0x%x, next_id = 0x%x, obj_number = 0x%x"):format(more_follows, next_object_id, number_of_objects))
stdnse.print_debug(1, "more = 0x%x, next_id = 0x%x, obj_number = 0x%x", more_follows, next_object_id, number_of_objects)
local offset = 15
for i = start_id, (number_of_objects - 1) do
local object_id = string.byte(result, offset)
@@ -71,7 +71,7 @@ discover_device_id_recursive = function(host, port, sid, start_id)
-- error data format --
if object_len == nil then break end
local object_value = string.sub(result, offset + 2, offset + 1 + object_len)
stdnse.print_debug(1, ("Object id = 0x%x, value = %s"):format(object_id, object_value))
stdnse.print_debug(1, "Object id = 0x%x, value = %s", object_id, object_value)
table.insert(objects_table, object_id + 1, object_value)
offset = offset + 2 + object_len
end

View File

@@ -105,7 +105,7 @@ action = function( host, port )
for username in usernames do
ssl_enable = not(nossl)
for password in passwords do
stdnse.print_debug( string.format("Trying %s/%s ...", username, password ) )
stdnse.print_debug("Trying %s/%s ...", username, password )
local socket = connectSocket( host, port, ssl_enable )
status, response = pg.sendStartup(socket, username, username)

View File

@@ -87,17 +87,17 @@ system commands as the 'root' user.
-- Send command as service launcher request
local req = string.format("service launcher\nstart/flags run /bin/sh /bin/sh -c \"%s\"\n", cmd)
stdnse.print_debug(1, ("%s: Connecting to %s:%s"):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: Connecting to %s:%s", SCRIPT_NAME, host.targetname or host.ip, port.number)
local status, data = comm.exchange(host, port, req, {timeout=timeout*1000,bytes=bytes})
if not status then
stdnse.print_debug(1, ("%s: Timeout exceeded for %s:%s (Timeout: %ss)."):format(SCRIPT_NAME, host.targetname or host.ip, port.number, timeout))
stdnse.print_debug(1, "%s: Timeout exceeded for %s:%s (Timeout: %ss).", SCRIPT_NAME, host.targetname or host.ip, port.number, timeout)
return
end
-- Parse response
stdnse.print_debug(2, ("%s: Received reply:\n%s"):format(SCRIPT_NAME, data))
stdnse.print_debug(2, "%s: Received reply:\n%s", SCRIPT_NAME, data)
if not string.match(data, "QCONN") then
stdnse.print_debug(1, ("%s: %s:%s is not a QNX QCONN daemon."):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: %s:%s is not a QNX QCONN daemon.", SCRIPT_NAME, host.targetname or host.ip, port.number)
return
end
@@ -107,7 +107,7 @@ system commands as the 'root' user.
local report = vulns.Report:new(SCRIPT_NAME, host, port)
return report:make_output(vuln_table)
else
stdnse.print_debug(1, ("%s: %s:%s QNX QCONN daemon is not vulnerable."):format(SCRIPT_NAME, host.targetname or host.ip, port.number))
stdnse.print_debug(1, "%s: %s:%s QNX QCONN daemon is not vulnerable.", SCRIPT_NAME, host.targetname or host.ip, port.number)
return
end

View File

@@ -98,7 +98,7 @@ local create_tftp_file_request = function(filename)
end
local check_file_present = function(host, port, filename)
stdnse.print_debug(1, ("checking file %s"):format(filename))
stdnse.print_debug(1, "checking file %s", filename)
local file_request = create_tftp_file_request(filename)
@@ -109,14 +109,14 @@ local check_file_present = function(host, port, filename)
if (not (status)) then
stdnse.print_debug(1, ("error %s"):format(lhost))
stdnse.print_debug(1, "error %s", lhost)
socket:close()
return REQUEST_ERROR
end
local bind_socket = nmap.new_socket("udp")
stdnse.print_debug(1, ("local port = %d"):format(lport))
stdnse.print_debug(1, "local port = %d", lport)
socket:send(file_request)
socket:close()
@@ -127,7 +127,7 @@ local check_file_present = function(host, port, filename)
stdnse.print_debug(1, "starting listener")
if (not (bindOK)) then
stdnse.print_debug(1, ("Error in bind %s"):format(error))
stdnse.print_debug(1, "Error in bind %s", error)
bind_socket:close()
return REQUEST_ERROR
end
@@ -136,7 +136,7 @@ local check_file_present = function(host, port, filename)
local recvOK, data = bind_socket:receive()
if (not (recvOK)) then
stdnse.print_debug(1, ("Error in receive %s"):format(data))
stdnse.print_debug(1, "Error in receive %s", data)
bind_socket:close()
return REQUEST_ERROR
end