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

Manual corrections.
This commit is contained in:
batrick
2014-08-02 02:54:47 +00:00
parent 810f7d4803
commit aeb5908481
10 changed files with 31 additions and 40 deletions

View File

@@ -130,7 +130,7 @@ function parse_db2_packet(packet)
local response = {}
if packet.header.data_len < info_length_offset then
stdnse.print_debug( "db2-das-info: packet too short to be DB2 response...")
stdnse.debug1("packet too short to be DB2 response...")
return
end
@@ -172,7 +172,7 @@ function read_db2_packet(socket)
local ENDIANESS_OFFSET = 23
local catch = function()
stdnse.print_debug("%s", "db2-das-info: ERROR communicating with DB2 server")
stdnse.debug1("ERROR communicating with DB2 server")
socket:close()
end
@@ -235,7 +235,7 @@ end
function send_db2_packet( socket, packet )
local catch = function()
stdnse.print_debug("%s", "db2-das-info: ERROR communicating with DB2 server")
stdnse.debug1("ERROR communicating with DB2 server")
socket:close()
end
@@ -290,7 +290,7 @@ action = function(host, port)
-- do some exception handling / cleanup
local catch = function()
stdnse.print_debug("%s", "db2-das-info: ERROR communicating with " .. host.ip .. " on port " .. port.number)
stdnse.debug1("ERROR communicating with " .. host.ip .. " on port " .. port.number)
socket:close()
end

View File

@@ -201,8 +201,7 @@ action = function( host, port )
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",
SCRIPT_NAME, physical, logical, hostname)
stdnse.debug2("%s (%s) %s", physical, logical, hostname)
if (table_count(nodes, hostname) == 0) then
nodes[#nodes+1] = hostname
add_target(hostname)

View File

@@ -48,7 +48,7 @@ action = function(host, port)
-- If head failed, try using GET
if(status == false) then
stdnse.print_debug(1, "http-headers.nse: HEAD request failed, falling back to GET")
stdnse.debug1("HEAD request failed, falling back to GET")
result = http.get(host, port, path)
request_type = "GET"
end

View File

@@ -77,7 +77,7 @@ action = function(host, port)
end
-- Cache in case retest is requested.
options_status_line = response["status-line"]
stdnse.print_debug("http-methods.nse: HTTP Status for OPTIONS is " .. response.status)
stdnse.debug1("HTTP Status for OPTIONS is " .. response.status)
if not (response.header["allow"] or response.header["public"]) then
return string.format("No Allow or Public header in OPTIONS response (status code %d)", response.status)

View File

@@ -46,9 +46,7 @@ categories = {"discovery", "intrusive"}
portrule = shortport.http
local function dbg(str,...)
stdnse.print_debug(2,"%s:"..str, SCRIPT_NAME, ...)
end
local dbg = stdnse.debug2
local function getHostPort(parsed)
local host, port = parsed.host, parsed.port

View File

@@ -80,7 +80,7 @@ action = function(host, port)
local i
for i = 1, #usernames, 1 do
if(nmap.registry.args.limit and i > tonumber(nmap.registry.args.limit)) then
stdnse.print_debug(1, "http-userdir-enum.nse: Reached the limit (%d), stopping", nmap.registry.args.limit)
stdnse.debug1("Reached the limit (%d), stopping", nmap.registry.args.limit)
break;
end
@@ -95,7 +95,7 @@ action = function(host, port)
-- Check for http.pipeline error
if(results == nil) then
stdnse.print_debug(1, "http-userdir-enum.nse: http.pipeline returned nil")
stdnse.debug1("http.pipeline returned nil")
if(nmap.debugging() > 0) then
return "ERROR: http.pipeline returned nil"
else
@@ -106,7 +106,7 @@ action = function(host, port)
local found = {}
for i, data in pairs(results) do
if(http.page_exists(data, result_404, known_404, "/~" .. usernames[i], true)) then
stdnse.print_debug(1, "http-userdir-enum.nse: Found a valid user: %s", usernames[i])
stdnse.debug1("Found a valid user: %s", usernames[i])
table.insert(found, usernames[i])
end
end
@@ -136,8 +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.debug1("%s",
usernames or "Unknown Error reading usernames list.")
stdnse.debug1("%s", usernames or "Unknown Error reading usernames list.")
nmap.registry.userdir = {}
return nil
end

View File

@@ -79,7 +79,7 @@ overlapping byte ranges are requested.]],
if not path then
path = '/'
stdnse.print_debug(1, "Setting the request path to '/' since 'http-vuln-cve2011-3192.path' argument is missing.")
stdnse.debug1("Setting the request path to '/' since 'http-vuln-cve2011-3192.path' argument is missing.")
end
-- This first request will try to get a code 206 reply from the server by
@@ -100,8 +100,7 @@ overlapping byte ranges are requested.]],
local response = http.head(host, port, path, request_opts)
if not response.status then
stdnse.print_debug(1, "%s: Functionality check HEAD request failed for %s (with path '%s').",
SCRIPT_NAME, hostname or host.ip, path)
stdnse.debug1("Functionality check HEAD request failed for %s (with path '%s').", hostname or host.ip, path)
elseif response.status == 206 then
-- The server handle range requests. Now try to request 11 ranges (one more
-- than allowed).
@@ -117,12 +116,10 @@ overlapping byte ranges are requested.]],
elseif response.status == 206 then
vuln.state = vulns.STATE.VULN
else
stdnse.print_debug(1, "%s: Server isn't vulnerable (%i status code)",
SCRIPT_NAME, response.status)
stdnse.debug1("Server isn't vulnerable (%i status code)", response.status)
end
else
stdnse.print_debug(1, "%s: Server ignores the range header (%i status code)",
SCRIPT_NAME, response.status)
stdnse.debug1("Server ignores the range header (%i status code)", response.status)
end
return vuln_report:make_output(vuln)
end

