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

more stdnse.print_debug -> stdnse.debug

$ sed -i 's/stdnse.print_debug( *\([0-9]*\) *, *" *%s *:* *\([^"]*\)" *, *SCRIPT_NAME/stdnse.debug\1("\2"/' *.nse
$ sed -i 's/stdnse.print_debug( *" *%s *:* *\([^"]*\)" *, *SCRIPT_NAME/stdnse.debug1("\1"/' *.nse
This commit is contained in:
batrick
2014-08-02 02:08:12 +00:00
parent a763dc81a8
commit d47acf9f5e
49 changed files with 162 additions and 162 deletions

View File

@@ -212,7 +212,7 @@ function ip_to_asn( query )
local status, decoded_response = dns.query( query, options)
if not status then
stdnse.print_debug( "%s Error from dns.query(): %s", SCRIPT_NAME, decoded_response )
stdnse.debug1("Error from dns.query(): %s", decoded_response )
end
return status, decoded_response

View File

@@ -63,7 +63,7 @@ Driver =
-- This error seems to indicate that the user does not exist
if ( err:match("E PAM start error%: Critical error %- immediate abort\0$") ) then
stdnse.print_debug(2, "%s: The user %s does not exist", SCRIPT_NAME, username)
stdnse.debug2("The user %s does not exist", username)
local err = brute.Error:new("Account invalid")
err:setInvalidAccount(username)
return false, err

View File

@@ -182,7 +182,7 @@ action = function( host, port )
and response['body'] then
local body = response['body']:gsub("%%","%%%%")
local capacity = {}
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME, body)
stdnse.debug2("Body %s\n", body)
if body:match("Version:%s*</b>([^][,]+)") then
local version = body:match("Version:%s*</b>([^][,]+)")
stdnse.debug1("Version %s", version)

View File

@@ -44,12 +44,12 @@ action = function( host, port )
local result = {}
local uri = "/browseDirectory.jsp"
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 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", SCRIPT_NAME,body)
stdnse.debug2("Body %s\n",body)
if body:match("([^][\"]+)\">Log") then
port.version.name = "hadoop-datanode"
port.version.product = "Apache Hadoop"

View File

@@ -62,14 +62,14 @@ 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", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 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", SCRIPT_NAME,body)
stdnse.debug2("Body %s\n",body)
for line in string.gmatch(body, "[^\n]+") do
stdnse.print_debug(3, "%s: Line %s\n", SCRIPT_NAME,line)
stdnse.debug3("Line %s\n",line)
if line:match("job_[%d_]+") then
local user = line:match("<td>([^][<>]+)</td></tr>")
local job_time = line:match("</td><td>([^][<]+)")
@@ -83,13 +83,13 @@ end
get_tasktrackers = function( host, port )
local results = {}
local uri = "/machines.jsp?type=active"
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 response['status-line'] and response['status-line']:match("200%s+OK") and response['body'] then
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,response['body'])
stdnse.debug2("Body %s\n",response['body'])
for line in string.gmatch(response['body'], "[^\n]+") do
stdnse.print_debug(3, "%s: Line %s\n", SCRIPT_NAME,line)
stdnse.debug3("Line %s\n",line)
if line:match("href=\"[%w]+://([%w%.:]+)/\">tracker") then
local tasktracker = line:match("href=\".*//([%w%.:]+)/\">tracker")
stdnse.debug1("taskstracker %s",tasktracker)
@@ -110,11 +110,11 @@ action = function( host, port )
local result = {}
local uri = "/jobtracker.jsp"
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 response['status-line'] and response['status-line']:match("200%s+OK") and response['body'] then
stdnse.print_debug(2, "%s: Body %s\n", SCRIPT_NAME,response['body'])
stdnse.debug2("Body %s\n",response['body'])
if response['body']:match("State:</b>%s*([^][<]+)") then
local state = response['body']:match("State:</b>%s*([^][<]+)")
stdnse.debug1("State %s",state)

View File

@@ -62,12 +62,12 @@ 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", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 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", SCRIPT_NAME,body)
stdnse.debug2("Body %s\n",body)
for datanodetmp in string.gmatch(body, "[%w%.:-_]+/browseDirectory.jsp") do
local datanode = datanodetmp:gsub("/browseDirectory.jsp","")
stdnse.debug1("Datanode %s",datanode)
@@ -88,13 +88,13 @@ action = function( host, port )
local result = {}
local uri = "/dfshealth.jsp"
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 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", SCRIPT_NAME,body)
stdnse.debug2("Body %s\n",body)
if body:match("Started:%s*<td>([^][<]+)") then
local start = body:match("Started:%s*<td>([^][<]+)")
stdnse.debug1("Started %s",start)

View File

@@ -59,13 +59,13 @@ action = function( host, port )
local result = {}
local uri = "/status.jsp"
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 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", SCRIPT_NAME,body)
stdnse.debug2("Body %s\n",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]+)"))

View File

@@ -48,12 +48,12 @@ action = function( host, port )
local result = {}
local uri = "/tasktracker.jsp"
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 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", SCRIPT_NAME,body)
stdnse.debug2("Body %s\n",body)
if response['body']:match("Version:</b>%s*([^][<]+)") then
local version = response['body']:match("Version:</b>%s*([^][<]+)")
local versionNo = version:match("([^][,]+)")

View File

