From 5d4c5a659c9553d8d94a461d09c295ad6353bad7 Mon Sep 17 00:00:00 2001 From: batrick Date: Sat, 2 Aug 2014 02:13:12 +0000 Subject: [PATCH] more stdnse.print_debug -> stdnse.debug $ sed -i 's/stdnse.print_debug( *\([0-9]*\) *, *SCRIPT_NAME *.. *" *:* *\([^"]*\)"/stdnse.debug\1("\2"/' *.nse $ sed -i 's/stdnse.print_debug( *SCRIPT_NAME *.. *" *:* *\([^"]*\)"/stdnse.debug1("\1"/' *.nse --- scripts/http-config-backup.nse | 2 +- scripts/http-slowloris.nse | 22 +++++++++++----------- scripts/sip-call-spoof.nse | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/http-config-backup.nse b/scripts/http-config-backup.nse index 1c80755a2..50015653a 100644 --- a/scripts/http-config-backup.nse +++ b/scripts/http-config-backup.nse @@ -223,7 +223,7 @@ action = function (host, port) table.insert(backups, url_path .. " " .. response["status-line"]); else - stdnse.print_debug(1, SCRIPT_NAME .. ": %s: found but not matching: %s", + stdnse.debug1("%s: found but not matching: %s", host.targetname or host.ip, url_path); end end diff --git a/scripts/http-slowloris.nse b/scripts/http-slowloris.nse index e9e3cf658..01efc36e0 100644 --- a/scripts/http-slowloris.nse +++ b/scripts/http-slowloris.nse @@ -116,7 +116,7 @@ local function do_half_http(host, port, obj) local catch = function() -- This connection is now dead ThreadCount = ThreadCount - 1 - stdnse.print_debug(SCRIPT_NAME .. " [HALF HTTP]: lost connection") + stdnse.debug1("[HALF HTTP]: lost connection") slowloris:close() slowloris = nil condvar("signal") @@ -161,7 +161,7 @@ local function do_monitor(host, port) local general_faults = 0 local request_faults = 0 -- keeps track of how many times we didn't get a reply from the server - stdnse.print_debug(SCRIPT_NAME .. " [MONITOR]: Monitoring " .. host.ip .. " started") + stdnse.debug1("[MONITOR]: Monitoring " .. host.ip .. " started") local request = "GET / HTTP/1.1\r\n" .. "Host: " .. host.ip .. @@ -193,12 +193,12 @@ local function do_monitor(host, port) end status, _ = monitor:receive_lines(1) if not status then - stdnse.print_debug(SCRIPT_NAME .. " [MONITOR]: Didn't get a reply from " .. host.ip .. "." ) + stdnse.debug1("[MONITOR]: Didn't get a reply from " .. host.ip .. "." ) monitor:close() request_faults = request_faults +1 if request_faults > 3 then if TimeLimit then - stdnse.print_debug(SCRIPT_NAME .. " [MONITOR]: server " .. host.ip .. " is now unavailable. The attack worked.") + stdnse.debug1("[MONITOR]: server " .. host.ip .. " is now unavailable. The attack worked.") DOSed = true end monitor:close() @@ -207,7 +207,7 @@ local function do_monitor(host, port) else request_faults = 0 general_faults = 0 - stdnse.print_debug(SCRIPT_NAME .. " [MONITOR]: ".. host.ip .." still up, answer received.") + stdnse.debug1("[MONITOR]: ".. host.ip .." still up, answer received.") stdnse.sleep(10) monitor:close() end @@ -246,7 +246,7 @@ local function worker_scheduler(host, port) Threads[thread] = nil end end - stdnse.print_debug(SCRIPT_NAME .. " [SCHEDULER]: starting new thread") + stdnse.debug1("[SCHEDULER]: starting new thread") local co = stdnse.new_thread(do_half_http, host, port, obj) Threads[co] = true if ( next(Threads) ) then @@ -273,19 +273,19 @@ action = function(host, port) stdnse.new_thread(do_monitor, host, port) stdnse.sleep(2) -- let the monitor make the first request - stdnse.print_debug(SCRIPT_NAME .. " [MAIN THREAD]: starting scheduler") + stdnse.debug1("[MAIN THREAD]: starting scheduler") stdnse.new_thread(worker_scheduler, host, port) local end_time = get_end_time() local last_message if TimeLimit == nil then - stdnse.print_debug(SCRIPT_NAME .. " [MAIN THREAD]: running forever!") + stdnse.debug1("[MAIN THREAD]: running forever!") end -- return a live notice from time to time while (nmap.clock_ms() < end_time or TimeLimit == nil) and not StopAll do if ServerNotice ~= last_message then -- don't flood the output by repeating the same info - stdnse.print_debug(SCRIPT_NAME .. " [MAIN THREAD]: " .. ServerNotice) + stdnse.debug1("[MAIN THREAD]: " .. ServerNotice) last_message = ServerNotice end if DOSed and TimeLimit ~= nil then @@ -299,14 +299,14 @@ action = function(host, port) StopAll = true if DOSed then if Reason == "slowloris" then - stdnse.print_debug(2, SCRIPT_NAME .. " Slowloris Attack stopped, building output") + stdnse.debug2("Slowloris Attack stopped, building output") output = "Vulnerable:\n" .. "the DoS attack took ".. dos_time .. "\n" .. "with ".. Sockets .. " concurrent connections\n" .. "and " .. Queries .." sent queries" else - stdnse.print_debug(2, SCRIPT_NAME .. " Slowloris Attack stopped. Monitor couldn't communicate with the server.") + stdnse.debug2("Slowloris Attack stopped. Monitor couldn't communicate with the server.") output = "Probably vulnerable:\n" .. "the DoS attack took " .. dos_time .. "\n" .. "with " .. Sockets .. " concurrent connections\n" .. diff --git a/scripts/sip-call-spoof.nse b/scripts/sip-call-spoof.nse index bd5e66a24..f9a644134 100644 --- a/scripts/sip-call-spoof.nse +++ b/scripts/sip-call-spoof.nse @@ -166,6 +166,6 @@ action = function(host, port) return stdnse.format_output(true, "Ringing, got no answer. (script timeout)") end else - stdnse.print_debug(SCRIPT_NAME .. "Target phone didn't ring.") + stdnse.debug1("Target phone didn't ring.") end end