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

stdnse.print_debug -> stdnse.debug1

sed -i 's/stdnse.print_debug("%s: \([^"]*\)", SCRIPT_NAME/stdnse.debug1("\1"/' *.nse
This commit is contained in:
batrick
2014-08-01 21:31:04 +00:00
parent 5161b8642a
commit c94d5970ff
21 changed files with 46 additions and 46 deletions

View File

@@ -131,12 +131,12 @@ action = function()
local iname = nmap.get_interface() local iname = nmap.get_interface()
if ( not(iname) ) then if ( not(iname) ) then
stdnse.print_debug("%s: No interface supplied, use -e", SCRIPT_NAME) stdnse.debug1("No interface supplied, use -e")
return return
end end
if ( not(nmap.is_privileged()) ) then if ( not(nmap.is_privileged()) ) then
stdnse.print_debug("%s: not running for lack of privileges", SCRIPT_NAME) stdnse.debug1("not running for lack of privileges")
return return
end end

View File

@@ -224,7 +224,7 @@ action = function()
return ("\n ERROR: Failed to retrieve %s interface information."):format(interface) return ("\n ERROR: Failed to retrieve %s interface information."):format(interface)
end end
interfaces = {interface} interfaces = {interface}
stdnse.print_debug("%s: Will use %s interface.", SCRIPT_NAME, interface.shortname) stdnse.debug1("Will use %s interface.", interface.shortname)
else else
local ifacelist = nmap.list_interfaces() local ifacelist = nmap.list_interfaces()
for _, iface in ipairs(ifacelist) do for _, iface in ipairs(ifacelist) do
@@ -232,7 +232,7 @@ action = function()
if iface.address and iface.link=="ethernet" and if iface.address and iface.link=="ethernet" and
iface.address:match("%d+%.%d+%.%d+%.%d+") then iface.address:match("%d+%.%d+%.%d+%.%d+") then
stdnse.print_debug("%s: Will use %s interface.", SCRIPT_NAME, iface.shortname) stdnse.debug1("Will use %s interface.", iface.shortname)
table.insert(interfaces, iface) table.insert(interfaces, iface)
end end
end end
@@ -243,7 +243,7 @@ action = function()
if not as then if not as then
-- We use a table for condvar -- We use a table for condvar
local astab = {} local astab = {}
stdnse.print_debug("%s: No A.S value provided, will sniff for one.", SCRIPT_NAME) stdnse.debug1("No A.S value provided, will sniff for one.")
-- We should iterate over interfaces -- We should iterate over interfaces
for _, interface in pairs(interfaces) do for _, interface in pairs(interfaces) do
local co = stdnse.new_thread(asListener, interface, timeout, astab) local co = stdnse.new_thread(asListener, interface, timeout, astab)

View File

@@ -302,14 +302,14 @@ local mgroup_names_fetch = function(filename)
end end
local mgroup_name_identify = function(db, ip) local mgroup_name_identify = function(db, ip)
--stdnse.print_debug("%s: '%s'", SCRIPT_NAME, ip) --stdnse.debug1("'%s'", ip)
for _, mg in ipairs(db) do for _, mg in ipairs(db) do
local ip1 = mg[1] local ip1 = mg[1]
local ip2 = mg[2] local ip2 = mg[2]
local desc = mg[3] local desc = mg[3]
--stdnse.print_debug("%s: try: %s <= %s <= %s (%s)", SCRIPT_NAME, ip1, ip, ip2, desc) --stdnse.debug1("try: %s <= %s <= %s (%s)", ip1, ip, ip2, desc)
if (not ipOps.compare_ip(ip, "lt", ip1) and not ipOps.compare_ip(ip2, "lt", ip)) then if (not ipOps.compare_ip(ip, "lt", ip1) and not ipOps.compare_ip(ip2, "lt", ip)) then
--stdnse.print_debug("%s: found! %s <= %s <= %s (%s)", SCRIPT_NAME, ip1, ip, ip2, desc) --stdnse.debug1("found! %s <= %s <= %s (%s)", ip1, ip, ip2, desc)
return desc return desc
end end
end end
@@ -341,7 +341,7 @@ action = function(host, port)
return ("ERROR: Failed to retrieve %s interface information."):format(interface) return ("ERROR: Failed to retrieve %s interface information."):format(interface)
end end
interfaces = {interface} interfaces = {interface}
stdnse.print_debug("%s: Will use %s interface.", SCRIPT_NAME, interface.shortname) stdnse.debug1("Will use %s interface.", interface.shortname)
else else
local ifacelist = nmap.list_interfaces() local ifacelist = nmap.list_interfaces()
for _, iface in ipairs(ifacelist) do for _, iface in ipairs(ifacelist) do
@@ -349,7 +349,7 @@ action = function(host, port)
if iface.address and iface.link=="ethernet" and if iface.address and iface.link=="ethernet" and
iface.address:match("%d+%.%d+%.%d+%.%d+") then iface.address:match("%d+%.%d+%.%d+%.%d+") then
stdnse.print_debug("%s: Will use %s interface.", SCRIPT_NAME, iface.shortname) stdnse.debug1("Will use %s interface.", iface.shortname)
table.insert(interfaces, iface) table.insert(interfaces, iface)
end end
end end