View File

@@ -80,12 +80,12 @@ action = function(host, port)
local netgear_username = string.match(escape(payload_session.body), 'Router Admin Username</td>.+align="left">(.+)</td>.+Router Admin')
local netgear_password = string.match(escape(payload_session.body), 'Router Admin Password</td>.+align="left">(.+)</td>.+MNUText')
if (username ~= nil and password ~= nil) then
stdnse.print_debug(1, "%s: username : " .. escape(netgear_username), SCRIPT_NAME)
stdnse.print_debug(1, "%s: password : " .. escape(netgear_password), SCRIPT_NAME)
stdnse.debug1("username : %s", escape(netgear_username))
stdnse.debug1("password : %s", escape(netgear_password))
else
stdnse.debug1("We haven't been able to get username/password")
end
end
end
end
end
end

View File

@@ -153,7 +153,7 @@ action = function(host, port)
for i, data in pairs(pipeline_returns) do
-- if it's not a four-'o-four, it probably means that the plugin is present
if http.page_exists(data, result_404, body_404, bfqueries[i][1], true) then
stdnse.print_debug(1, "http-wordpress-plugins.nse: Found a plugin: %s", bfqueries[i][2])
stdnse.debug1("Found a plugin: %s", bfqueries[i][2])
table.insert(result, bfqueries[i][2])
end
end

View File

@@ -71,9 +71,7 @@ local detail_debug = 3 -- debug level for printing individual login steps
-- @param level Verbosity level (mandatory, unlike stdnse.print_debug).
-- @param fmt Format string.
-- @param ... Arguments to format.
local print_debug = function (level, fmt, ...)
stdnse.print_debug(level, "%s: " .. fmt, SCRIPT_NAME, ...)
end
local debug = stdnse.debug
local patt_login = U.atwordboundary(re.compile [[([uU][sS][eE][rR][nN][aA][mM][eE] / [lL][oO][gG][iI][nN]) %s* ':' %s* !.]])
@@ -478,7 +476,7 @@ Driver.methods.connect_autosize = function (self)
end
-- let's park the thread here till all the functioning threads finish
self.target:inuse(false)
print_debug(detail_debug, "Retiring %s", tostring(coroutine.running()))
debug(detail_debug, "Retiring %s", tostring(coroutine.running()))
while not self.target:idle() do self.thread_exit("wait") end
-- pretend that it connected
self.conn = Connection.GHOST
@@ -538,7 +536,7 @@ Driver.methods.login = function (self, username, password)
local loc = " in " .. tostring(coroutine.running())
local connection_error = function (msg)
print_debug(detail_debug, msg .. loc)
debug(detail_debug, msg .. loc)
local err = brute.Error:new(msg)
err:setRetry(true)
return false, err
@@ -546,7 +544,7 @@ Driver.methods.login = function (self, username, password)
local passonly_error = function ()
local msg = "Password prompt encountered"
print_debug(critical_debug, msg .. loc)
debug(critical_debug, msg .. loc)
local err = brute.Error:new(msg)
err:setAbort(true)
return false, err
@@ -554,7 +552,7 @@ Driver.methods.login = function (self, username, password)
local username_error = function ()
local msg = "Invalid username encountered"
print_debug(detail_debug, msg .. loc)
debug(detail_debug, msg .. loc)
local err = brute.Error:new(msg)
err:setInvalidAccount(username)
return false, err
@@ -562,23 +560,23 @@ Driver.methods.login = function (self, username, password)
local login_error = function ()
local msg = "Login failed"
print_debug(detail_debug, msg .. loc)
debug(detail_debug, msg .. loc)
return false, brute.Error:new(msg)
end
local login_success = function ()
local msg = "Login succeeded"
print_debug(detail_debug, msg .. loc)
debug(detail_debug, msg .. loc)
return true, brute.Account:new(username, password, "OPEN")
end
local login_no_password = function ()
local msg = "Login succeeded without password"
print_debug(detail_debug, msg .. loc)
debug(detail_debug, msg .. loc)
return true, brute.Account:new(username, "<none>", "OPEN")
end
print_debug(detail_debug, "Login attempt %s:%s%s", username, password, loc)
debug(detail_debug, "Login attempt %s:%s%s", username, password, loc)
if conn == Connection.GHOST then
-- reached when auto-sizing is enabled and all worker threads
@@ -597,7 +595,7 @@ Driver.methods.login = function (self, username, password)
if is_username_prompt(line) then
-- being prompted for a username
conn:discard_line()
print_debug(detail_debug, "Sending username" .. loc)
debug(detail_debug, "Sending username" .. loc)
if not conn:send_line(username) then
return connection_error(conn.error)
end
@@ -633,7 +631,7 @@ Driver.methods.login = function (self, username, password)
elseif is_password_prompt(line) then
-- being prompted for a password
conn:discard_line()
print_debug(detail_debug, "Sending password" .. loc)
debug(detail_debug, "Sending password" .. loc)
if not conn:send_line(password) then
return connection_error(conn.error)
end