diff --git a/nselib/comm.lua b/nselib/comm.lua index 296be669c..64337fdb6 100644 --- a/nselib/comm.lua +++ b/nselib/comm.lua @@ -215,7 +215,7 @@ local function opencon(host, port, protocol, data, opts) status, response = sd:receive() else if not (opts and opts.recv_before) then - stdnse.print_debug("Using comm.tryssl without either first data payload or opts.recv_before." .. + stdnse.debug1("Using comm.tryssl without either first data payload or opts.recv_before." .. "\nImpossible to test the connection for the correct protocol!") end response = early_resp diff --git a/nselib/dnsbl.lua b/nselib/dnsbl.lua index 6a5a29dfc..589af268e 100644 --- a/nselib/dnsbl.lua +++ b/nselib/dnsbl.lua @@ -385,7 +385,7 @@ SERVICES = { if ( octet1 ~= 127 ) then -- This shouldn't happen :P - stdnse.print_debug( + stdnse.debug1( "The request made to dnsbl.httpbl.org was considered invalid (%i)", octet1) elseif ( "short" == self.mode ) then diff --git a/nselib/http.lua b/nselib/http.lua index 150241b41..bcc7bfb72 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -2107,7 +2107,7 @@ end ---Take the data returned from a HTTP request and return the status string. --- Useful for stdnse.print_debug messages and even advanced output. +-- Useful for stdnse.debug messages and even advanced output. -- -- @param data The response table from any HTTP request -- @return The best status string we could find: either the actual status string, the status code, or "". diff --git a/nselib/json.lua b/nselib/json.lua index 5eeace4f0..a5d32440a 100644 --- a/nselib/json.lua +++ b/nselib/json.lua @@ -191,7 +191,7 @@ local function d3(str,...) if nmap.debugging() > 2 then dbg(str, ...) end end ---local dbg =stdnse.print_debug +--local dbg =stdnse.debug local function dbg_err(str,...) stdnse.debug1("json-ERR:"..str, ...) end diff --git a/nselib/mongodb.lua b/nselib/mongodb.lua index 782cea89f..1ab683c64 100644 --- a/nselib/mongodb.lua +++ b/nselib/mongodb.lua @@ -30,9 +30,9 @@ local arg_DB = stdnse.get_script_args("mongodb.db") local function dbg(str,...) stdnse.debug3("MngoDb:"..str, ...) end ---local dbg =stdnse.print_debug +--local dbg =stdnse.debug1 -local err =stdnse.print_debug +local err =stdnse.debug1 ---------------------------------------------------------------------- -- First of all comes a Bson parsing library. This can easily be moved out into a separate library should other diff --git a/nselib/msrpc.lua b/nselib/msrpc.lua index b9033af8a..5c6d21253 100644 --- a/nselib/msrpc.lua +++ b/nselib/msrpc.lua @@ -4855,7 +4855,7 @@ end --####################################################################-- --# 3) RRAS RASRPC OPERATIONS --####################################################################-- -local RRAS_DEBUG_LVL = 2 --debug level for rras operations when calling stdnse.print_debug +local RRAS_DEBUG_LVL = 2 --debug level for rras operations when calling stdnse.debug --####################################################################-- --- RRAS operation numbers. @@ -4904,7 +4904,7 @@ function RRAS_SubmitRequest(smbstate, pReqBuffer, dwcbBufSize) req_blob = req_blob .. msrpctypes.marshall_int32(dwcbBufSize) --call the function local status, result - stdnse.print_debug( + stdnse.debug( RRAS_DEBUG_LVL, "RRAS_SubmitRequest: Calling...") status, result = call_function( @@ -4913,13 +4913,13 @@ function RRAS_SubmitRequest(smbstate, pReqBuffer, dwcbBufSize) req_blob) --sanity check if(status == false) then - stdnse.print_debug( + stdnse.debug( RRAS_DEBUG_LVL, "RRAS_SubmitRequest: Call function failed: %s", result) return false, result end - stdnse.print_debug( + stdnse.debug( RRAS_DEBUG_LVL, "RRAS_SubmitRequest: Returned successfully") --dissect the reply @@ -4953,7 +4953,7 @@ DNSSERVER_ConfInfo = --####################################################################-- --# 3) DNS SERVER MANAGEMENT SERVICE OPERATIONS --####################################################################-- -local DNSSERVER_DEBUG_LVL = 2 --debug level for dnsserver operations when calling stdnse.print_debug +local DNSSERVER_DEBUG_LVL = 2 --debug level for dnsserver operations when calling stdnse.debug --####################################################################-- --- DNSSERVER operation numbers. @@ -5042,7 +5042,7 @@ function DNSSERVER_Query(smbstate, server_name, zone, operation) get_pad(operation_ascii, 4)) local call_result - stdnse.print_debug( + stdnse.debug( DNSSERVER_DEBUG_LVL, "DNSSERVER_Query: Calling...") status, call_result = call_function( @@ -5051,13 +5051,13 @@ function DNSSERVER_Query(smbstate, server_name, zone, operation) req_blob) --sanity check if(status == false) then - stdnse.print_debug( + stdnse.debug( DNSSERVER_DEBUG_LVL, "DNSSERVER_Query: Call function failed: %s", call_result) return false, call_result end - stdnse.print_debug( + stdnse.debug( DNSSERVER_DEBUG_LVL, "DNSSERVER_Query: Returned successfully") --dissect the reply diff --git a/nselib/openssl.luadoc b/nselib/openssl.luadoc index 80a2cc43d..58cf3b9ed 100644 --- a/nselib/openssl.luadoc +++ b/nselib/openssl.luadoc @@ -10,7 +10,7 @@ -- -- if not pcall(require, "openssl") then -- action = function(host, port) --- stdnse.print_debug(2, "Skipping \"%s\" because OpenSSL is missing.", id) +-- stdnse.debug2("Skipping \"%s\" because OpenSSL is missing.", id) -- end -- end -- action = action or function(host, port) diff --git a/nselib/proxy.lua b/nselib/proxy.lua index 00c704695..0ca7dac73 100644 --- a/nselib/proxy.lua +++ b/nselib/proxy.lua @@ -233,7 +233,7 @@ function socksHandshake(socket, version, hostname) local request_status = string.byte(response, 2) local err = string.format("Unknown response (0x%02x)", request_status) if(request_status == 0x5a) then - stdnse.print_debug('Socks4: Received "Request Granted" from proxy server') + stdnse.debug1('Socks4: Received "Request Granted" from proxy server') return true, socket end if(request_status == 0x5b) then @@ -243,7 +243,7 @@ function socksHandshake(socket, version, hostname) elseif (request_status == 0x5d) then err = "request failed because client program and identd report different user-ids" end - stdnse.print_debug('Socks4: Received "%s" from proxy server', err) + stdnse.debug1('Socks4: Received "%s" from proxy server', err) return false, err end if version == 5 then @@ -280,7 +280,7 @@ function socksHandshake(socket, version, hostname) local request_status = string.byte(z, 2) err = string.format("Unknown response (0x%02x)", request_status) if (request_status == 0x00) then - stdnse.print_debug('Socks5: Received "Request Granted" from proxy server') + stdnse.debug1('Socks5: Received "Request Granted" from proxy server') return true, socket elseif(request_status == 0x01) then err = "General Failure" @@ -300,7 +300,7 @@ function socksHandshake(socket, version, hostname) err = "Address type not supported" end end - stdnse.print_debug('Socks5: Received "%s" from proxy server', err) + stdnse.debug1('Socks5: Received "%s" from proxy server', err) return false, err end return false, "Invalid SOCKS version" diff --git a/nselib/sslcert.lua b/nselib/sslcert.lua index 48d87e892..2e6daaa55 100644 --- a/nselib/sslcert.lua +++ b/nselib/sslcert.lua @@ -138,8 +138,7 @@ StartTLS = { if status then status,err = s:reconnect_ssl() if not status then - stdnse.print_debug( - 1, "Could not establish SSL session after STARTTLS command.") + stdnse.debug1("Could not establish SSL session after STARTTLS command.") s:close() return false, "Failed to connect to IMAP server" else @@ -217,8 +216,7 @@ StartTLS = { if status then status,err = s:reconnect_ssl() if not status then - stdnse.print_debug( - 1,"Could not establish SSL session after STARTTLS command.") + stdnse.debug1("Could not establish SSL session after STARTTLS command.") s:close() return false, "Failed to connect to LDAP server" else @@ -268,8 +266,7 @@ StartTLS = { if status then status,err = s:reconnect_ssl() if not status then - stdnse.print_debug( - 1, "Could not establish SSL session after STARTTLS command.") + stdnse.debug1("Could not establish SSL session after STARTTLS command.") s:close() return false, "Failed to connect to POP3 server" else diff --git a/nselib/unittest.lua b/nselib/unittest.lua index 033470313..b7e799708 100644 --- a/nselib/unittest.lua +++ b/nselib/unittest.lua @@ -232,9 +232,9 @@ TestSuite = { failures = failures + 1 end if note then - stdnse.print_debug(lvl, "| \\_result: %s (%s)", result, note) + stdnse.debug(lvl, "| \\_result: %s (%s)", result, note) else - stdnse.print_debug(lvl, "| \\_result: %s", result) + stdnse.debug(lvl, "| \\_result: %s", result) end end stdnse.debug1("|_%d of %d tests passed", passes, #self.tests) diff --git a/nselib/vulns.lua b/nselib/vulns.lua index 909c92e7b..c56eb7873 100644 --- a/nselib/vulns.lua +++ b/nselib/vulns.lua @@ -201,7 +201,7 @@ local setmetatable = setmetatable local string_format = string.format local string_upper = string.upper -local print_debug = stdnse.print_debug +local debug = stdnse.debug local compare_ip = ipOps.compare_ip _ENV = stdnse.module("vulns", stdnse.seeall) @@ -693,7 +693,7 @@ local l_update_id = function(fid_table, id_type, id, vuln_table) local target_key = l_get_host_port_key(vuln_table) host_info = host_info..string_format(" %s)", target_key) - print_debug(5, + debug(5, "vulns.lua: Updating VULNS.FILTERS_IDS{} with '%s' ID:%s:%s %s", vuln_table.title, id_type, id, host_info) push_table.HOSTS = push_table.HOSTS or {} @@ -702,7 +702,7 @@ local l_update_id = function(fid_table, id_type, id, vuln_table) push_table.HOSTS[vuln_table.host.ip][target_key] = vuln_table return push_table.HOSTS[vuln_table.host.ip][target_key] else - print_debug(5, + debug(5, "vulns.lua: Updating VULNS.FILTERS_IDS{} with '%s' ID:%s:%s", vuln_table.title, id_type, id) push_table.NETWORKS = push_table.NETWORKS or {} @@ -1024,7 +1024,7 @@ local l_add = function(vulndb, vuln_table) -- variable false. local id_not_found = true - print_debug(5, + debug(5, "vulns.lua: Searching VULNS.FILTERS_IDS[%d] for '%s' ID:%s:%s", fid, vuln_table.title, id_type, id) @@ -1040,7 +1040,7 @@ local l_add = function(vulndb, vuln_table) local tmp_vuln = old_vuln_list[target_key] if tmp_vuln then - print_debug(5, + debug(5, "vulns.lua: VULNS.FILTERS_IDS[%d] '%s' ID:%s:%s%s: FOUND", fid, vuln_table.title, id_type, id, host_info) if old_entries[#old_entries] ~= tmp_vuln then @@ -1061,7 +1061,7 @@ local l_add = function(vulndb, vuln_table) -- in order to make it later reference the saved vulnerability -- entry (vulnerability table in the registry). if id_not_found then - print_debug(5, + debug(5, "vulns.lua: VULNS.FILTERS_IDS[%d] '%s' ID:%s:%s%s: NOT FOUND", fid, vuln_table.title, id_type, id, host_info) NEW_IDS[id_type] = {['id'] = id, ['fid'] = fid} @@ -1078,17 +1078,17 @@ local l_add = function(vulndb, vuln_table) -- Old entry, update the vulnerability information if ids_found > 0 then if #old_entries > 1 then - print_debug(3, "vulns.lua: Warning at vuln '%s': ".. + debug(3, "vulns.lua: Warning at vuln '%s': ".. "please check the vulnerability IDs field.", vuln_table.title) for _, old_vuln in ipairs(old_entries) do - print_debug(3, "vulns: Warning at vuln '%s': ".. + debug(3, "vulns: Warning at vuln '%s': ".. "please check the vulnerability IDs field.", old_vuln.title) end end - print_debug(3, + debug(3, "vulns.lua: Updating vulnerability entry: '%s'%s", vuln_table.title, host_info) - print_debug(3, + debug(3, "vulns.lua: Vulnerability '%s' referenced by %d IDs from %d (%s)", vuln_table.title, ids_found, ids_count, ids_found < ids_count and "Bad" or "Good") @@ -1099,7 +1099,7 @@ local l_add = function(vulndb, vuln_table) vuln_ref = l_update_vuln(vulndb, old_entries[1], vuln_table) else -- New vulnerability entry - print_debug(3, + debug(3, "vulns.lua: Adding new vulnerability entry: '%s'%s", vuln_table.title, host_info) @@ -1116,7 +1116,7 @@ local l_add = function(vulndb, vuln_table) if new_entry['fid'] == fid then -- Add the ID couple (id_type, id) to the -- VULNS.FILTERS_IDS[fid] table that lacks them - print_debug(5, + debug(5, "vulns.lua: Updating VULNS.FILTERS_IDS[%d]", new_entry.fid) l_update_id(vulndb.FILTERS_IDS[new_entry['fid']], id_type, new_entry.id, vuln_ref) @@ -1217,13 +1217,13 @@ local l_find_by_id = function(fid_table, vuln_id_type, id) local db = l_lookup_id(fid_table, vuln_id_type, id) if db then - print_debug(5, + debug(5, "vulns.lua: Lookup VULNS.FILTERS_IDS{} for ID:%s:%s: FOUND", vuln_id_type, id) if db.ENTRIES and db.ENTRIES.HOSTS and next(db.ENTRIES.HOSTS) then for _, vuln_list in pairs(db.ENTRIES.HOSTS) do for _, vuln_table in pairs(vuln_list) do - print_debug(5, + debug(5, "vulns.lua: Vulnerability '%s' (host:%s): FOUND", vuln_table.title, vuln_table.host.ip) out[#out + 1] = vuln_table @@ -1233,7 +1233,7 @@ local l_find_by_id = function(fid_table, vuln_id_type, id) if db.ENTRIES.NETWORKS and next(db.ENTRIES.NETWORKS) then for _, vuln_table in ipairs(db.ENTRIES.NETWOKRS) do - print_debug(5, + debug(5, "vulns.lua: Vulnerability '%s': FOUND", vuln_table.title) out[#out + 1] = vuln_table end @@ -1262,7 +1262,7 @@ local l_find_vulns = function(fid_table, entries, filter) for host_ip, vulns_list in pairs(entries.HOSTS) do for _, vuln_table in ipairs(vulns_list) do if check_vuln(vuln_table, fid_table, filter) then - print_debug(5, + debug(5, "vulns.lua: Vulnerability '%s' (host: %s): FOUND", vuln_table.title, vuln_table.host.ip) out[#out + 1] = vuln_table @@ -1272,7 +1272,7 @@ local l_find_vulns = function(fid_table, entries, filter) for _, vuln_table in ipairs(entries.NETWORKS) do if check_vuln(vuln_table, fid_table, filter) then - print_debug(5, + debug(5, "vulns.lua: Vulnerability '%s': FOUND", vuln_table.title) out[#out + 1] = vuln_table end @@ -1329,7 +1329,7 @@ local l_make_output = function(fid_table, entries, filter) for _, vuln_table in ipairs(vulns_list) do if check_vuln(vuln_table, fid_table, filter) then - print_debug(5, + debug(5, "vulns.lua: Vulnerability '%s' (host: %s): FOUND", vuln_table.title, vuln_table.host.ip) @@ -1348,7 +1348,7 @@ local l_make_output = function(fid_table, entries, filter) for _, vuln_table in ipairs(entries.NETWORKS) do if check_vuln(vuln_table, fid_table, filter) then - print_debug(5, + debug(5, "vulns.lua: Vulnerability '%s': FOUND", vuln_table.title) if bit.band(vuln_table.state, STATE.NOT_VULN) == 0 then networks.vulns[#networks.vulns + 1] = vuln_table @@ -1443,7 +1443,7 @@ end --- Find vulnerabilities by ID wrapper local registry_find_by_id = function(fid, vuln_id_type, id) if registry_lookup_id(fid, vuln_id_type, id) then - print_debug(5, + debug(5, "vulns.lua: Lookup VULNS.FILTERS_IDS[%d] for vulnerabilities", fid) @@ -1458,7 +1458,7 @@ local registry_find_vulns = function(fid, selection_filter) if fid_table and next(fid_table) then -- Normalize the 'selection_filter' fields local filter = l_normalize_selection_filter(selection_filter) - print_debug(5, + debug(5, "vulns.lua: Lookup VULNS.FILTERS_IDS[%d] for vulnerabilities", fid) @@ -1472,7 +1472,7 @@ local registry_make_output = function(fid, selection_filter) if fid_table and next(fid_table) then local filter = l_normalize_selection_filter(selection_filter) - print_debug(5, + debug(5, "vulns.lua: Lookup VULNS.FILTERS_IDS[%d] for vulnerabilities", fid) @@ -1495,7 +1495,7 @@ local registry_add_vulns = function(script_name, ...) if validate_vuln(vuln_table) then normalize_vuln_info(vuln_table) vuln_table.script_name = script_name - print_debug(3, + debug(3, "vulns.lua: *** New Vuln '%s' %sreported by '%s' script ***", vuln_table.title, vuln_table.host and @@ -1799,7 +1799,7 @@ local format_vuln_base = function(vuln_table, showall) end if not showall and bit.band(vuln_table.state, STATE.NOT_VULN) ~= 0 then - print_debug(2, "vulns.lua: vulnerability '%s'%s: %s.", + debug(2, "vulns.lua: vulnerability '%s'%s: %s.", vuln_table.title, vuln_table.host and string_format(" (host:%s%s)", vuln_table.host.ip, @@ -2092,7 +2092,7 @@ save_reports = function(filter_callback) local fid = register_filter(VULNS.FILTERS_FUNCS, filter_callback) VULNS.FILTERS_IDS[fid] = {} - print_debug(3, + debug(3, "vulns.lua: New Filter table: VULNS.FILTERS_IDS[%d]", fid) return fid end