View File

@@ -111,7 +111,7 @@ loadDecoders = function(fname)
local env = setmetatable({Decoders = {}}, {__index = _G}); local env = setmetatable({Decoders = {}}, {__index = _G});
local file = loadfile(abs_fname, "t", env) local file = loadfile(abs_fname, "t", env)
if(not(file)) then if(not(file)) then
stdnse.print_debug("%s: Couldn't load decoder file: %s", SCRIPT_NAME, fname) stdnse.debug1("Couldn't load decoder file: %s", fname)
return false, "ERROR: Couldn't load decoder file: " .. fname return false, "ERROR: Couldn't load decoder file: " .. fname
end end

View File

@@ -167,7 +167,7 @@ action = function()
return ("\n ERROR: Couldn't get interface for %s"):format(mcast) return ("\n ERROR: Couldn't get interface for %s"):format(mcast)
end end
stdnse.print_debug("%s: will send via %s interface.", SCRIPT_NAME, interface.shortname) stdnse.debug1("will send via %s interface.", interface.shortname)
-- Launch listener -- Launch listener
stdnse.new_thread(helloListen, interface, timeout, responses) stdnse.new_thread(helloListen, interface, timeout, responses)

View File

@@ -45,7 +45,7 @@ action = function( host, port )
local try = nmap.new_try( local try = nmap.new_try(
function() function()
stdnse.print_debug("%s: failed", SCRIPT_NAME) stdnse.debug1("failed")
socket:close() socket:close()
end end
) )

View File

@@ -89,7 +89,7 @@ action = function(host, port)
local res, res404, known404 = http.identify_404(host, port) local res, res404, known404 = http.identify_404(host, port)
if not res then if not res then
stdnse.print_debug("%s: Can't identify 404 pages", SCRIPT_NAME) stdnse.debug1("Can't identify 404 pages")
return nil return nil
end end

View File

@@ -125,7 +125,7 @@ function action(host, port)
-- Do the requests. -- Do the requests.
replies = http.pipeline_go(host, port, pl_requests) replies = http.pipeline_go(host, port, pl_requests)
if replies == nil then if replies == nil then
stdnse.print_debug("%s: pipeline_go() error. Aborting.", SCRIPT_NAME) stdnse.debug1("pipeline_go() error. Aborting.")
return nil return nil
end end

View File