@@ -61,15 +61,15 @@ action = function( host, port )
local result = {}
local region_servers = {}
local uri = "/master.jsp"
stdnse.print_debug(1, "%s:HTTP GET %s:%s%s", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 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", SCRIPT_NAME,body)
stdnse.debug2("Body %s\n",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", SCRIPT_NAME,version)
stdnse.debug1("Hbase Version %s",version)
table.insert(result, ("Hbase Version: %s"):format(version))
port.version.version = version
end
@@ -111,7 +111,7 @@ action = function( host, port )
end
end
for line in string.gmatch(body, "[^\n]+") do
stdnse.print_debug(3, "%s: Line %s\n", SCRIPT_NAME,line)
stdnse.debug3("Line %s\n",line)
if line:match("maxHeap") then
local region_server= line:match("\">([^][<]+)</a>")
stdnse.debug1("Region Server %s",region_server)

View File

@@ -56,15 +56,15 @@ 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", SCRIPT_NAME, host.targetname or host.ip, port.number, uri)
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 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", SCRIPT_NAME,body)
stdnse.debug2("Body %s\n",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", SCRIPT_NAME,version)
stdnse.debug1("Hbase Version %s",version)
table.insert(result, ("Hbase Version: %s"):format(version))
port.version.version = version
end

View File

@@ -34,7 +34,7 @@ local MAGIC_URI = "administrator.cfc?method=login&adminpassword=&rdsPasswordAllo
local function get_admin_cookie(host, port, basepath)
local req = http.get(host, port, basepath..MAGIC_URI)
if req.header['set-cookie'] then
stdnse.print_debug(1, "%s:Header 'set-cookie' detected in response.", SCRIPT_NAME)
stdnse.debug1("Header 'set-cookie' detected in response.")
local _, _, admin_cookie = string.find(req.header['set-cookie'], ";path=/, CFAUTHORIZATION_cfadmin=(.*);path=/")
if admin_cookie:len() > 79 then
stdnse.debug1("Extracted cookie:%s", admin_cookie)

View File

@@ -94,7 +94,7 @@ action = function(host, port)
--check for awstats signature
local awstats_check = check_installation(host, port, uri)
if not(awstats_check) then
stdnse.print_debug(1, "%s:This does not look like Awstats Totals. Quitting.", SCRIPT_NAME)
stdnse.debug1("This does not look like Awstats Totals. Quitting.")
return
end

View File

@@ -145,14 +145,14 @@ action = function(host, port)
--Use selected service and exploit
stdnse.debug1("Querying service: %s", selected_service)
req = http.get(host, port, basepath..selected_service.."?xsd="..rfile)
stdnse.print_debug(2, "%s: Query -> %s", SCRIPT_NAME, basepath..selected_service.."?xsd="..rfile)
stdnse.debug2("Query -> %s", basepath..selected_service.."?xsd="..rfile)
--response came back
if req.status and req.status == 200 then
--if body is empty something wrong could have happened...
if string.len(req.body) <= 0 then
if nmap.verbosity() >= 2 then
stdnse.print_debug(1, "%s:Response was empty. The file does not exists or the web server does not have sufficient permissions", SCRIPT_NAME)
stdnse.debug1("Response was empty. The file does not exists or the web server does not have sufficient permissions")
end
return
end

View File

@@ -71,7 +71,7 @@ local CREDENTIALS_PAYLOADS = {
local function get_installation_path(host, port, basepath)
local req = http.get(host, port, basepath..PATH_PAYLOAD)
if req.header['set-cookie'] then
stdnse.print_debug(1, "%s:Header 'set-cookie' detected in response.", SCRIPT_NAME)
stdnse.debug1("Header 'set-cookie' detected in response.")
local _, _, path = string.find(req.header['set-cookie'],
"path=/, ANALYZER_DIRECTORY=(.-);path=/")
if path then
@@ -91,16 +91,16 @@ local function get_version(host, port, basepath)
if img_req.status == 200 then
local md5chk = stdnse.tohex(openssl.md5(img_req.body))
if md5chk == "a4c81b7a6289b2fc9b36848fa0cae83c" then
stdnse.print_debug(1, "%s:CF version 10 detected.", SCRIPT_NAME)
stdnse.debug1("CF version 10 detected.")
version = 10
elseif md5chk == "596b3fc4f1a0b818979db1cf94a82220" then
stdnse.print_debug(1, "%s:CF version 9 detected.", SCRIPT_NAME)
stdnse.debug1("CF version 9 detected.")
version = 9
elseif md5chk == "" then
stdnse.print_debug(1, "%s:CF version 8 detected.", SCRIPT_NAME)
stdnse.debug1("CF version 8 detected.")
version = 8
else
stdnse.print_debug(1, "%s:Could not determine version.", SCRIPT_NAME)
stdnse.debug1("Could not determine version.")
version = nil
end
end

View File

@@ -109,7 +109,7 @@ including PPPoE credentials, firmware version, model, gateway, dns servers and a
if pppoe_user then
vuln.state = vulns.STATE.EXPLOIT
else
stdnse.print_debug(1, "%s:Username string was not found in this page. Exiting.", SCRIPT_NAME)
stdnse.debug1("Username string was not found in this page. Exiting.")
return vuln_report:make_output(vuln)
end

View File

@@ -57,7 +57,7 @@ action = function()
local status, response = mobileme:getLocation()
if ( not(status) ) then
stdnse.print_debug(2, "%s: %s", SCRIPT_NAME, response)
stdnse.debug2("%s", response)
return fail("Failed to retrieve location information")
end

View File

@@ -114,7 +114,7 @@ local function findName(host, port, path, number)
errors = errors+1
end
if errors>10 then
stdnse.print_debug(1, "%s:False positive detected. Exiting.", SCRIPT_NAME)
stdnse.debug1("False positive detected. Exiting.")
errors_max=true
else
stdnse.print_debug(1, "Added folder: %s", path .. "~" .. number)

View File

@@ -56,7 +56,7 @@ action = function(host, port)
elseif req.status == 404 and nmap.verbosity() >= 2 then
output[#output+1] = string.format("Page: %s was not found. Try with an existing file.", rfile)
end
stdnse.print_debug(2, "%s:Request status:%s body:%s", SCRIPT_NAME, req.status, req.body)
stdnse.debug2("Request status:%s body:%s", req.status, req.body)
else
output[#output+1] = "\nLitespeed Web Server Source Code Disclosure (CVE-2010-2333)"
output[#output+1] = string.format("%s source code:", rfile)

View File

@@ -76,7 +76,7 @@ action = function(host, port)
response = http.get(host, port, evil_uri)
if response.body and response.status==200 then
if response.body:match("unknowntopic") then
stdnse.print_debug(1, "%s:[Error] The server is not vulnerable, '%s' was not found or the web server has insufficient permissions to read it", SCRIPT_NAME, rfile)
stdnse.debug1("[Error] The server is not vulnerable, '%s' was not found or the web server has insufficient permissions to read it", rfile)
return
end
local _

View File

@@ -73,7 +73,7 @@ portrule = shortport.http
-- First, it tries with HEAD, POST and then with a random string.
--
local function probe_http_verbs(host, port, uri)
stdnse.print_debug(2, "%s:Tampering HTTP verbs %s", SCRIPT_NAME, uri)
stdnse.debug2("Tampering HTTP verbs %s", uri)
local head_req = http.head(host, port, uri)
if head_req and head_req.status ~= 401 then
return true, "HEAD"
@@ -134,11 +134,11 @@ vulnerabilities via HTTP verb tampering. This is often found in web servers that
end
end
if r.response.status == 401 then
stdnse.print_debug(2, "%s:%s is protected! Let's try some verb tampering...", SCRIPT_NAME, tostring(r.url))
stdnse.debug2("%s is protected! Let's try some verb tampering...", tostring(r.url))
local parsed = url.parse(tostring(r.url))
local probe_status, probe_type = probe_http_verbs(host, port, parsed.path)
if probe_status then
stdnse.print_debug(1, "%s:Vulnerable URI %s", SCRIPT_NAME, uri)
stdnse.debug1("Vulnerable URI %s", uri)
table.insert(vuln_uris, parsed.path..string.format(" [%s]", probe_type))
end
end
@@ -157,7 +157,7 @@ vulnerabilities via HTTP verb tampering. This is often found in web servers that
if path_req.status == 401 then
local probe_status, probe_type = probe_http_verbs(host, port, path)
if probe_status then
stdnse.print_debug(1, "%s:Vulnerable URI %s", SCRIPT_NAME, path)
stdnse.debug1("Vulnerable URI %s", path)
table.insert(vuln_uris, path..string.format(" [%s]", probe_type))
end
end

View File

@@ -134,7 +134,7 @@ action = function(host, port)
end
elseif response.status==500 then
vuln.state = vulns.STATE.LIKELY_VULN
stdnse.print_debug(1, "%s:[Error] File not found:%s", SCRIPT_NAME, rfile)
stdnse.debug1("[Error] File not found:%s", rfile)
stdnse.debug1("response : %s", response.body)
vuln.extra_info = string.format("%s not found.\n", rfile)
end

View File

@@ -83,7 +83,7 @@ local function launch_probe(host, port, uri)
return false
end
stdnse.print_debug(1, "%s:HTTP GET %s%s", SCRIPT_NAME, uri, PHP_SELF_PROBE)
stdnse.debug1("HTTP GET %s%s", uri, PHP_SELF_PROBE)
probe_response = http.get(host, port, uri .. PHP_SELF_PROBE)
--save probe in list to avoid repeating it

View File

@@ -90,7 +90,7 @@ action = function(host)
return
end
local url = base_url:format(server)
stdnse.print_debug(2, "%s: Querying URL: %s", SCRIPT_NAME, url)
stdnse.debug2("Querying URL: %s", url)
data = fetch_robtex_data(url)
domains = parse_robtex_response(data)

View File

@@ -78,7 +78,7 @@ local function check_injection_response(response)
if errorstrings then
for _,e in ipairs(errorstrings) do
if string.find(body, e) then
stdnse.print_debug(2, "%s: error string matched: %s", SCRIPT_NAME, e)
stdnse.debug2("error string matched: %s", e)
return true
end
end
@@ -192,7 +192,7 @@ local function check_form(form, host, port, path)
for _,field in ipairs(form["fields"]) do
if sqli_field(field["type"]) then
stdnse.print_debug(2, "%s: checking field %s", SCRIPT_NAME, field["name"])
stdnse.debug2("checking field %s", field["name"])
postdata[field["name"]] = "' OR sqlspider"
response = sending_function(postdata)
if response and response.body and response.status==200 then

View File

@@ -91,10 +91,10 @@ end
---
local function check_vuln(host, port)
local evil_uri = TRAVERSAL_QRY..DEFAULT_REMOTE_FILE
stdnse.print_debug(1, "%s:HTTP GET %s", SCRIPT_NAME, evil_uri)
stdnse.debug1("HTTP GET %s", evil_uri)
local response = http.get(host, port, evil_uri)
if response.body and response.status==200 and response.body:match("root:") then
stdnse.print_debug(1, "%s:Pattern 'root:' found.", SCRIPT_NAME, response.body)
stdnse.debug1("Pattern 'root:' found.", response.body)
return true
end
return false
@@ -134,7 +134,7 @@ Possibly vulnerable (Based on the same firmware): WR743ND,WR842ND,WA-901ND,WR941
if response.body and response.status==200 then
stdnse.print_debug(2, "%s", response.body)
if response.body:match("Error") then
stdnse.print_debug(1, "%s:[Error] File not found:%s", SCRIPT_NAME, rfile)
stdnse.debug1("[Error] File not found:%s", rfile)
vuln.extra_info = string.format("%s not found.\n", rfile)
return vuln_report:make_output(vuln)
end

View File

@@ -136,7 +136,7 @@ function init()
stdnse.get_script_args('userdir.users')
local read, usernames = datafiles.parse_file(customlist or "nselib/data/usernames.lst", {})
if not read then
stdnse.print_debug(1, "%s %s", SCRIPT_NAME,
stdnse.debug1("%s",
usernames or "Unknown Error reading usernames list.")
nmap.registry.userdir = {}
return nil
@@ -144,7 +144,7 @@ function init()
-- random dummy username to catch false positives (not necessary)
-- if #usernames > 0 then table.insert(usernames, 1, randomstring()) end
nmap.registry.userdir = usernames
stdnse.print_debug(1, "%s Testing %d usernames.", SCRIPT_NAME, #usernames)
stdnse.debug1("Testing %d usernames.", #usernames)
return nil
end

View File

@@ -84,7 +84,7 @@ servers to remote users who send carefully crafted requests.]],
local bypass_request = http.pipeline_go(host,port, all)
if ( not(bypass_request) ) then
stdnse.print_debug(1, "%s : got no answers from pipelined queries", SCRIPT_NAME)
stdnse.debug1("got no answers from pipelined queries")
return "\n ERROR: Got no answers from pipelined queries"
end
@@ -112,7 +112,7 @@ servers to remote users who send carefully crafted requests.]],
end
for i=1, #bypass_request, 1 do
stdnse.print_debug(1, "%s : test %d returned a %d", SCRIPT_NAME,i,bypass_request[i].status)
stdnse.debug1("test %d returned a %d",i,bypass_request[i].status)
-- here a 400 should be the evidence for a patched server.
if ( bypass_request[i].status == 200 and vuln.state ~= vulns.STATE.VULN ) then

View File

@@ -78,10 +78,10 @@ local function detect(host, port, uri)
local req_ok = http.post(host, port, uri, opts, nil, PAYLOAD_OK)
local req_time = http.post(host, port, uri, opts, nil, PAYLOAD_TIME)
stdnse.print_debug(2, "%s:First request returned status %d. Second request returned status %d", SCRIPT_NAME, req_ok.status, req_time.status)
stdnse.debug2("First request returned status %d. Second request returned status %d", req_ok.status, req_time.status)
if req_ok.status == 200 and req_time.status == 200 then
local req_malformed = http.post(host, port, uri, opts, nil, PAYLOAD_MALFORMED)
stdnse.print_debug(2, "%s:Malformed request returned status %d", SCRIPT_NAME, req_malformed.status)
stdnse.debug2("Malformed request returned status %d", req_malformed.status)
if req_malformed.status == 500 then
return true
end
@@ -111,7 +111,7 @@ The attackers don't need to be authenticated to exploit these vulnerabilities.
}
if detect(host,port,uri) then
stdnse.print_debug(1, "%s:Received status 500 as expected in vulnerable installations. Marking as vulnerable...", SCRIPT_NAME)
stdnse.debug1("Received status 500 as expected in vulnerable installations. Marking as vulnerable...")
vuln_table.state = vulns.STATE.VULN
local report = vulns.Report:new(SCRIPT_NAME, host, port)
return report:make_output(vuln_table)

View File

@@ -70,7 +70,7 @@ action = function(host, port)
local use_body = stdnse.get_script_args(SCRIPT_NAME..".detectBodyChanges") or false
--get original response from a "good" request
stdnse.print_debug(2, "%s: Requesting URI %s", SCRIPT_NAME, path)
stdnse.debug2("Requesting URI %s", path)
orig_req = http.get(host, port, path)
orig_req.body = http.clean_404(orig_req.body)
if orig_req.status and orig_req.body then

View File

@@ -51,7 +51,7 @@ portrule = shortport.http
-- @return false if not found otherwise it returns the username
---
local function get_wp_user(host, port, path, id)
stdnse.print_debug(2, "%s: Trying to get username with id %s", SCRIPT_NAME, id)
stdnse.debug2("Trying to get username with id %s", id)
local req = http.get(host, port, path.."?author="..id, { no_cache = true})
if req.status then
stdnse.debug1("User id #%s returned status %s", id, req.status)
@@ -77,7 +77,7 @@ end
--@return True if WP was found
--
local function check_wp(host, port, path)
stdnse.print_debug(2, "%s:Checking %swp-login.php ", SCRIPT_NAME, path)
stdnse.debug2("Checking %swp-login.php ", path)
local req = http.get(host, port, path.."wp-login.php", {no_cache=true})
if req.status and req.status == 200 then
return true

View File

@@ -91,7 +91,7 @@ action = function(host, port)
plugins_search = tonumber(plugins_search_arg)
end
stdnse.print_debug(1, "%s plugins search range: %s", SCRIPT_NAME, plugins_search or "unlimited")
stdnse.debug1("plugins search range: %s", plugins_search or "unlimited")
-- search the website root for evidences of a Wordpress path
@@ -102,9 +102,9 @@ action = function(host, port)
wp_autoroot = string.match(target_index.body, "http://[%w%-%.]-/([%w%-%./]-)wp%-content")
if wp_autoroot then
wp_autoroot = "/" .. wp_autoroot
stdnse.print_debug(1, "%s WP root directory: %s", SCRIPT_NAME, wp_autoroot)
stdnse.debug1("WP root directory: %s", wp_autoroot)
else
stdnse.print_debug(1, "%s WP root directory: wp_autoroot was unable to find a WP content dir (root page returns %d).", SCRIPT_NAME, target_index.status)
stdnse.debug1("WP root directory: wp_autoroot was unable to find a WP content dir (root page returns %d).", target_index.status)
end
end
end
@@ -147,7 +147,7 @@ action = function(host, port)
-- release hell...
local pipeline_returns = http.pipeline_go(host, port, all)
if not pipeline_returns then
stdnse.print_debug(1, "%s : got no answers from pipelined queries", SCRIPT_NAME)
stdnse.debug1("got no answers from pipelined queries")
end
for i, data in pairs(pipeline_returns) do

View File

@@ -39,7 +39,7 @@ local arg_target = stdnse.get_script_args(SCRIPT_NAME .. ".target")
hostrule = function(host)
if ( not(host.mac_addr) ) then
stdnse.print_debug( "%s: Failed to determine hosts remote MAC address", SCRIPT_NAME )
stdnse.debug1("Failed to determine hosts remote MAC address" )
end
return (arg_target ~= nil and host.mac_addr ~= nil)
end

View File

@@ -41,7 +41,7 @@ categories = {"discovery","external","safe"}
hostrule = function(host)
local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then
stdnse.print_debug( "%s Error in Hostrule: %s.", SCRIPT_NAME, err )
stdnse.debug1("Error in Hostrule: %s.", err )
return false
end
return not is_private

View File

@@ -29,7 +29,7 @@ categories = {"discovery","external","safe"}
hostrule = function(host)
local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then
stdnse.print_debug( "%s Error in Hostrule: %s.", SCRIPT_NAME, err )
stdnse.debug1("Error in Hostrule: %s.", err )
return false
end
return not is_private

View File

@@ -36,7 +36,7 @@ categories = {"discovery","external","safe"}
hostrule = function(host)
local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then
stdnse.print_debug( "%s not running: Error in Hostrule: %s.", SCRIPT_NAME, err )
stdnse.debug1("not running: Error in Hostrule: %s.", err )
return false
elseif is_private then
stdnse.debug1("not running: Private IP address of target: %s", host.ip)

View File

@@ -35,7 +35,7 @@ categories = {"discovery","external","safe"}
hostrule = function(host)
local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then
stdnse.print_debug( "%s Error in Hostrule: %s.", SCRIPT_NAME, err )
stdnse.debug1("Error in Hostrule: %s.", err )
return false
end
return not is_private

View File

@@ -79,7 +79,7 @@ local function getMechs(host, port)
local status, response = helper:getSASLMechList()
if ( not(status) ) then
stdnse.print_debug(2, "%s: Received unexpected response: %s", SCRIPT_NAME, response)
stdnse.debug2("Received unexpected response: %s", response)
return false, "Received unexpected response"
end

View File

@@ -59,19 +59,19 @@ Driver =
try = nmap.new_try(function() return false end)
try(self.s:send(data))
data = try(self.s:receive_bytes(50))
stdnse.print_debug(1, "%s:Response #1:%s", SCRIPT_NAME, data)
stdnse.debug1("Response #1:%s", data)
local _, _, ret = string.find(data, '!done%%=ret=(.+)')
--If we find the challenge value we continue the connection process
if ret then
stdnse.print_debug(1, "%s:Challenge value found:%s", SCRIPT_NAME, ret)
stdnse.debug1("Challenge value found:%s", ret)
local md5str = bin.pack("xAA", password, bin.pack("H", ret)) --appends pwd and challenge
local chksum = stdnse.tohex(openssl.md5(md5str))
local user_l = username:len()+6 --we add six because of the string "=name="
local login_pkt = bin.pack("cAcAcAx", 0x6, "/login", user_l, "=name="..username, 0x2c, "=response=00"..chksum)
try(self.s:send(login_pkt))
data = try(self.s:receive_bytes(50))
stdnse.print_debug(1, "%s:Response #2:%s", SCRIPT_NAME, data)
stdnse.debug1("Response #2:%s", data)
if data then
if string.find(data, "message=cannot") == nil then
local c = creds.Credentials:new(SCRIPT_NAME, self.host, self.port )

View File

@@ -142,7 +142,7 @@ local function test_credentials( instance, helper, username, password )
local status, result = helper:ConnectEx( instance )
local loginErrorCode
if( status ) then
stdnse.print_debug( 2, "%s: Attempting login to %s as %s/%s", SCRIPT_NAME, instance:GetName(), username, password )
stdnse.debug2("Attempting login to %s as %s/%s", instance:GetName(), username, password )
status, result, loginErrorCode = helper:Login( username, password, database, instance.host.ip )
end
helper:Disconnect()
@@ -160,7 +160,7 @@ local function test_credentials( instance, helper, username, password )
if ( loginErrorCode == mssql.LoginErrorType.PasswordExpired ) then passwordIsGood = true
elseif ( loginErrorCode == mssql.LoginErrorType.PasswordMustChange ) then passwordIsGood = true
elseif ( loginErrorCode == mssql.LoginErrorType.AccountLockedOut ) then
stdnse.print_debug( 1, "%s: Account %s locked out on %s", SCRIPT_NAME, username, instance:GetName() )
stdnse.debug1("Account %s locked out on %s", username, instance:GetName() )
table.insert( instance.ms_sql_brute.warnings, string.format( "%s: Account is locked out.", username ) )
if ( not stdnse.get_script_args( "ms-sql-brute.ignore-lockout" ) ) then
stopInstance = true
@@ -226,14 +226,14 @@ local function process_instance( instance )
local helper = mssql.Helper:new()
if ( not instance:HasNetworkProtocols() ) then
stdnse.print_debug( 1, "%s: %s has no network protocols enabled.", SCRIPT_NAME, instance:GetName() )
stdnse.debug1("%s has no network protocols enabled.", instance:GetName() )
table.insert( instance.ms_sql_brute.errors, "No network protocols enabled." )
stopInstance = true
end
status, usernames = unpwdb.usernames()
if ( not(status) ) then
stdnse.print_debug( 1, "%s: Failed to load usernames list.", SCRIPT_NAME )
stdnse.debug1("Failed to load usernames list." )
table.insert( instance.ms_sql_brute.errors, "Failed to load usernames list." )
stopInstance = true
end
@@ -241,7 +241,7 @@ local function process_instance( instance )
if ( status ) then
status, passwords = unpwdb.passwords()
if ( not(status) ) then
stdnse.print_debug( 1, "%s: Failed to load passwords list.", SCRIPT_NAME )
stdnse.debug1("Failed to load passwords list." )
table.insert( instance.ms_sql_brute.errors, "Failed to load passwords list." )
stopInstance = true
end

View File

@@ -67,7 +67,7 @@ local function test_credentials( instance, helper, username, password )
local status, result = helper:ConnectEx( instance )
local loginErrorCode
if( status ) then
stdnse.print_debug( 2, "%s: Attempting login to %s", SCRIPT_NAME, instance:GetName() )
stdnse.debug2("Attempting login to %s", instance:GetName() )
status, result, loginErrorCode = helper:Login( username, password, database, instance.host.ip )
end
helper:Disconnect()
@@ -80,7 +80,7 @@ local function test_credentials( instance, helper, username, password )
if ( loginErrorCode == mssql.LoginErrorType.PasswordExpired ) then passwordIsGood = true end
if ( loginErrorCode == mssql.LoginErrorType.PasswordMustChange ) then passwordIsGood = true end
if ( loginErrorCode == mssql.LoginErrorType.AccountLockedOut ) then
stdnse.print_debug( 1, "%s: Account %s locked out on %s", SCRIPT_NAME, username, instance:GetName() )
stdnse.debug1("Account %s locked out on %s", username, instance:GetName() )
table.insert( instance.ms_sql_empty, string.format("'sa' account is locked out.", result ) )
end
if ( mssql.LoginErrorMessage[ loginErrorCode ] == nil ) then
@@ -135,7 +135,7 @@ local function process_instance( instance )
instance.ms_sql_empty = instance.ms_sql_empty or {}
if not instance:HasNetworkProtocols() then
stdnse.print_debug( 1, "%s: %s has no network protocols enabled.", SCRIPT_NAME, instance:GetName() )
stdnse.debug1("%s has no network protocols enabled.", instance:GetName() )
table.insert( instance.ms_sql_empty, "No network protocols enabled." )
end

View File

@@ -201,21 +201,21 @@ local function process_instance( instance )
foundVersion, ssnetlibVersion = mssql.Helper.GetInstanceVersion( instance )
if ( foundVersion ) then
instance.version = ssnetlibVersion
stdnse.print_debug( 1, "%s: Retrieved SSNetLib version for %s.", SCRIPT_NAME, instance:GetName() )
stdnse.debug1("Retrieved SSNetLib version for %s.", instance:GetName() )
else
stdnse.print_debug( 1, "%s: Could not retrieve SSNetLib version for %s.", SCRIPT_NAME, instance:GetName() )
stdnse.debug1("Could not retrieve SSNetLib version for %s.", instance:GetName() )
end
end
-- If we didn't get a version from SSNetLib, give the user some detail as to why
if ( not foundVersion ) then
if ( not instance:HasNetworkProtocols() ) then
stdnse.print_debug( 1, "%s: %s has no network protocols enabled.", SCRIPT_NAME, instance:GetName() )
stdnse.debug1("%s has no network protocols enabled.", instance:GetName() )
end
if ( instance.version ) then
stdnse.print_debug( 1, "%s: Using version number from SSRP response for %s.", SCRIPT_NAME, instance:GetName() )
stdnse.debug1("Using version number from SSRP response for %s.", instance:GetName() )
else
stdnse.print_debug( 1, "%s: Version info could not be retrieved for %s.", SCRIPT_NAME, instance:GetName() )
stdnse.debug1("Version info could not be retrieved for %s.", instance:GetName() )
end
end

View File

@@ -91,11 +91,11 @@ Driver =
local status, data
repeat
if ( tries < MAX_RETRIES ) then
stdnse.print_debug(2, "%s: Attempting to re-connect (attempt %d of %d)", SCRIPT_NAME, MAX_RETRIES - tries, MAX_RETRIES)
stdnse.debug2("Attempting to re-connect (attempt %d of %d)", MAX_RETRIES - tries, MAX_RETRIES)
end
status, data = self.helper:Connect()
if ( not(status) ) then
stdnse.print_debug(2, "%s: ERROR: An Oracle %s error occurred", SCRIPT_NAME, data)
stdnse.debug2("ERROR: An Oracle %s error occurred", data)
self.helper:Close()
else
break

View File

@@ -107,11 +107,11 @@ Driver =
local status, data
repeat
if ( tries < MAX_RETRIES ) then
stdnse.print_debug(2, "%s: Attempting to re-connect (attempt %d of %d)", SCRIPT_NAME, MAX_RETRIES - tries, MAX_RETRIES)
stdnse.debug2("Attempting to re-connect (attempt %d of %d)", MAX_RETRIES - tries, MAX_RETRIES)
end
status, data = self.helper:Connect()
if ( not(status) ) then
stdnse.print_debug(2, "%s: ERROR: An Oracle %s error occurred", SCRIPT_NAME, data)
stdnse.debug2("ERROR: An Oracle %s error occurred", data)
self.helper:Close()
else
break

View File

@@ -95,7 +95,7 @@ system commands as the 'root' user.
end
-- Parse response
stdnse.print_debug(2, "%s: Received reply:\n%s", SCRIPT_NAME, data)
stdnse.debug2("Received reply:\n%s", data)
if not string.match(data, "QCONN") then
stdnse.debug1("%s:%s is not a QNX QCONN daemon.", host.targetname or host.ip, port.number)
return

View File

@@ -212,7 +212,7 @@ local rpcGrinder = function(host, port, iterator, result)
-- Otherwise, an Accept state other than Program unavailable is not normal behaviour.
elseif response.accept_state ~= rpc.Portmap.AcceptState.PROG_UNAVAIL then
stdnse.print_debug("%s: returned %s accept state for %s program number.",SCRIPT_NAME, response.accept_state, number)
stdnse.debug1("returned %s accept state for %s program number.", response.accept_state, number)
end
end
end

View File

@@ -174,7 +174,7 @@ local function check_keys(host, keys, f)
for _,name in ipairs(possible_host_names) do
local hash = base64.enc(openssl.hmac("SHA1", salt, name))
if parts_hostname[4] == hash then
stdnse.print_debug(2, "%s: found a hash that matches: %s for hostname: %s", SCRIPT_NAME, hash, name)
stdnse.debug2("found a hash that matches: %s for hostname: %s", hash, name)
foundhostname = true
table.insert(keys_from_file, {name=name, key=("%s %s"):format(parts[2], parts[3]), lnumber=lnumber})
end

View File

@@ -91,7 +91,7 @@ local table = require "table"
hostrule = function( host )
local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then
stdnse.print_debug( "%s Error in Hostrule: %s.", SCRIPT_NAME, err )
stdnse.debug1("Error in Hostrule: %s.", err )
return false
end

View File

@@ -101,7 +101,7 @@ hostrule = function( host )
local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then
stdnse.print_debug( "%s Error in Hostrule: %s.", SCRIPT_NAME, err )
stdnse.debug1("Error in Hostrule: %s.", err )
return false
end
@@ -196,7 +196,7 @@ action = function( host )
status, retval = pcall( get_next_action, tracking, host.ip )
if not status then
stdnse.print_debug( "%s %s pcall caught an exception in get_next_action: %s.", SCRIPT_NAME, host.ip, retval )
stdnse.debug1("%s pcall caught an exception in get_next_action: %s.", host.ip, retval )
else tracking = retval end
if tracking.this_db then
@@ -207,13 +207,13 @@ action = function( host )
-- analyse data
status, retval = pcall( analyse_response, tracking, host.ip, response, data )
if not status then
stdnse.print_debug( "%s %s pcall caught an exception in analyse_response: %s.", SCRIPT_NAME, host.ip, retval )
stdnse.debug1("%s pcall caught an exception in analyse_response: %s.", host.ip, retval )
else data = retval end
-- get next action
status, retval = pcall( get_next_action, tracking, host.ip )
if not status then
stdnse.print_debug( "%s %s pcall caught an exception in get_next_action: %s.", SCRIPT_NAME, host.ip, retval )
stdnse.debug1("%s pcall caught an exception in get_next_action: %s.", host.ip, retval )
if not tracking.last_db then tracking.last_db, tracking.this_db = tracking.this_db or tracking.next_db, nil end
else tracking = retval end
end
@@ -346,7 +346,7 @@ function check_response_cache( ip )
-- record found in cache
return true, nil
else
stdnse.print_debug( 1, "%s %s Error in check_response_cache: Empty Cache Entry was found.", SCRIPT_NAME, ip )
stdnse.debug1("%s Error in check_response_cache: Empty Cache Entry was found.", ip )
end
return false, nil
@@ -467,7 +467,7 @@ function get_db_from_assignments( ip )
end
if not nmap.registry.whois.local_assignments_data or not nmap.registry.whois.local_assignments_data[af] then
stdnse.print_debug( 1, "%s Error in get_db_from_assignments: Missing assignments data in registry.", SCRIPT_NAME )
stdnse.debug1("Error in get_db_from_assignments: Missing assignments data in registry." )
return nil
end
@@ -517,7 +517,7 @@ function do_query(db, ip)
local socket = nmap.new_socket()
local catch = function()
stdnse.print_debug( "%s %s Connection to %s failed or was aborted! No Output for this Target.", SCRIPT_NAME, ip, db )
stdnse.debug1("%s Connection to %s failed or was aborted! No Output for this Target.", ip, db )
nmap.registry.whois.mutex[db] "done"
socket:close()
end
@@ -540,7 +540,7 @@ function do_query(db, ip)
socket:close()
stdnse.print_debug(3, "%s %s Ended Query at %s.", SCRIPT_NAME, ip, db)
stdnse.debug3("%s Ended Query at %s.", ip, db)
if #result == 0 then
return nil
@@ -593,13 +593,13 @@ function analyse_response( tracking, ip, response, data )
if type( meta ) == "table" and type( meta.fieldreq ) == "table" and type( meta.fieldreq.ob_exist ) == "string" then
have_objects = response:match( meta.fieldreq.ob_exist )
else
stdnse.print_debug( 2, "%s %s Could not check for objects, problem with meta data.", SCRIPT_NAME, ip )
stdnse.debug2("%s Could not check for objects, problem with meta data.", ip )
have_objects = false
end
-- if we do not recognize objects check for an known error/non-object message
if not have_objects then
stdnse.print_debug( 4, "%s %s %s has not responded with the expected objects.", SCRIPT_NAME, ip, this_db )
stdnse.debug4("%s %s has not responded with the expected objects.", ip, this_db )
local tmp, msg
-- may have found our record saying something similar to "No Record Found"
for _, pattern in ipairs( nmap.registry.whois.m_none ) do
@@ -607,7 +607,7 @@ function analyse_response( tracking, ip, response, data )
local pattern_u = pattern:gsub( "$addr", ip:upper() )
msg = response:match( pattern_l ) or response:match( pattern_u )
if msg then
stdnse.print_debug( 4, "%s %s %s responded with a message which is assumed to be authoritative (but may not be).", SCRIPT_NAME, ip, this_db )
stdnse.debug4("%s %s responded with a message which is assumed to be authoritative (but may not be).", ip, this_db )
break
end
end
@@ -616,7 +616,7 @@ function analyse_response( tracking, ip, response, data )
for _, pattern in ipairs( nmap.registry.whois.m_err ) do
msg = response:match( pattern )
if msg then
stdnse.print_debug( 4, "%s %s %s responded with an ERROR message.", SCRIPT_NAME, ip, this_db )
stdnse.debug4("%s %s responded with an ERROR message.", ip, this_db )
break
end
end
@@ -635,7 +635,7 @@ function analyse_response( tracking, ip, response, data )
for setname, set in pairs( nmap.registry.whois.fields_meta ) do
if set ~= nmap.registry.whois.whoisdb[this_db].fieldreq and response:match(set.ob_exist) then
foreign_obj = setname
stdnse.print_debug( 4, "%s %s %s seems to have responded using the set of objects named: %s.", SCRIPT_NAME, ip, this_db, foreign_obj )
stdnse.debug4("%s %s seems to have responded using the set of objects named: %s.", ip, this_db, foreign_obj )
break
end
end
@@ -644,7 +644,7 @@ function analyse_response( tracking, ip, response, data )
meta = nmap.registry.whois.whoisdb.ripe
meta.redirects = nil
have_objects = true
stdnse.print_debug( 4, "%s %s %s will use the display properties of ripe.", SCRIPT_NAME, ip, this_db )
stdnse.debug4("%s %s will use the display properties of ripe.", ip, this_db )
elseif foreign_obj then
-- find a display to match the objects.
for some_db, db_props in pairs( nmap.registry.whois.whoisdb ) do
@@ -653,7 +653,7 @@ function analyse_response( tracking, ip, response, data )
meta = nmap.registry.whois.whoisdb[some_db]
meta.redirects = nil
have_objects = true
stdnse.print_debug( 4, "%s %s %s will use the display properties of %s.", SCRIPT_NAME, ip, this_db, some_db )
stdnse.debug4("%s %s will use the display properties of %s.", ip, this_db, some_db )
break
end
end
@@ -662,7 +662,7 @@ function analyse_response( tracking, ip, response, data )
-- extract fields from the entire response for record/redirect discovery
if have_objects then
stdnse.print_debug( 4, "%s %s Parsing Query response from %s.", SCRIPT_NAME, ip, this_db )
stdnse.debug4("%s Parsing Query response from %s.", ip, this_db )
data[this_db] = extract_objects_from_response( response, this_db, ip, meta )
end
@@ -670,7 +670,7 @@ function analyse_response( tracking, ip, response, data )
-- do record/redirect discovery, cache found redirect
if not nmap.registry.whois.nofollow and have_objects and meta.redirects then
stdnse.print_debug( 4, "%s %s Testing response for redirection.", SCRIPT_NAME, ip )
stdnse.debug4("%s Testing response for redirection.", ip )
found, nextdb, data.iana = redirection_rules( this_db, ip, data, meta )
end
@@ -678,7 +678,7 @@ function analyse_response( tracking, ip, response, data )
-- modify the data table depending on whether we're redirecting or quitting
if have_objects then
stdnse.print_debug( 5, "%s %s Extracting Fields from response.", SCRIPT_NAME, ip )
stdnse.debug5("%s Extracting Fields from response.", ip )
-- optionally constrain response to a more focused area
-- discarding previous extraction
@@ -690,7 +690,7 @@ function analyse_response( tracking, ip, response, data )
end
if offset > 1 and meta.unordered then
-- fetch an object immediately in front of inetnum
stdnse.print_debug( 5, "%s %s %s Searching for an object group immediately before this range.", SCRIPT_NAME, ip, this_db )
stdnse.debug5("%s %s Searching for an object group immediately before this range.", ip, this_db )
-- split objects from the record, up to offset. Last object should be the one we want.
local obj_sel = stdnse.strsplit( "\r?\n\r?\n", response:sub( 1, offset ) )
response_chunk = "\n" .. obj_sel[#obj_sel] .. "\n"
@@ -722,10 +722,10 @@ function analyse_response( tracking, ip, response, data )
end
-- DEBUG
stdnse.print_debug( 6, "%s %s %s Fields captured :", SCRIPT_NAME, ip, this_db )
stdnse.debug6("%s %s Fields captured :", ip, this_db )
for ob, t in pairs( data[this_db] ) do
for fieldname, fieldvalue in pairs( t ) do
stdnse.print_debug( 6, "%s %s %s %s.%s %s.", SCRIPT_NAME, ip, this_db, ob, fieldname, fieldvalue )
stdnse.debug6("%s %s %s.%s %s.", ip, this_db, ob, fieldname, fieldvalue )
end
end
@@ -820,15 +820,15 @@ function extract_objects_from_response( response_string, db, ip, meta, specific_
-- we either receive a table for one object or for all objects
if type( specific_object ) == "string" and meta.fieldreq[specific_object] then
objects_to_extract[specific_object] = meta.fieldreq[specific_object]
stdnse.print_debug( 5, "%s %s Extracting a single object: %s.", SCRIPT_NAME, ip, specific_object )
stdnse.debug5("%s Extracting a single object: %s.", ip, specific_object )
else
stdnse.print_debug( 5, "%s %s Extracting all objects.", SCRIPT_NAME, ip )
stdnse.debug5("%s Extracting all objects.", ip )
objects_to_extract = meta.fieldreq
end
for object_name, object in pairs( objects_to_extract ) do
if object_name and object_name ~= "ob_exist" then
stdnse.print_debug(5, "%s %s Seeking object group: %s.", SCRIPT_NAME, ip, object_name)
stdnse.debug5("%s Seeking object group: %s.", ip, object_name)
extracted_objects[object_name] = {}
extracted_objects[object_name].for_compare = {} -- this will allow us to compare two tables
-- get a substr of response_string that corresponds to a single object
@@ -837,7 +837,7 @@ function extract_objects_from_response( response_string, db, ip, meta, specific_
-- if we could not find the end, make the end EOF
ob_end = ob_end or -1
if ob_start and ob_end then
stdnse.print_debug(5, "%s %s Capturing: %s with indices %s and %s.", SCRIPT_NAME, ip, object_name, ob_start, ob_end )
stdnse.debug5("%s Capturing: %s with indices %s and %s.", ip, object_name, ob_start, ob_end )
local obj_string = response_string:sub( ob_start, ob_end )
for fieldname, pattern in pairs( object ) do
if fieldname ~= "ob_start" and fieldname ~= "ob_end" then
@@ -910,19 +910,19 @@ function redirection_rules( db, ip, data, meta )
-- arin record points to iana so we won't follow and we assume we have our record
if directed_to == iana and directed_from == arin then
stdnse.print_debug( 4, "%s %s %s Accept arin record (matched IANA).", SCRIPT_NAME, ip, directed_from )
stdnse.debug4("%s %s Accept arin record (matched IANA).", ip, directed_from )
return true, nil, ( icnt+1 )
end
-- non-arin record points to iana so we query arin next
if directed_to == iana then
stdnse.print_debug( 4, "%s %s Redirecting to arin (matched IANA).", SCRIPT_NAME, ip )
stdnse.debug4("%s Redirecting to arin (matched IANA).", ip )
return false, arin, ( icnt+1 )
end
-- a redirect, but not to iana or to self, so we follow it.
if directed_to ~= nmap.registry.whois.whoisdb[directed_from].id then
stdnse.print_debug( 4, "%s %s %s redirects us to %s.", SCRIPT_NAME, ip, directed_from, directed_to )
stdnse.debug4("%s %s redirects us to %s.", ip, directed_from, directed_to )
return false, directed_to, icnt
end
@@ -938,14 +938,14 @@ function redirection_rules( db, ip, data, meta )
-- if a field has been captured for the given redirect info
if data[db][obj] and data[db][obj][fld] then
stdnse.print_debug( 5, "%s %s Seek redirect in object: %s.%s for %s.", SCRIPT_NAME, ip, obj, fld, pattern )
stdnse.debug5("%s Seek redirect in object: %s.%s for %s.", ip, obj, fld, pattern )
-- iterate over nmap.registry.whois.whoisdb to find pattern (from each service) in the designated field
for member, mem_properties in pairs( nmap.registry.whois.whoisdb ) do
-- if pattern if found in the field, we have a redirect to member
if type( mem_properties[pattern] ) == "string" and string.lower( data[db][obj][fld] ):match( mem_properties[pattern] ) then
stdnse.print_debug( 5, "%s %s Matched %s in %s.%s.", SCRIPT_NAME, ip, pattern, obj, fld )
stdnse.debug5("%s Matched %s in %s.%s.", ip, pattern, obj, fld )
return redirection_validation( nmap.registry.whois.whoisdb[member].id, db, iana_count )
elseif type( mem_properties[pattern] ) == "table" then
@@ -953,7 +953,7 @@ function redirection_rules( db, ip, data, meta )
-- pattern is an array of patterns
for _, pattn in ipairs( mem_properties[pattern] ) do
if type( pattn ) == "string" and string.lower( data[db][obj][fld] ):match( pattn ) then
stdnse.print_debug( 5, "%s %s Matched %s in %s.%s.", SCRIPT_NAME, ip, pattern, obj, fld )
stdnse.debug5("%s Matched %s in %s.%s.", ip, pattern, obj, fld )
return redirection_validation( nmap.registry.whois.whoisdb[member].id, db, iana_count )
end
end
@@ -1007,7 +1007,7 @@ function constrain_response( response, db, ip, meta )
if # mptr > 1 then
-- find the closest one to host.ip and constrain the response to it
stdnse.print_debug( 5, "%s %s %s Focusing on the smallest of %s address ranges.", SCRIPT_NAME, ip, db, #mptr )
stdnse.debug5("%s %s Focusing on the smallest of %s address ranges.", ip, db, #mptr )
-- sort the table mptr into nets ascending
table.sort( mptr, smallest_range )
-- select the first net that includes host.ip
@@ -1025,7 +1025,7 @@ function constrain_response( response, db, ip, meta )
if mptr[index+1] and ( mptr[index+1].pointer > mptr[index].pointer ) then
bound = mptr[index+1].pointer
end
stdnse.print_debug(5, "%s %s %s Smallest range containing target IP addr. is %s.", SCRIPT_NAME, ip, db, trim( str_net ) )
stdnse.debug5("%s %s Smallest range containing target IP addr. is %s.", ip, db, trim( str_net ) )
local dbg = "%s %s %s smallest range is offset from %s to %s."
-- isolate inetnum and associated objects
if bound then
@@ -1075,7 +1075,7 @@ function not_short_prefix( ip, range, redirect )
first, last, err[#err+1] = ipOps.get_ips_from_range( range )
if #err > 0 then
stdnse.print_debug( 1, "%s Error in not_short_prefix: s%.", SCRIPT_NAME, table.concat( err, " " ) )
stdnse.debug1("Error in not_short_prefix: s%.", table.concat( err, " " ) )
return nil
end
@@ -1119,7 +1119,7 @@ function add_to_cache( ip, range, redirect, data )
-- we need to cache some range so we'll cache the small assignment that includes ip.
if type( range ) ~= "string" or type( get_prefix_length( range ) ) ~= "number" then
range = get_assignment( ip, longest_prefix )
stdnse.print_debug(5, "%s %s Caching an assumed Range: %s", SCRIPT_NAME, ip, range)
stdnse.debug5("%s Caching an assumed Range: %s", ip, range)
end
nmap.registry.whois.cache[ip] = {} -- destroy any previous cache entry for this target.
@@ -1212,13 +1212,13 @@ function output( ip, services_queried )
end
if type( services_queried ) ~= "table" then
stdnse.print_debug( "%s %s Error in output(): No data found.", SCRIPT_NAME, ip )
stdnse.debug1("%s Error in output(): No data found.", ip )
return nil
elseif #services_queried == 0 then
stdnse.print_debug( "%s %s Error in output(): No data found, no queries were completed.", SCRIPT_NAME, ip )
stdnse.debug1("%s Error in output(): No data found, no queries were completed.", ip )
return nil
elseif #services_queried > 0 then
stdnse.print_debug( "%s %s Error in output(): No data found - could not understand query responses.", SCRIPT_NAME, ip )
stdnse.debug1("%s Error in output(): No data found - could not understand query responses.", ip )
return nil
end
@@ -1239,7 +1239,7 @@ function get_output_from_cache( ip )
local ip_key = get_cache_key( ip )
if not ip_key then
stdnse.print_debug( 1, "%s %s Error in get_output_from_cache().", SCRIPT_NAME, ip )
stdnse.debug1("%s Error in get_output_from_cache().", ip )
return nil
end
@@ -1707,7 +1707,7 @@ function get_args()
nmap.registry.whois.using_cache = false
elseif ( db == "nofile" ) then
nmap.registry.whois.using_local_assignments_file = false
stdnse.print_debug( 2, "%s: Not using local assignments data.", SCRIPT_NAME )
stdnse.debug2("Not using local assignments data." )
end
elseif not ( string.match( table.concat( t, " " ), db ) ) then
-- we have a unique valid whois db
@@ -1718,18 +1718,18 @@ function get_args()
if ( #t > 0 ) and nmap.registry.whois.using_local_assignments_file then
-- "nofile" was not explicitly supplied, but it is implied by supplying custom whoisdb_default_order
nmap.registry.whois.using_local_assignments_file = false
stdnse.print_debug(3, "%s: Not using local assignments data because custom whoisdb_default_order was supplied.", SCRIPT_NAME)
stdnse.debug3("Not using local assignments data because custom whoisdb_default_order was supplied.")
end
if ( #t > 1 ) and nmap.registry.whois.nofollow then
-- using nofollow, we do not follow redirects and can only accept what we find as a record therefore we only accept the first db supplied
t = {t[1]}
stdnse.print_debug( 1, "%s: Too many args supplied with 'nofollow', only using %s.", SCRIPT_NAME, t[1] )
stdnse.debug1("Too many args supplied with 'nofollow', only using %s.", t[1] )
end
if ( #t > 0 ) then
nmap.registry.whois.whoisdb_default_order = t
stdnse.print_debug( 2, "%s: whoisdb_default_order: %s.", SCRIPT_NAME, table.concat( t, " " ) )
stdnse.debug2("whoisdb_default_order: %s.", table.concat( t, " " ) )
end
end
@@ -1758,7 +1758,7 @@ function get_local_assignments_data()
local fetchfile = "nmap-services"
local directory_path, err = get_parentpath( fetchfile )
if err then
stdnse.print_debug( 1, "%s: Nmap.fetchfile() failed to get a path to %s: %s.", SCRIPT_NAME, fetchfile, err )
stdnse.debug1("Nmap.fetchfile() failed to get a path to %s: %s.", fetchfile, err )
return nil, err
end
@@ -1774,10 +1774,10 @@ function get_local_assignments_data()
local file, exists = directory_path .. assignment_data_spec.local_resource
exists, err = file_exists( file )
if not exists and err then
stdnse.print_debug( 1, "%s: Error accessing %s: %s.", SCRIPT_NAME, file, err )
stdnse.debug1("Error accessing %s: %s.", file, err )
elseif not exists then
update_required = true
stdnse.print_debug( 2, "%s: %s does not exist or is empty. Fetching it now...", SCRIPT_NAME, file )
stdnse.debug2("%s does not exist or is empty. Fetching it now...", file )
elseif exists then
update_required, modified_date, entity_tag = requires_updating( file )
end
@@ -1786,7 +1786,7 @@ function get_local_assignments_data()
-- read an existing and up-to-date file into file_content.
if exists and not update_required then
stdnse.print_debug( 2, "%s: %s was cached less than %s ago. Reading...", SCRIPT_NAME, file, nmap.registry.whois.local_assignments_file_expiry )
stdnse.debug2("%s was cached less than %s ago. Reading...", file, nmap.registry.whois.local_assignments_file_expiry )
file_content = read_from_file( file )
end
@@ -1795,10 +1795,10 @@ function get_local_assignments_data()
if update_required then
http_response = ( conditional_download( assignment_data_spec.remote_resource, modified_date, entity_tag ) )
if not http_response or type( http_response.status ) ~= "number" then
stdnse.print_debug( 1, "%s: Failed whilst requesting %s.", SCRIPT_NAME, assignment_data_spec.remote_resource )
stdnse.debug1("Failed whilst requesting %s.", assignment_data_spec.remote_resource )
elseif http_response.status == 200 then
-- prepend our file header
stdnse.print_debug( 2, "%s: Retrieved %s.", SCRIPT_NAME, assignment_data_spec.remote_resource )
stdnse.debug2("Retrieved %s.", assignment_data_spec.remote_resource )
file_content = stdnse.strsplit( "\r?\n", http_response.body )
table.insert( file_content, 1, "** Do Not Alter This Line or The Following Line **" )
local hline = {}
@@ -1810,19 +1810,19 @@ function get_local_assignments_data()
table.insert( file_content, 2, table.concat( hline ) )
write_success, err = write_to_file( file, file_content )
if err then
stdnse.print_debug( 1, "%s: Error writing %s to %s: %s.", SCRIPT_NAME, assignment_data_spec.remote_resource, file, err )
stdnse.debug1("Error writing %s to %s: %s.", assignment_data_spec.remote_resource, file, err )
end
elseif http_response.status == 304 then
-- update our file header with a new timestamp
stdnse.print_debug( 1, "%s: %s is up-to-date.", SCRIPT_NAME, file )
stdnse.debug1("%s is up-to-date.", file )
file_content = read_from_file( file )
file_content[2] = file_content[2]:gsub("^<[-+]?%d+>(.*)$", "<" .. os.time() .. ">%1")
write_success, err = write_to_file( file, file_content )
if err then
stdnse.print_debug( 1, "%s: Error writing to %s: %s.", SCRIPT_NAME, file, err )
stdnse.debug1("Error writing to %s: %s.", file, err )
end
else
stdnse.print_debug( 1, "%s: HTTP %s whilst requesting %s.", SCRIPT_NAME, http_response.status, assignment_data_spec.remote_resource )
stdnse.debug1("HTTP %s whilst requesting %s.", http_response.status, assignment_data_spec.remote_resource )
end
end
@@ -1836,7 +1836,7 @@ function get_local_assignments_data()
if #t == 0 or err then
-- good header, but bad file? Kill the file!
write_to_file( file, "" )
stdnse.print_debug( 1, "%s: Problem with the data in %s.", SCRIPT_NAME, file )
stdnse.debug1("Problem with the data in %s.", file )
else
for i, v in pairs( t ) do
ret[address_family][#ret[address_family]+1] = v
@@ -1855,7 +1855,7 @@ function get_local_assignments_data()
for af, t in pairs( ret ) do
if #t == 0 then
ret[af] = nil
stdnse.print_debug( 1, "%s: Cannot use local assignments file for address family %s.", SCRIPT_NAME, af )
stdnse.debug1("Cannot use local assignments file for address family %s.", af )
end
end
@@ -1979,7 +1979,7 @@ function read_from_file( file )
local f, err, _ = io.open( file, "r" )
if not f then
stdnse.print_debug( 1, "%s: Error opening %s for reading: %s", SCRIPT_NAME, file, err )
stdnse.debug1("Error opening %s for reading: %s", file, err )
return nil, err
end
@@ -2039,7 +2039,7 @@ function conditional_download( url, mod_date, e_tag )
and ( tostring( request_response.status ):match( "30%d" )
and type( request_response.header.location ) == "string"
and request_response.header.location ~= "" ) then
stdnse.print_debug( 2, "%s: HTTP Status:%d New Location: %s.", SCRIPT_NAME, request_response.status, request_response.header.location )
stdnse.debug2("HTTP Status:%d New Location: %s.", request_response.status, request_response.header.location )
request_response = http.get_url( request_response.header.location, request_options )
end
@@ -2068,7 +2068,7 @@ function write_to_file( file, content )
local f, err, _ = io.open( file, "w" )
if not f then
stdnse.print_debug( 1, "%s: Error opening %s for writing: %s.", SCRIPT_NAME, file, err )
stdnse.debug1("Error opening %s for writing: %s.", file, err )
return nil, err
end

View File

@@ -202,15 +202,15 @@ local id_database = {
local receive_tag = function(conn)
local status, data = conn:receive_buf(">", true)
if data then stdnse.print_debug(2, "%s: %s", SCRIPT_NAME, data) end
if data then stdnse.debug2("%s", data) end
return status and xmpp.XML.parse_tag(data)
end
local log_tag = function(tag)
stdnse.print_debug(2, "%s: %s", SCRIPT_NAME, "name=" .. tag.name)
stdnse.print_debug(2, "%s: %s", SCRIPT_NAME, "finish=" .. tostring(tag.finish))
stdnse.print_debug(2, "%s: %s", SCRIPT_NAME, "empty=" .. tostring(tag.empty))
stdnse.print_debug(2, "%s: %s", SCRIPT_NAME, "contents=" .. tag.contents)
stdnse.debug2("%s", "name=" .. tag.name)
stdnse.debug2("%s", "finish=" .. tostring(tag.finish))
stdnse.debug2("%s", "empty=" .. tostring(tag.empty))
stdnse.debug2("%s", "contents=" .. tag.contents)
end
local make_request = function(server_name, xmlns)
@@ -542,7 +542,7 @@ action = function(host, port)
local tls_result
local starttls_failed
stdnse.print_debug(2, "%s: %s", SCRIPT_NAME, "server = " .. server_name)
stdnse.debug2("%s", "server = " .. server_name)
local altname_result = scan(host, port, alt_server_name, false)