1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41: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()
if ( not(iname) ) then
stdnse.print_debug("%s: No interface supplied, use -e", SCRIPT_NAME)
stdnse.debug1("No interface supplied, use -e")
return
end
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
end

View File

@@ -224,7 +224,7 @@ action = function()
return ("\n ERROR: Failed to retrieve %s interface information."):format(interface)
end
interfaces = {interface}
stdnse.print_debug("%s: Will use %s interface.", SCRIPT_NAME, interface.shortname)
stdnse.debug1("Will use %s interface.", interface.shortname)
else
local ifacelist = nmap.list_interfaces()
for _, iface in ipairs(ifacelist) do
@@ -232,7 +232,7 @@ action = function()
if iface.address and iface.link=="ethernet" and
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)
end
end
@@ -243,7 +243,7 @@ action = function()
if not as then
-- We use a table for condvar
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
for _, interface in pairs(interfaces) do
local co = stdnse.new_thread(asListener, interface, timeout, astab)

View File

@@ -302,14 +302,14 @@ local mgroup_names_fetch = function(filename)
end
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
local ip1 = mg[1]
local ip2 = mg[2]
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
--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
end
end
@@ -341,7 +341,7 @@ action = function(host, port)
return ("ERROR: Failed to retrieve %s interface information."):format(interface)
end
interfaces = {interface}
stdnse.print_debug("%s: Will use %s interface.", SCRIPT_NAME, interface.shortname)
stdnse.debug1("Will use %s interface.", interface.shortname)
else
local ifacelist = nmap.list_interfaces()
for _, iface in ipairs(ifacelist) do
@@ -349,7 +349,7 @@ action = function(host, port)
if iface.address and iface.link=="ethernet" and
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)
end
end

View File

@@ -111,7 +111,7 @@ loadDecoders = function(fname)
local env = setmetatable({Decoders = {}}, {__index = _G});
local file = loadfile(abs_fname, "t", env)
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
end

View File

@@ -167,7 +167,7 @@ action = function()
return ("\n ERROR: Couldn't get interface for %s"):format(mcast)
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
stdnse.new_thread(helloListen, interface, timeout, responses)

View File

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

View File

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

View File

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

View File

@@ -52,7 +52,7 @@ end
-- made so no more requests are made to the server during one scan
action = function(host)
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
end
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 not nmap.registry["ip-geolocation-geobytes"] then nmap.registry["ip-geolocation-geobytes"]={} end
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
end
-- Process output
@@ -80,7 +80,7 @@ action = function(host)
elseif response.body:match("Limit Exceeded") then
if not nmap.registry["ip-geolocation-geobytes"] then nmap.registry["ip-geolocation-geobytes"]={} end
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
end
return nil

View File

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

View File

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

View File

@@ -258,7 +258,7 @@ action = function()
return ("\n ERROR: Couldn't get interface for %s"):format(target)
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
stdnse.new_thread(mrinfoListen, interface, timeout, responses)

View File

@@ -348,8 +348,8 @@ action = function()
-- Destination defaults to our own host
toip = toip or interface.address
stdnse.print_debug("%s: Traceroute group %s from %s to %s.", SCRIPT_NAME, group, fromip, toip)
stdnse.print_debug("%s: will send to %s via %s interface.", SCRIPT_NAME, firsthop, interface.shortname)
stdnse.debug1("Traceroute group %s from %s to %s.", group, fromip, toip)
stdnse.debug1("will send to %s via %s interface.", firsthop, interface.shortname)
-- Thread that listens for 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)
if not status then
stdnse.print_debug("%s: error connecting: %s", SCRIPT_NAME, err)
stdnse.debug1("error connecting: %s", err)
return nil
end
local status, info = mysql.receiveGreeting(socket)
if not status then
stdnse.print_debug("%s: MySQL error: %s", SCRIPT_NAME, info)
stdnse.debug1("MySQL error: %s", info)
output["MySQL Error"] = info
if nmap.verbosity() > 1 then
return output

View File

@@ -59,14 +59,14 @@ local function account_enum_targets(host, port, username, password)
local status, err = session:connect(host, port)
if not status then
stdnse.print_debug("%s: connection failure (%s)", SCRIPT_NAME, err)
stdnse.debug1("connection failure (%s)", err)
return nil
end
if session:authenticate(username, password) then
targets = session:ls_targets()
else
stdnse.print_debug("%s: authentication failure (%s:%s)", SCRIPT_NAME, username, password)
stdnse.debug1("authentication failure (%s:%s)", username, password)
end
session:close()
@@ -115,7 +115,7 @@ action = function(host, port)
end
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))
end

View File

@@ -78,7 +78,7 @@ local isRPC = function(host, port)
rpcConn = rpc.Comm:new("rpcbind", 2)
status, err = rpcConn:Connect(host, port)
if not status then
stdnse.print_debug("%s: %s", SCRIPT_NAME, err)
stdnse.debug1("%s", err)
return
end
@@ -94,7 +94,7 @@ local isRPC = function(host, port)
-- And check response
status, data = rpcConn:ReceivePacket()
if not status then
stdnse.print_debug("%s: isRPC didn't receive response.", SCRIPT_NAME)
stdnse.debug1("isRPC didn't receive response.")
return
else
-- If we got response, set port to open
@@ -110,7 +110,7 @@ local isRPC = function(host, port)
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
-- Function that iterates over the nmap-rpc file and
@@ -121,14 +121,14 @@ local rpcIterator = function()
-- Check if nmap-rpc file is present.
local path = nmap.fetchfile("nmap-rpc")
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
end
-- And is readable
local nmaprpc, _, _ = io.open( path, "r" )
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
end
@@ -199,7 +199,7 @@ local rpcGrinder = function(host, port, iterator, result)
if type(response) == 'table' then
if xid ~= response.xid then
-- Shouldn't happen.
stdnse.print_debug("%s: XID mismatch.", SCRIPT_NAME)
stdnse.debug1("XID mismatch.")
end
-- Look at accept state
-- 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
i, record = tls.record_read(response, i)
if record == nil then
stdnse.print_debug("%s: Unknown response from server", SCRIPT_NAME)
stdnse.debug1("Unknown response from server")
s:close()
return "NOT_VULNERABLE"
elseif record.protocol ~= version then

View File

@@ -109,7 +109,7 @@ end
local extract_time = function(response)
local i, record = tls.record_read(response, 0)
if record == nil then
stdnse.print_debug("%s: Unknown response from server", SCRIPT_NAME)
stdnse.debug1("Unknown response from server")
return nil
end
@@ -120,7 +120,7 @@ local extract_time = function(response)
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
end

View File

@@ -153,11 +153,11 @@ local function testversion(host, port, version)
local record
i, record = tls.record_read(response, i)
if record == nil then
stdnse.print_debug("%s: Unknown response from server", SCRIPT_NAME)
stdnse.debug1("Unknown response from server")
s:close()
return nil
elseif record.protocol ~= version then
stdnse.print_debug("%s: Protocol version mismatch", SCRIPT_NAME)
stdnse.debug1("Protocol version mismatch")
s:close()
return nil
end
@@ -176,7 +176,7 @@ local function testversion(host, port, version)
end
until done
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()
return nil
end

View File

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

View File

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