@@ -52,7 +52,7 @@ end
-- made so no more requests are made to the server during one scan -- made so no more requests are made to the server during one scan
action = function(host) action = function(host)
if nmap.registry["ip-geolocation-geobytes"] and nmap.registry["ip-geolocation-geobytes"].blocked then if nmap.registry["ip-geolocation-geobytes"] and nmap.registry["ip-geolocation-geobytes"].blocked then
stdnse.print_debug("%s: 20 requests per hour Limit Exceeded", SCRIPT_NAME) stdnse.debug1("20 requests per hour Limit Exceeded")
return nil return nil
end end
local response = http.get("www.geobytes.com", 80, "/IpLocator.htm?GetLocation&template=json.txt&IpAddress="..host.ip, nil) local response = http.get("www.geobytes.com", 80, "/IpLocator.htm?GetLocation&template=json.txt&IpAddress="..host.ip, nil)
@@ -63,7 +63,7 @@ action = function(host)
if loc.city and loc.city == "Limit Exceeded" then if loc.city and loc.city == "Limit Exceeded" then
if not nmap.registry["ip-geolocation-geobytes"] then nmap.registry["ip-geolocation-geobytes"]={} end if not nmap.registry["ip-geolocation-geobytes"] then nmap.registry["ip-geolocation-geobytes"]={} end
nmap.registry["ip-geolocation-geobytes"].blocked = true nmap.registry["ip-geolocation-geobytes"].blocked = true
stdnse.print_debug("%s: 20 requests per hour Limit Exceeded", SCRIPT_NAME) stdnse.debug1("20 requests per hour Limit Exceeded")
return nil return nil
end end
-- Process output -- Process output
@@ -80,7 +80,7 @@ action = function(host)
elseif response.body:match("Limit Exceeded") then elseif response.body:match("Limit Exceeded") then
if not nmap.registry["ip-geolocation-geobytes"] then nmap.registry["ip-geolocation-geobytes"]={} end if not nmap.registry["ip-geolocation-geobytes"] then nmap.registry["ip-geolocation-geobytes"]={} end
nmap.registry["ip-geolocation-geobytes"].blocked = true nmap.registry["ip-geolocation-geobytes"].blocked = true
stdnse.print_debug("%s: 20 requests per hour Limit Exceeded", SCRIPT_NAME) stdnse.debug1("20 requests per hour Limit Exceeded")
return nil return nil
end end
return nil return nil

View File

@@ -63,14 +63,14 @@ action = function( host, port )
local status = helper:connect() local status = helper:connect()
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug("%s: failed to connect to server", SCRIPT_NAME ) stdnse.debug1("failed to connect to server" )
return return
end end
local records local records
status, records = helper:discoverTargets() status, records = helper:discoverTargets()
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug("%s: failed to discover targets", SCRIPT_NAME ) stdnse.debug1("failed to discover targets" )
return return
end end
status = helper:logout() status = helper:logout()

View File

@@ -74,7 +74,7 @@ local llmnrSend = function(query, mcast, mport)
local sock = nmap.new_socket() local sock = nmap.new_socket()
local status, err = sock:connect(mcast, mport, "udp") local status, err = sock:connect(mcast, mport, "udp")
if not status then if not status then
stdnse.print_debug("%s: %s", SCRIPT_NAME, err) stdnse.debug1("%s", err)
return return
end end
sock:send(query) sock:send(query)

View File

@@ -258,7 +258,7 @@ action = function()
return ("\n ERROR: Couldn't get interface for %s"):format(target) return ("\n ERROR: Couldn't get interface for %s"):format(target)
end end
stdnse.print_debug("%s: will send to %s via %s interface.", SCRIPT_NAME, target, interface.shortname) stdnse.debug1("will send to %s via %s interface.", target, interface.shortname)
-- Thread that listens for responses -- Thread that listens for responses
stdnse.new_thread(mrinfoListen, interface, timeout, responses) stdnse.new_thread(mrinfoListen, interface, timeout, responses)

View File

@@ -348,8 +348,8 @@ action = function()
-- Destination defaults to our own host -- Destination defaults to our own host
toip = toip or interface.address toip = toip or interface.address
stdnse.print_debug("%s: Traceroute group %s from %s to %s.", SCRIPT_NAME, group, fromip, toip) stdnse.debug1("Traceroute group %s from %s to %s.", group, fromip, toip)
stdnse.print_debug("%s: will send to %s via %s interface.", SCRIPT_NAME, firsthop, interface.shortname) stdnse.debug1("will send to %s via %s interface.", firsthop, interface.shortname)
-- Thread that listens for responses -- Thread that listens for responses
stdnse.new_thread(traceListener, interface, timeout, responses) stdnse.new_thread(traceListener, interface, timeout, responses)

View File

@@ -80,14 +80,14 @@ action = function(host, port)
local status, err = socket:connect(host, port) local status, err = socket:connect(host, port)
if not status then if not status then
stdnse.print_debug("%s: error connecting: %s", SCRIPT_NAME, err) stdnse.debug1("error connecting: %s", err)
return nil return nil
end end
local status, info = mysql.receiveGreeting(socket) local status, info = mysql.receiveGreeting(socket)
if not status then if not status then
stdnse.print_debug("%s: MySQL error: %s", SCRIPT_NAME, info) stdnse.debug1("MySQL error: %s", info)
output["MySQL Error"] = info output["MySQL Error"] = info
if nmap.verbosity() > 1 then if nmap.verbosity() > 1 then
return output return output

View File

@@ -59,14 +59,14 @@ local function account_enum_targets(host, port, username, password)
local status, err = session:connect(host, port) local status, err = session:connect(host, port)
if not status then if not status then
stdnse.print_debug("%s: connection failure (%s)", SCRIPT_NAME, err) stdnse.debug1("connection failure (%s)", err)
return nil return nil
end end
if session:authenticate(username, password) then if session:authenticate(username, password) then
targets = session:ls_targets() targets = session:ls_targets()
else else
stdnse.print_debug("%s: authentication failure (%s:%s)", SCRIPT_NAME, username, password) stdnse.debug1("authentication failure (%s:%s)", username, password)
end end
session:close() session:close()
@@ -115,7 +115,7 @@ action = function(host, port)
end end
if target.ALLOW_NEW_TARGETS and targets ~= nil then if target.ALLOW_NEW_TARGETS and targets ~= nil then
stdnse.print_debug("%s: adding new targets %s", SCRIPT_NAME, stdnse.strjoin(", ", targets)) stdnse.debug1("adding new targets %s", stdnse.strjoin(", ", targets))
target.add(table.unpack(targets)) target.add(table.unpack(targets))
end end

View File

@@ -78,7 +78,7 @@ local isRPC = function(host, port)
rpcConn = rpc.Comm:new("rpcbind", 2) rpcConn = rpc.Comm:new("rpcbind", 2)
status, err = rpcConn:Connect(host, port) status, err = rpcConn:Connect(host, port)
if not status then if not status then
stdnse.print_debug("%s: %s", SCRIPT_NAME, err) stdnse.debug1("%s", err)
return return
end end
@@ -94,7 +94,7 @@ local isRPC = function(host, port)
-- And check response -- And check response
status, data = rpcConn:ReceivePacket() status, data = rpcConn:ReceivePacket()
if not status then if not status then
stdnse.print_debug("%s: isRPC didn't receive response.", SCRIPT_NAME) stdnse.debug1("isRPC didn't receive response.")
return return
else else
-- If we got response, set port to open -- If we got response, set port to open
@@ -110,7 +110,7 @@ local isRPC = function(host, port)
end end
end end
end end
stdnse.print_debug("%s: RPC checking function response data is not RPC.", SCRIPT_NAME) stdnse.debug1("RPC checking function response data is not RPC.")
end end
-- Function that iterates over the nmap-rpc file and -- Function that iterates over the nmap-rpc file and
@@ -121,14 +121,14 @@ local rpcIterator = function()
-- Check if nmap-rpc file is present. -- Check if nmap-rpc file is present.
local path = nmap.fetchfile("nmap-rpc") local path = nmap.fetchfile("nmap-rpc")
if not path then if not path then
stdnse.print_debug("%s: Could not find nmap-rpc file.", SCRIPT_NAME) stdnse.debug1("Could not find nmap-rpc file.")
return false return false
end end
-- And is readable -- And is readable
local nmaprpc, _, _ = io.open( path, "r" ) local nmaprpc, _, _ = io.open( path, "r" )
if not nmaprpc then if not nmaprpc then
stdnse.print_debug("%s: Could not open nmap-rpc for reading.", SCRIPT_NAME) stdnse.debug1("Could not open nmap-rpc for reading.")
return false return false
end end
@@ -199,7 +199,7 @@ local rpcGrinder = function(host, port, iterator, result)
if type(response) == 'table' then if type(response) == 'table' then
if xid ~= response.xid then if xid ~= response.xid then
-- Shouldn't happen. -- Shouldn't happen.
stdnse.print_debug("%s: XID mismatch.", SCRIPT_NAME) stdnse.debug1("XID mismatch.")
end end
-- Look at accept state -- Look at accept state
-- Not supported version means that we used the right program number -- Not supported version means that we used the right program number

View File

@@ -176,7 +176,7 @@ local function test_ccs_injection(host, port, version)
local record local record
i, record = tls.record_read(response, i) i, record = tls.record_read(response, i)
if record == nil then if record == nil then
stdnse.print_debug("%s: Unknown response from server", SCRIPT_NAME) stdnse.debug1("Unknown response from server")
s:close() s:close()
return "NOT_VULNERABLE" return "NOT_VULNERABLE"
elseif record.protocol ~= version then elseif record.protocol ~= version then

View File

@@ -109,7 +109,7 @@ end
local extract_time = function(response) local extract_time = function(response)
local i, record = tls.record_read(response, 0) local i, record = tls.record_read(response, 0)
if record == nil then if record == nil then
stdnse.print_debug("%s: Unknown response from server", SCRIPT_NAME) stdnse.debug1("Unknown response from server")
return nil return nil
end end
@@ -120,7 +120,7 @@ local extract_time = function(response)
end end
end end
end end
stdnse.print_debug("%s: Server response was not server_hello", SCRIPT_NAME) stdnse.debug1("Server response was not server_hello")
return nil return nil
end end

View File

@@ -153,11 +153,11 @@ local function testversion(host, port, version)
local record local record
i, record = tls.record_read(response, i) i, record = tls.record_read(response, i)
if record == nil then if record == nil then
stdnse.print_debug("%s: Unknown response from server", SCRIPT_NAME) stdnse.debug1("Unknown response from server")
s:close() s:close()
return nil return nil
elseif record.protocol ~= version then elseif record.protocol ~= version then
stdnse.print_debug("%s: Protocol version mismatch", SCRIPT_NAME) stdnse.debug1("Protocol version mismatch")
s:close() s:close()
return nil return nil
end end
@@ -176,7 +176,7 @@ local function testversion(host, port, version)
end end
until done until done
if not supported then if not supported then
stdnse.print_debug("%s: Server does not support TLS Heartbeat Requests.", SCRIPT_NAME) stdnse.debug1("Server does not support TLS Heartbeat Requests.")
s:close() s:close()
return nil return nil
end end

View File

@@ -68,7 +68,7 @@ action = function(host, port)
string.format(request, host.targetname or host.ip), string.format(request, host.targetname or host.ip),
{ timeout=3000, lines=4 }) { timeout=3000, lines=4 })
if not socket then if not socket then
stdnse.print_debug("%s: Problem establishing connection: %s", SCRIPT_NAME, response) stdnse.debug1("Problem establishing connection: %s", response)
return nil return nil
end end
socket:close() socket:close()

View File

@@ -102,19 +102,19 @@ end
local check_npn = function(response) local check_npn = function(response)
local i, record = tls.record_read(response, 0) local i, record = tls.record_read(response, 0)
if record == nil then if record == nil then
stdnse.print_debug("%s: Unknown response from server", SCRIPT_NAME) stdnse.debug1("Unknown response from server")
return nil return nil
end end
if record.type == "handshake" and record.body[1].type == "server_hello" then if record.type == "handshake" and record.body[1].type == "server_hello" then
if record.body[1].extensions == nil then if record.body[1].extensions == nil then
stdnse.print_debug("%s: Server does not support TLS NPN extension.", SCRIPT_NAME) stdnse.debug1("Server does not support TLS NPN extension.")
return nil return nil
end end
local results = {} local results = {}
local npndata = record.body[1].extensions["next_protocol_negotiation"] local npndata = record.body[1].extensions["next_protocol_negotiation"]
if npndata == nil then if npndata == nil then
stdnse.print_debug("%s: Server does not support TLS NPN extension.", SCRIPT_NAME) stdnse.debug1("Server does not support TLS NPN extension.")
return nil return nil
end end
-- Parse data -- Parse data
@@ -127,7 +127,7 @@ local check_npn = function(response)
return results return results
else else
stdnse.print_debug("%s: Server response was not server_hello", SCRIPT_NAME) stdnse.debug1("Server response was not server_hello")
return nil return nil
end end
end end