diff --git a/nselib/ajp.lua b/nselib/ajp.lua index f4db20d61..26a3ade9f 100644 --- a/nselib/ajp.lua +++ b/nselib/ajp.lua @@ -415,7 +415,7 @@ Helper = { local auth = self:getOption(options, "auth") if ( not(auth) or not(auth.username) and not(auth.password) ) then - stdnse.print_debug(2, "No authentication information") + stdnse.debug2("No authentication information") return status, result end @@ -429,9 +429,9 @@ Helper = { end if ( not(scheme) ) then - stdnse.print_debug(2, "Could not find a supported authentication scheme") + stdnse.debug2("Could not find a supported authentication scheme") elseif ( "basic" ~= scheme ) then - stdnse.print_debug(2, "Unsupported authentication scheme: %s", scheme) + stdnse.debug2("Unsupported authentication scheme: %s", scheme) else headers = headers or {} headers["Authorization"] = ("Basic %s"):format(base64.enc(auth.username .. ":" .. auth.password)) diff --git a/nselib/amqp.lua b/nselib/amqp.lua index 461792afa..0d8c16265 100644 --- a/nselib/amqp.lua +++ b/nselib/amqp.lua @@ -249,7 +249,7 @@ AMQP = { -- parse frame header local frametype, chnumber, framesize, method _, frametype, chnumber, framesize, method = bin.unpack(">CSII", tmp) - stdnse.print_debug("frametype: %d, chnumber: %d, framesize: %d, method: %d", frametype, chnumber, framesize, method) + stdnse.debug1("frametype: %d, chnumber: %d, framesize: %d, method: %d", frametype, chnumber, framesize, method) if (frametype ~= 1) then return false, ("ERROR: AQMP:handshake expected header (1) frame, but was %d"):format(frametype) diff --git a/nselib/asn1.lua b/nselib/asn1.lua index 69808266e..531bc7a36 100644 --- a/nselib/asn1.lua +++ b/nselib/asn1.lua @@ -139,7 +139,7 @@ ASN1Decoder = { if self.decoder[etype] then return self.decoder[etype]( self, encStr, elen, newpos ) else - stdnse.print_debug("no decoder for etype: " .. etype) + stdnse.debug1("no decoder for etype: " .. etype) return newpos, nil end end, diff --git a/nselib/bittorrent.lua b/nselib/bittorrent.lua index 36d82c05b..bcf0526aa 100644 --- a/nselib/bittorrent.lua +++ b/nselib/bittorrent.lua @@ -678,15 +678,15 @@ Torrent = if tracker:match("^http://") then -- http tracker status, err = self:http_tracker_peers(tracker) if not status then - stdnse.print_debug("Could not get peers from tracker %s, reason: %s",tracker, err) + stdnse.debug1("Could not get peers from tracker %s, reason: %s",tracker, err) end elseif tracker:match("^udp://") then -- udp tracker status, err = self:udp_tracker_peers(tracker) if not status then - stdnse.print_debug("Could not get peers from tracker %s, reason: %s",tracker, err) + stdnse.debug1("Could not get peers from tracker %s, reason: %s",tracker, err) end else -- unknown tracker - stdnse.print_debug("Unknown tracker protocol for: "..tracker) + stdnse.debug1("Unknown tracker protocol for: "..tracker) end --if not status then return false, err end end @@ -699,10 +699,10 @@ Torrent = -- The default timeout for this discovery is 30 seconds but it can be -- set through the timeout argument. dht_peers = function(self, timeout) - stdnse.print_debug("bittorrent: Starting DHT peers discovery") + stdnse.debug1("bittorrent: Starting DHT peers discovery") if next(self.peers) == nil then - stdnse.print_debug("bittorrent: No peers detected") + stdnse.debug1("bittorrent: No peers detected") return end diff --git a/nselib/brute.lua b/nselib/brute.lua index 16c6e6329..a84e499ff 100644 --- a/nselib/brute.lua +++ b/nselib/brute.lua @@ -266,7 +266,7 @@ Options = { end if ( not(supported) ) then - stdnse.print_debug("ERROR: brute.options.setMode: mode %s not supported", mode) + stdnse.debug1("ERROR: brute.options.setMode: mode %s not supported", mode) return false, "Unsupported mode" else self.mode = mode @@ -535,7 +535,7 @@ Engine = end local msg = ( retries ~= self.options.max_retries ) and "Re-trying" or "Trying" - stdnse.print_debug(2, "%s %s against %s:%d", msg, c, self.host.ip, self.port.number ) + stdnse.debug2("%s %s against %s:%d", msg, c, self.host.ip, self.port.number ) status, response = driver:login( username, password ) driver:disconnect() @@ -584,7 +584,7 @@ Engine = table.insert(self.credstore, response:toString() ) end - stdnse.print_debug("Discovered account: %s", response:toString()) + stdnse.debug1("Discovered account: %s", response:toString()) -- if we're running in passonly mode, and want to continue guessing -- we will have a problem as the username is always the same. @@ -618,7 +618,7 @@ Engine = interval_start = os.time() local tps = self.counter / ( os.time() - self.starttime ) table.insert(self.tps, tps ) - stdnse.print_debug(2, "threads=%d,tps=%d", self:activeThreads(), tps ) + stdnse.debug2("threads=%d,tps=%d", self:activeThreads(), tps ) end -- if delay was specified, do sleep diff --git a/nselib/cassandra.lua b/nselib/cassandra.lua index a08d35005..3ec12c9ab 100644 --- a/nselib/cassandra.lua +++ b/nselib/cassandra.lua @@ -120,7 +120,7 @@ function describe_cluster_name (socket,cnt) local status,resp = sendcmd(socket,cname,cnt) if (not(status)) then - stdnse.print_debug(1, "sendcmd"..resp) + stdnse.debug1("sendcmd"..resp) return false, "error in communication" end @@ -144,7 +144,7 @@ function describe_version (socket,cnt) local status,resp = sendcmd(socket,cname,cnt) if (not(status)) then - stdnse.print_debug(1, "sendcmd"..resp) + stdnse.debug1("sendcmd"..resp) return false, "error in communication" end @@ -171,20 +171,20 @@ function login (socket,username,password) local status, err = socket:send(bin.pack(">I",string.len(loginstr))) if ( not(status) ) then - stdnse.print_debug(3, "cannot send len "..combo) + stdnse.debug3("cannot send len "..combo) return false, "Failed to connect to server" end status, err = socket:send(loginstr) if ( not(status) ) then - stdnse.print_debug(3, "Sent packet for "..combo) + stdnse.debug3("Sent packet for "..combo) return false, err end local response status, response = socket:receive_bytes(22) if ( not(status) ) then - stdnse.print_debug(3, "Receive packet for "..combo) + stdnse.debug3("Receive packet for "..combo) return false, err end local _, size = bin.unpack(">I", response, 1) @@ -195,10 +195,10 @@ function login (socket,username,password) end local magic = string.sub(response,18,22) - stdnse.print_debug(3, "packet for "..combo) - stdnse.print_debug(3, "packet hex: %s", stdnse.tohex(response) ) - stdnse.print_debug(3, "size packet hex: %s", stdnse.tohex(size) ) - stdnse.print_debug(3, "magic packet hex: %s", stdnse.tohex(magic) ) + stdnse.debug3("packet for "..combo) + stdnse.debug3("packet hex: %s", stdnse.tohex(response) ) + stdnse.debug3("size packet hex: %s", stdnse.tohex(size) ) + stdnse.debug3("magic packet hex: %s", stdnse.tohex(magic) ) if (magic == LOGINSUCC) then return true diff --git a/nselib/data/http-fingerprints.lua b/nselib/data/http-fingerprints.lua index 2e9bb6374..d7c5a9b0f 100644 --- a/nselib/data/http-fingerprints.lua +++ b/nselib/data/http-fingerprints.lua @@ -11874,7 +11874,7 @@ local f = nmap.fetchfile(nikto_db_path) or io.open(nikto_db_path, "r") if f then - stdnse.print_debug(1, "Found nikto db.") + stdnse.debug1("Found nikto db.") local nikto_db = {} for l in io.lines(nikto_db_path) do diff --git a/nselib/data/packetdecoders.lua b/nselib/data/packetdecoders.lua index 7fabfa5ab..c29f205a4 100644 --- a/nselib/data/packetdecoders.lua +++ b/nselib/data/packetdecoders.lua @@ -97,7 +97,7 @@ Decoders = { end local mac = sender.mac:gsub("(..)(..)(..)(..)(..)(..)","%1:%2:%3:%4:%5:%6") - stdnse.print_debug(1, "Decoded ARP: %s, %s, %s", ipOps.fromdword(sender.ip), mac, ipOps.fromdword(target.ip)) + stdnse.debug1("Decoded ARP: %s, %s, %s", ipOps.fromdword(sender.ip), mac, ipOps.fromdword(target.ip)) if ( not(self.dups[("%u:%s"):format(sender.ip,sender.mac)]) ) then if ( target.ALLOW_NEW_TARGETS ) then target.add(sender.ip) end self.dups[("%u:%s"):format(sender.ip,sender.mac)] = true @@ -328,7 +328,7 @@ Decoders = { -- is applied to the whole packet+password else -- Error - stdnse.print_debug("Unknown OSPF auth type %d", header.auth_type) + stdnse.debug1("Unknown OSPF auth type %d", header.auth_type) return end @@ -396,7 +396,7 @@ udp = { local gw = self.getOption(result.options, "Router") or "-" local dns = self.getOption(result.options, "Domain Name Server") or "-" local vendor = self.getOption(result.options, "Class Identifier") or "-" - stdnse.print_debug(1, "Decoded DHCP: %s, %s, %s, %s, %s, %s", p.ip_src, result.yiaddr_str, mask, gw, dns, vendor) + stdnse.debug1("Decoded DHCP: %s, %s, %s, %s, %s, %s", p.ip_src, result.yiaddr_str, mask, gw, dns, vendor) tab.addrow(self.results, p.ip_src, result.yiaddr_str, mask, gw, dns, vendor ) end end @@ -440,7 +440,7 @@ udp = { if ( #res == 0 ) then tab.addrow(res, 'ip', 'query') end - stdnse.print_debug(1, 'Decoded Netbios(%s): %s, %s', (isreg and "Registration" or "Query"), ip, name) + stdnse.debug1('Decoded Netbios(%s): %s, %s', (isreg and "Registration" or "Query"), ip, name) if ( not(dup[ip]) or not(dup[ip][name]) ) then if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end @@ -488,7 +488,7 @@ udp = { ip = ipOps.fromdword(ip) src = netbios.name_decode(src) dst = netbios.name_decode(dst) - stdnse.print_debug(1, "Decoded BROWSER: %s, %s, %s", ip, src, dst) + stdnse.debug1("Decoded BROWSER: %s, %s, %s", ip, src, dst) local dup_rec = ("%s:%s:%s"):format(ip, src, dst) if ( not(self.dups[dup_rec]) ) then @@ -581,7 +581,7 @@ udp = { tab.addrow(self.results, 'ip', 'uri', 'loc', 'model') end - stdnse.print_debug(1, "Decoded CUPS: %s, %s, %s, %s", p.ip_src, uri, loc, model) + stdnse.debug1("Decoded CUPS: %s, %s, %s, %s", p.ip_src, uri, loc, model) if ( not(self.dups[p.ip_src]) or not(self.dups[p.ip_src][uri]) ) then tab.addrow(self.results, p.ip_src, uri, loc, model) self.dups[p.ip_src] = self.dups[p.ip_src] or {} @@ -826,7 +826,7 @@ udp = { self.macbooks[macbook]['model'] = self.macbooks[macbook]['model'] or model self.macbooks[macbook]['ip'] = self.macbooks[macbook]['ip'] or ip self.macbooks[macbook]['ipv6'] = self.macbooks[macbook]['ipv6'] or ipv6 - stdnse.print_debug(1, "Decoded MDNS(MacBook): %s, %s, %s, %s", + stdnse.debug1("Decoded MDNS(MacBook): %s, %s, %s, %s", (self.macbooks[macbook]['ip'] or ""), (self.macbooks[macbook]['ipv6'] or ""), self.macbooks[macbook]['model'], self.macbooks[macbook]['macbook']) else @@ -839,7 +839,7 @@ udp = { else self.generic[name]['ip'] = p.ip_src end - stdnse.print_debug(1, "Decoded MDNS(Generic): %s, %s", name, p.ip_src) + stdnse.debug1("Decoded MDNS(Generic): %s, %s", name, p.ip_src) end end end, @@ -899,7 +899,7 @@ udp = { local name = (( resp.questions and #resp.questions > 0 ) and resp.questions[1].dname ) if ( not(name) ) then return end - stdnse.print_debug(1, "Decoded LLMNR: %s, %s", p.ip_src, name) + stdnse.debug1("Decoded LLMNR: %s, %s", p.ip_src, name) if ( not(self.dups[("%s:%s"):format(p.ip_src, name)]) ) then self.dups[("%s:%s"):format(p.ip_src, name)] = true diff --git a/nselib/datafiles.lua b/nselib/datafiles.lua index d4133ee8a..159119280 100644 --- a/nselib/datafiles.lua +++ b/nselib/datafiles.lua @@ -225,7 +225,7 @@ function parse_lines(lines, data_struct) _, ret[index] = parse_lines( lines, value ) else -- TEMP - stdnse.print_debug( "Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value)) + stdnse.debug1("Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value)) end elseif type(index) == "string" or type(index) == "function" then if type( value ) == "string" or type( value ) == "function" then @@ -235,7 +235,7 @@ function parse_lines(lines, data_struct) end else -- TEMP - stdnse.print_debug( "Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value)) + stdnse.debug1("Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value)) end end diff --git a/nselib/dhcp.lua b/nselib/dhcp.lua index 37c37a4a7..8044df7ad 100644 --- a/nselib/dhcp.lua +++ b/nselib/dhcp.lua @@ -56,7 +56,7 @@ request_types_str[8] = "DHCPINFORM" local function read_ip(data, pos, length) if(length ~= 4) then if((length % 4) ~= 0) then - stdnse.print_debug(1, "dhcp-discover: Invalid length for an ip address (%d)", length) + stdnse.debug1("dhcp-discover: Invalid length for an ip address (%d)", length) pos = pos + length return pos, nil @@ -98,7 +98,7 @@ end --@return The value of the field, or nil if the field length was wrong. local function read_1_byte(data, pos, length) if(length ~= 1) then - stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be %d)", length, 1) + stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be %d)", length, 1) pos = pos + length return pos, nil end @@ -118,7 +118,7 @@ local function read_message_type(data, pos, length) pos, value = read_1_byte(data, pos, length) if(value == nil) then - stdnse.print_debug(1, "dhcp-discover: Couldn't read the 1-byte message type") + stdnse.debug1("dhcp-discover: Couldn't read the 1-byte message type") return pos, nil end @@ -138,7 +138,7 @@ local function read_boolean(data, pos, length) pos, result = read_1_byte(data, pos, length) if(result == nil) then - stdnse.print_debug(1, "dhcp-discover: Couldn't read the 1-byte boolean") + stdnse.debug1("dhcp-discover: Couldn't read the 1-byte boolean") return pos, nil elseif(result == 0) then return pos, "false" @@ -156,7 +156,7 @@ end --@return The value of the field, or nil if the field length was wrong. local function read_2_bytes(data, pos, length) if(length ~= 2) then - stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be %d)", length, 2) + stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be %d)", length, 2) pos = pos + length return pos, nil end @@ -174,7 +174,7 @@ end --@return The value of the field, or nil if the field length was wrong. local function read_2_bytes_list(data, pos, length) if((length % 2) ~= 0) then - stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 2) + stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 2) pos = pos + length return pos, nil @@ -200,7 +200,7 @@ end --@return The value of the field, or nil if the field length was wrong. local function read_4_bytes(data, pos, length) if(length ~= 4) then - stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be %d)", length, 4) + stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be %d)", length, 4) pos = pos + length return pos, nil end @@ -218,7 +218,7 @@ end local function read_time(data, pos, length) local result if(length ~= 4) then - stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be %d)", length, 4) + stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be %d)", length, 4) pos = pos + length return pos, nil end @@ -254,7 +254,7 @@ end --@return The value of the field, or nil if the field length was wrong. local function read_static_route(data, pos, length) if((length % 8) ~= 0) then - stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 8) + stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 8) pos = pos + length return pos, nil @@ -281,7 +281,7 @@ end --@return The value of the field, or nil if the field length was wrong. local function read_policy_filter(data, pos, length) if((length % 8) ~= 0) then - stdnse.print_debug(1, "dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 8) + stdnse.debug1("dhcp-discover: Invalid length for data (%d; should be multiple of %d)", length, 8) pos = pos + length return pos, nil @@ -536,22 +536,22 @@ function dhcp_parse(data, transaction_id) -- Verify we got a valid code (if we didn't, we're probably in big trouble) local value if(action == nil) then - stdnse.print_debug(1, "dhcp-discover: Unknown option: %d", option) + stdnse.debug1("dhcp-discover: Unknown option: %d", option) pos = pos + length else -- Call the function to parse the option, and insert the result into our results table - stdnse.print_debug(2, "dhcp-discover: Attempting to parse %s", action['name']) + stdnse.debug2("dhcp-discover: Attempting to parse %s", action['name']) pos, value = action['func'](data, pos, length) if(nmap.verbosity() == 0 and action.default == false) then - stdnse.print_debug(1, "dhcp-discover: Server returned unrequested option (%s => %s)", action['name'], value) + stdnse.debug1("dhcp-discover: Server returned unrequested option (%s => %s)", action['name'], value) else if(value) then table.insert(result['options'], {name=action['name'], value=value}) else - stdnse.print_debug(1, "dhcp-discover: Couldn't determine value for %s", action['name']); + stdnse.debug1("dhcp-discover: Couldn't determine value for %s", action['name']); end end end @@ -566,7 +566,7 @@ function dhcp_parse(data, transaction_id) elseif(value == 3) then data = data .. result['file'] .. result['sname'] else - stdnse.print_debug(1, "dhcp-discover: Warning: 'Option Overload' gave an unsupported value: %d", value) + stdnse.debug1("dhcp-discover: Warning: 'Option Overload' gave an unsupported value: %d", value) end end end @@ -624,7 +624,7 @@ function make_request(target, request_type, ip_address, mac_address, options, re -- Generate the packet local status, packet = dhcp_build(request_type, bin.pack(">I", ipOps.todword(ip_address)), mac_address, options, request_options, overrides, lease_time, transaction_id) if(not(status)) then - stdnse.print_debug(1, "dhcp: Couldn't build packet: " .. packet) + stdnse.debug1("dhcp: Couldn't build packet: " .. packet) return false, "Couldn't build packet: " .. packet end @@ -635,7 +635,7 @@ function make_request(target, request_type, ip_address, mac_address, options, re -- Send the packet and get the response local status, response = dhcp_send(socket, target, packet) if(not(status)) then - stdnse.print_debug(1, "dhcp: Couldn't send packet: " .. response) + stdnse.debug1("dhcp: Couldn't send packet: " .. response) return false, "Couldn't send packet: " .. response end @@ -643,14 +643,14 @@ function make_request(target, request_type, ip_address, mac_address, options, re socket:close() if ( not(status) ) then - stdnse.print_debug(1, "dhcp: Couldn't receive packet: " .. response) + stdnse.debug1("dhcp: Couldn't receive packet: " .. response) return false, "Couldn't receive packet: " .. response end -- Parse the response local status, parsed = dhcp_parse(response, transaction_id) if(not(status)) then - stdnse.print_debug(1, "dhcp: Couldn't parse response: " .. parsed) + stdnse.debug1("dhcp: Couldn't parse response: " .. parsed) return false, "Couldn't parse response: " .. parsed end diff --git a/nselib/dhcp6.lua b/nselib/dhcp6.lua index 16930d868..2d8f8365b 100644 --- a/nselib/dhcp6.lua +++ b/nselib/dhcp6.lua @@ -126,7 +126,7 @@ DHCP6.Option = { local pos pos, opt.duid = bin.unpack(">S", data, pos) if ( 1 ~= opt.duid ) then - stdnse.print_debug("Unexpected DUID type (%d)", opt.duid) + stdnse.debug1("Unexpected DUID type (%d)", opt.duid) return end pos, opt.hwtype, opt.time, opt.mac = bin.unpack(">SIA" .. (#data - pos - 4 - 2 + 1), data, pos) @@ -501,7 +501,7 @@ DHCP6.Response = { table.insert(resp.opts, { type = opt.type, resp = opt_parsed, raw = opt.data }) end else - stdnse.print_debug(2, "No option decoder for type: %d; len: %d", opt.type, #(opt.data or "")) + stdnse.debug2("No option decoder for type: %d; len: %d", opt.type, #(opt.data or "")) table.insert(resp.opts, { type = opt.type, raw = opt.data }) end end @@ -647,7 +647,7 @@ Helper = { table.insert(result_options, ("%s: %s"):format(topic, str)) end else - stdnse.print_debug(2, "No decoder for option type: %d", opt.type) + stdnse.debug2("No decoder for option type: %d", opt.type) end end table.insert(result, result_options) diff --git a/nselib/dns.lua b/nselib/dns.lua index dbe54ecf2..4e3451b46 100644 --- a/nselib/dns.lua +++ b/nselib/dns.lua @@ -284,7 +284,7 @@ local function processResponse( response, dname, dtype, options ) end -- nothing worked - stdnse.print_debug(1, "dns.query() failed to resolve the requested query%s%s", dname and ": " or ".", dname or "") + stdnse.debug1("dns.query() failed to resolve the requested query%s%s", dname and ": " or ".", dname or "") return false, "No Answers" end @@ -397,7 +397,7 @@ function query(dname, options) return processResponse( response[1].data, dname, dtype, options) end else - stdnse.print_debug(1, "dns.query() got zero responses attempting to resolve query%s%s", dname and ": " or ".", dname or "") + stdnse.debug1("dns.query() got zero responses attempting to resolve query%s%s", dname and ": " or ".", dname or "") return false, "No Answers" end end @@ -453,7 +453,7 @@ answerFetcher[types.TXT] = function(dec, retAll) if not retAll and dec.answers[1].data then return true, string.sub(dec.answers[1].data, 2) elseif not retAll then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: TXT") + stdnse.debug1("dns.answerFetcher found no records of the required type: TXT") return false, "No Answers" else for _, v in ipairs(dec.answers) do @@ -465,7 +465,7 @@ answerFetcher[types.TXT] = function(dec, retAll) end end if #answers == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: TXT") + stdnse.debug1("dns.answerFetcher found no records of the required type: TXT") return false, "No Answers" end return true, answers @@ -487,7 +487,7 @@ answerFetcher[types.A] = function(dec, retAll) end end if not retAll or #answers == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: A") + stdnse.debug1("dns.answerFetcher found no records of the required type: A") return false, "No Answers" end return true, answers @@ -504,7 +504,7 @@ answerFetcher[types.CNAME] = function(dec, retAll) if not retAll and dec.answers[1].domain then return true, dec.answers[1].domain elseif not retAll then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: NS, PTR or CNAME") + stdnse.debug1("dns.answerFetcher found no records of the required type: NS, PTR or CNAME") return false, "No Answers" else for _, v in ipairs(dec.answers) do @@ -512,7 +512,7 @@ answerFetcher[types.CNAME] = function(dec, retAll) end end if #answers == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: NS, PTR or CNAME") + stdnse.debug1("dns.answerFetcher found no records of the required type: NS, PTR or CNAME") return false, "No Answers" end return true, answers @@ -532,7 +532,7 @@ answerFetcher[types.MX] = function(dec, retAll) if not retAll then break end end if #mx == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: MX") + stdnse.debug1("dns.answerFetcher found no records of the required type: MX") return false, "No Answers" end for _, add in ipairs(dec.add) do @@ -570,7 +570,7 @@ answerFetcher[types.SRV] = function(dec, retAll) end end if #answers == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: SRV") + stdnse.debug1("dns.answerFetcher found no records of the required type: SRV") return false, "No Answers" end @@ -590,7 +590,7 @@ answerFetcher[types.NSEC] = function(dec, retAll) if not retAll then break end end if #nsec == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: NSEC") + stdnse.debug1("dns.answerFetcher found no records of the required type: NSEC") return false, "No Answers" end for _, nsecrec in ipairs(nsec) do @@ -633,7 +633,7 @@ answerFetcher[types.AAAA] = function(dec, retAll) end end if not retAll or #answers == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: AAAA") + stdnse.debug1("dns.answerFetcher found no records of the required type: AAAA") return false, "No Answers" end return true, answers @@ -653,13 +653,13 @@ function findNiceAnswer(dtype, dec, retAll) if answerFetcher[dtype] then return answerFetcher[dtype](dec, retAll) else - stdnse.print_debug(1, "dns.findNiceAnswer() does not have an answerFetcher for dtype %s", tostring(dtype)) + stdnse.debug1("dns.findNiceAnswer() does not have an answerFetcher for dtype %s", tostring(dtype)) return false, "Unable to handle response" end elseif (dec.flags.RC3 and dec.flags.RC4) then return false, "No Such Name" else - stdnse.print_debug(1, "dns.findNiceAnswer() found zero answers in a response, but got an unexpected flags.replycode") + stdnse.debug1("dns.findNiceAnswer() found zero answers in a response, but got an unexpected flags.replycode") return false, "No Answers" end end @@ -682,7 +682,7 @@ additionalFetcher[types.TXT] = function(dec, retAll) if not retAll and dec.add[1].data then return true, string.sub(dec.add[1].data, 2) elseif not retAll then - stdnse.print_debug(1, "dns.additionalFetcher found no records of the required type: TXT") + stdnse.debug1("dns.additionalFetcher found no records of the required type: TXT") return false, "No Answers" else for _, v in ipairs(dec.add) do @@ -694,7 +694,7 @@ additionalFetcher[types.TXT] = function(dec, retAll) end end if #answers == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: TXT") + stdnse.debug1("dns.answerFetcher found no records of the required type: TXT") return false, "No Answers" end return true, answers @@ -716,7 +716,7 @@ additionalFetcher[types.A] = function(dec, retAll) end end if not retAll or #answers == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: A") + stdnse.debug1("dns.answerFetcher found no records of the required type: A") return false, "No Answers" end return true, answers @@ -741,7 +741,7 @@ additionalFetcher[types.SRV] = function(dec, retAll) end end if #answers == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: SRV") + stdnse.debug1("dns.answerFetcher found no records of the required type: SRV") return false, "No Answers" end @@ -765,7 +765,7 @@ additionalFetcher[types.AAAA] = function(dec, retAll) end end if not retAll or #answers == 0 then - stdnse.print_debug(1, "dns.answerFetcher found no records of the required type: AAAA") + stdnse.debug1("dns.answerFetcher found no records of the required type: AAAA") return false, "No Answers" end return true, answers @@ -784,14 +784,14 @@ function findNiceAdditional(dtype, dec, retAll) if additionalFetcher[dtype] then return additionalFetcher[dtype](dec, retAll) else - stdnse.print_debug(1, "dns.findNiceAdditional() does not have an additionalFetcher for dtype %s", + stdnse.debug1("dns.findNiceAdditional() does not have an additionalFetcher for dtype %s", (type(dtype) == 'string' and dtype) or type(dtype) or "nil") return false, "Unable to handle response" end elseif (dec.flags.RC3 and dec.flags.RC4) then return false, "No Such Name" else - stdnse.print_debug(1, "dns.findNiceAdditional() found zero answers in a response, but got an unexpected flags.replycode") + stdnse.debug1("dns.findNiceAdditional() found zero answers in a response, but got an unexpected flags.replycode") return false, "No Answers" end end diff --git a/nselib/dnsbl.lua b/nselib/dnsbl.lua index 9668f2099..6a5a29dfc 100644 --- a/nselib/dnsbl.lua +++ b/nselib/dnsbl.lua @@ -377,7 +377,7 @@ SERVICES = { if ( not(parts) or err ) then -- TODO Should we return failure in the result? - stdnse.print_debug("The dnsbl.httpbl.org provider failed to return a valid address") + stdnse.debug1("The dnsbl.httpbl.org provider failed to return a valid address") return end @@ -592,7 +592,7 @@ Helper = { local status, answer = dns.query(query, {dtype=ns_type, retAll=true} ) answers[name] = { status = status, answer = answer, svc = svc } else - stdnse.print_debug("Query function returned nothing, skipping '%s'", name) + stdnse.debug1("Query function returned nothing, skipping '%s'", name) end condvar "signal" @@ -626,7 +626,7 @@ Helper = { local svc_result = svc:resp_parser(answer) if ( not(svc_result) ) then local resp = ( #answer > 0 and ("UNKNOWN (%s)"):format(answer[1]) or "UNKNOWN" ) - stdnse.print_debug(2, "%s received %s", name, resp) + stdnse.debug2("%s received %s", name, resp) end if ( svc_result ) then diff --git a/nselib/dnssd.lua b/nselib/dnssd.lua index 375ba8ada..33b2beecc 100644 --- a/nselib/dnssd.lua +++ b/nselib/dnssd.lua @@ -190,7 +190,7 @@ Comm = { local condvar = nmap.condvar(svcresponse) local status, response = dns.query( svc, { port = port, host = host, dtype="PTR", retPkt=true, retAll=true, multiple=multiple, sendCount=1, timeout=2000} ) if not status then - stdnse.print_debug("Failed to query service: %s; Error: %s", svc, response) + stdnse.debug1("Failed to query service: %s; Error: %s", svc, response) return end svcresponse[svc] = svcresponse[svc] or {} diff --git a/nselib/drda.lua b/nselib/drda.lua index 867d5e1eb..257577059 100644 --- a/nselib/drda.lua +++ b/nselib/drda.lua @@ -191,11 +191,11 @@ DRDA = { -- @return err string containing the error message if status is false addParameter = function( self, param ) if ( not(self.DDM) ) then - stdnse.print_debug("drda.DRDA.addParameter: DDM must be set prior to adding parameters") + stdnse.debug1("drda.DRDA.addParameter: DDM must be set prior to adding parameters") return false, "DDM must be set prior to adding parameters" end if ( not(param) ) then - stdnse.print_debug("drda.DRDA.addParameter: Param cannot be nil") + stdnse.debug1("drda.DRDA.addParameter: Param cannot be nil") return false, "Param cannot be nil" end @@ -226,7 +226,7 @@ DRDA = { -- @return data containing the object instance __tostring = function(self) if ( not(self.DDM) ) then - stdnse.print_debug("drda.DRDA.toString: DDM cannot be nil") + stdnse.debug1("drda.DRDA.toString: DDM cannot be nil") return nil end @@ -258,7 +258,7 @@ DRDA = { -- first read atleast enough so that we can populate the DDM local status, data = db2socket:receive_buf( match.numbytes(DDM_SIZE), true ) if ( not(status) ) then - stdnse.print_debug("drda.DRDA.receive: %s", data) + stdnse.debug1("drda.DRDA.receive: %s", data) return false, ("Failed to read at least %d bytes from socket"):format(DDM_SIZE) end @@ -607,7 +607,7 @@ Helper = { if ( packet:getDRDAByCodePoint( CodePoint.RDBNFNRM ) or packet:getDRDAByCodePoint( CodePoint.RDBAFLRM ) ) then - stdnse.print_debug("drda.Helper.login: ERROR: RDB not found") + stdnse.debug1("drda.Helper.login: ERROR: RDB not found") return false, "ERROR: Database not found" end @@ -618,12 +618,12 @@ Helper = { local param = drda:getParameter( CodePoint.SECMEC ) if ( not(param) ) then - stdnse.print_debug("drda.Helper.login: ERROR: Response did not contain any valid security mechanisms") + stdnse.debug1("drda.Helper.login: ERROR: Response did not contain any valid security mechanisms") return false, "ERROR: Response did not contain any valid security mechanisms" end if ( select(2, bin.unpack(">S", param:getData())) ~= SecMec.USER_PASSWORD ) then - stdnse.print_debug("drda.Helper.login: ERROR: Securite Mechanism not supported") + stdnse.debug1("drda.Helper.login: ERROR: Securite Mechanism not supported") return false, "ERROR: Security mechanism not supported" end @@ -706,13 +706,13 @@ Comm = { local status, err = self.socket:send( tostring(packet) ) if ( not(status) ) then - stdnse.print_debug("drda.Helper.login: ERROR: DB2Socket error: %s", err ) + stdnse.debug1("drda.Helper.login: ERROR: DB2Socket error: %s", err ) return false, ("ERROR: DB2Socket error: %s"):format( err ) end status, drda = self:recvDRDA() if( not(status) ) then - stdnse.print_debug("drda.Helper.login: ERROR: DB2Socket error: %s", drda ) + stdnse.debug1("drda.Helper.login: ERROR: DB2Socket error: %s", drda ) return false, ("ERROR: DB2Socket error: %s"):format( drda ) end return true, DRDAPacket:new( drda ) diff --git a/nselib/eap.lua b/nselib/eap.lua index 5ae5e5cb8..2684c3f90 100644 --- a/nselib/eap.lua +++ b/nselib/eap.lua @@ -181,7 +181,7 @@ local make_eap = function (arg) arg.header.payload = bin.pack("C",arg.code) .. bin.pack("C",arg.id) .. bin.pack(">S",bin_payload:len() + EAP_HEADER_SIZE).. bin.pack("C",arg.type) .. bin_payload local v = make_eapol(arg.header) - stdnse.print_debug(2, "make eapol %s", arg.header.src) + stdnse.debug2("make eapol %s", arg.header.src) return v end @@ -190,7 +190,7 @@ parse = function (packet) local tb = {} local _ - stdnse.print_debug(2, "packet size: 0x%x", #packet ) + stdnse.debug2("packet size: 0x%x", #packet ) -- parsing ethernet header _, tb.mac_src, tb.mac_dst, tb.ether_type = bin.unpack(">A6A6S", packet) @@ -199,12 +199,12 @@ parse = function (packet) -- parsing eapol header _, tb.version, tb.type, tb.length = bin.unpack(">CCS", packet, ETHER_HEADER_SIZE + 1) - stdnse.print_debug(1, "mac_src: %s, mac_dest: %s, ether_type: 0x%X", + stdnse.debug1("mac_src: %s, mac_dest: %s, ether_type: 0x%X", tb.mac_src_str, tb.mac_dst_str, tb.ether_type) if tb.ether_type ~= ETHER_TYPE_EAPOL_N then return nil, "not an eapol packet" end - stdnse.print_debug(2, "version: %X, type: %s, length: 0x%X", + stdnse.debug2("version: %X, type: %s, length: 0x%X", tb.version, eapol_str[tb.type] or "unknown", tb.length) @@ -215,11 +215,11 @@ parse = function (packet) _, tb.eap.code, tb.eap.id, tb.eap.length, tb.eap.type = bin.unpack(">CCSC", packet, ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + 1) - stdnse.print_debug(2, "code: %s, id: 0x%X, length: 0x%X, type: %s", + stdnse.debug2("code: %s, id: 0x%X, length: 0x%X, type: %s", code_str[tb.eap.code] or "unknown", tb.eap.id, tb.eap.length, eap_str[tb.eap.type] or "unknown" ) if tb.length ~= tb.eap.length then - stdnse.print_debug(1, "WARNING length mismatch: 0x%X and 0x%X", tb.length, tb.eap.length ) + stdnse.debug1("WARNING length mismatch: 0x%X and 0x%X", tb.length, tb.eap.length ) end end @@ -229,7 +229,7 @@ parse = function (packet) if tb.length > 5 and tb.eap.type == eap_t.IDENTITY then _, tb.eap.body.identity = bin.unpack("z", packet, ETHER_HEADER_SIZE + EAPOL_HEADER_SIZE + EAP_HEADER_SIZE + 1) - stdnse.print_debug(1, "identity: %s", tb.eap.body.identity ) + stdnse.debug1("identity: %s", tb.eap.body.identity ) end if tb.length > 5 and tb.eap.type == eap_t.MD5 then @@ -242,7 +242,7 @@ end send_identity_response = function (iface, id, identity) if not iface then - stdnse.print_debug(1, "no interface given") + stdnse.debug1("no interface given") return end @@ -258,7 +258,7 @@ end send_nak_response = function (iface, id, auth) if not iface then - stdnse.print_debug(1, "no interface given") + stdnse.debug1("no interface given") return end @@ -275,7 +275,7 @@ end send_start = function (iface) if not iface then - stdnse.print_debug(1, "no interface given") + stdnse.debug1("no interface given") return end diff --git a/nselib/eigrp.lua b/nselib/eigrp.lua index f5c6bd284..a8871f4b8 100644 --- a/nselib/eigrp.lua +++ b/nselib/eigrp.lua @@ -93,11 +93,11 @@ EIGRP = { -- @return response table Structured eigrp packet. parse = function(eigrp_raw) if type(eigrp_raw) ~= 'string' then - stdnse.print_debug("eigrp.lua: parse input should be string.") + stdnse.debug1("eigrp.lua: parse input should be string.") return end if #eigrp_raw < 20 then - stdnse.print_debug("eigrp.lua: raw packet size lower then 20.") + stdnse.debug1("eigrp.lua: raw packet size lower then 20.") return end local tlv @@ -118,7 +118,7 @@ EIGRP = { index, tlv.length = bin.unpack(">S", eigrp_raw, index) if tlv.length == 0x00 then -- In case someone wants to DoS us :) - stdnse.print_debug("eigrp.lua: stopped parsing due to null TLV length.") + stdnse.debug1("eigrp.lua: stopped parsing due to null TLV length.") break end if tlv.type == TLV.PARAM then @@ -153,19 +153,19 @@ EIGRP = { index = index + tlv.length - 8 elseif tlv.type == TLV.STUB then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) index = index + tlv.length - 4 elseif tlv.type == TLV.TERM then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) index = index + tlv.length - 4 elseif tlv.type == TLV.TIDLIST then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) index = index + tlv.length - 4 elseif tlv.type == TLV.REQ then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) index = index + tlv.length - 4 elseif tlv.type == TLV.INT then -- Internal Route @@ -215,22 +215,22 @@ EIGRP = { tlv.dst = dst[1] .. '.' .. dst[2] .. '.' .. dst[3] .. '.' .. dst[4] elseif tlv.type == TLV.COM then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) index = index + tlv.length - 4 elseif tlv.type == TLV.INT6 then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) index = index + tlv.length - 4 elseif tlv.type == TLV.EXT6 then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) index = index + tlv.length - 4 elseif tlv.type == TLV.COM6 then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) index = index + tlv.length - 4 else - stdnse.print_debug("eigrp.lua: eigrp.lua: TLV type %d unknown.", tlv.type) + stdnse.debug1("eigrp.lua: eigrp.lua: TLV type %d unknown.", tlv.type) index = index + tlv.length - 4 end table.insert(eigrp_packet.tlvs, tlv) @@ -244,7 +244,7 @@ EIGRP = { if type(tlv) == 'table' then table.insert(self.tlvs, tlv) else - stdnse.print_debug("eigrp.lua: TLV should be a table, not %s", type(tlv)) + stdnse.debug1("eigrp.lua: TLV should be a table, not %s", type(tlv)) end end, @@ -332,10 +332,10 @@ EIGRP = { data = data .. bin.pack(">S", tlv.htime) elseif tlv.type == TLV.AUTH then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.SEQ then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.SWVER then data = data .. bin.pack(">S", TLV.SWVER) data = data .. bin.pack(">S", 0x0008) @@ -343,39 +343,39 @@ EIGRP = { data = data .. bin.pack(">CC", tonumber(tlv.majtlv), tonumber(tlv.mintlv)) elseif tlv.type == TLV.MSEQ then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.STUB then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.TERM then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.TIDLIST then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.REQ then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.INT then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.EXT then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.COM then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.INT6 then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.EXT6 then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) elseif tlv.type == TLV.COM6 then -- TODO - stdnse.print_debug("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d skipped due to no parser.", tlv.type) else - stdnse.print_debug("eigrp.lua: TLV type %d unknown.", tlv.type) + stdnse.debug1("eigrp.lua: TLV type %d unknown.", tlv.type) end end -- In the end, correct the checksum if not manually set diff --git a/nselib/gps.lua b/nselib/gps.lua index 68c17b8a1..73ab217b7 100644 --- a/nselib/gps.lua +++ b/nselib/gps.lua @@ -98,7 +98,7 @@ NMEA = { return true, e else local err = ("No parser for prefix: %s"):format(prefix) - stdnse.print_debug(2, err) + stdnse.debug2("%s", err) return false, err end diff --git a/nselib/http.lua b/nselib/http.lua index 29959cfbe..150241b41 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -266,17 +266,17 @@ local function validate_options(options) for key, value in pairs(options) do if(key == 'timeout') then if(type(tonumber(value)) ~= 'number') then - stdnse.print_debug(1, 'http: options.timeout contains a non-numeric value') + stdnse.debug1('http: options.timeout contains a non-numeric value') bad = true end elseif(key == 'header') then if(type(value) ~= 'table') then - stdnse.print_debug(1, "http: options.header should be a table") + stdnse.debug1("http: options.header should be a table") bad = true end elseif(key == 'content') then if(type(value) ~= 'string' and type(value) ~= 'table') then - stdnse.print_debug(1, "http: options.content should be a string or a table") + stdnse.debug1("http: options.content should be a string or a table") bad = true end elseif(key == 'cookies') then @@ -285,42 +285,42 @@ local function validate_options(options) for cookie_key, cookie_value in pairs(cookie) do if(cookie_key == 'name') then if(type(cookie_value) ~= 'string') then - stdnse.print_debug(1, "http: options.cookies[i].name should be a string") + stdnse.debug1("http: options.cookies[i].name should be a string") bad = true end elseif(cookie_key == 'value') then if(type(cookie_value) ~= 'string') then - stdnse.print_debug(1, "http: options.cookies[i].value should be a string") + stdnse.debug1("http: options.cookies[i].value should be a string") bad = true end elseif(cookie_key == 'path') then if(type(cookie_value) ~= 'string') then - stdnse.print_debug(1, "http: options.cookies[i].path should be a string") + stdnse.debug1("http: options.cookies[i].path should be a string") bad = true end elseif(cookie_key == 'expires') then if(type(cookie_value) ~= 'string') then - stdnse.print_debug(1, "http: options.cookies[i].expires should be a string") + stdnse.debug1("http: options.cookies[i].expires should be a string") bad = true end else - stdnse.print_debug(1, "http: Unknown field in cookie table: %s", cookie_key) + stdnse.debug1("http: Unknown field in cookie table: %s", cookie_key) bad = true end end end elseif(type(value) ~= 'string') then - stdnse.print_debug(1, "http: options.cookies should be a table or a string") + stdnse.debug1("http: options.cookies should be a table or a string") bad = true end elseif(key == 'auth') then if(type(value) == 'table') then if(value['username'] == nil or value['password'] == nil) then - stdnse.print_debug(1, "http: options.auth should contain both a 'username' and a 'password' key") + stdnse.debug1("http: options.auth should contain both a 'username' and a 'password' key") bad = true end else - stdnse.print_debug(1, "http: options.auth should be a table") + stdnse.debug1("http: options.auth should be a table") bad = true end elseif (key == 'digestauth') then @@ -328,27 +328,27 @@ local function validate_options(options) local req_keys = {"username","realm","nonce","digest-uri","response"} for _,k in ipairs(req_keys) do if not value[k] then - stdnse.print_debug(1, "http: options.digestauth missing key: %s",k) + stdnse.debug1("http: options.digestauth missing key: %s",k) bad = true break end end else bad = true - stdnse.print_debug(1, "http: options.digestauth should be a table") + stdnse.debug1("http: options.digestauth should be a table") end elseif(key == 'bypass_cache' or key == 'no_cache' or key == 'no_cache_body') then if(type(value) ~= 'boolean') then - stdnse.print_debug(1, "http: options.bypass_cache, options.no_cache, and options.no_cache_body must be boolean values") + stdnse.debug1("http: options.bypass_cache, options.no_cache, and options.no_cache_body must be boolean values") bad = true end elseif(key == 'redirect_ok') then if(type(value)~= 'function' and type(value)~='boolean') then - stdnse.print_debug(1, "http: options.redirect_ok must be a function or boolean") + stdnse.debug1("http: options.redirect_ok must be a function or boolean") bad = true end else - stdnse.print_debug(1, "http: Unknown key in the options table: %s", key) + stdnse.debug1("http: Unknown key in the options table: %s", key) end end @@ -525,7 +525,7 @@ local function recv_chunked(s, partial) if not line then -- this warning message was initially an error but was adapted -- to support broken servers, such as the Citrix XML Service - stdnse.print_debug(2, "Didn't find CRLF after chunk-data.") + stdnse.debug2("Didn't find CRLF after chunk-data.") elseif not string.match(line, "^\r?\n") then return nil, string.format("Didn't find CRLF after chunk-data; got %q.", line) end @@ -925,7 +925,7 @@ local function check_size (cache) local size = cache.size; if size > max_size then - stdnse.print_debug(1, + stdnse.debug1( "Current http cache size (%d bytes) exceeds max size of %d", size, max_size); table.sort(cache, function(r1, r2) @@ -942,7 +942,7 @@ local function check_size (cache) end cache.size = size; end - stdnse.print_debug(2, "Final http cache size (%d bytes) of max size of %d", + stdnse.debug2("Final http cache size (%d bytes) of max size of %d", size, max_size); return size; end @@ -1202,7 +1202,7 @@ local function request(host, port, data, options) if type(port) == 'table' then if port.protocol and port.protocol ~= 'tcp' then - stdnse.print_debug(1, "http.request() supports the TCP protocol only, your request to %s cannot be completed.", host) + stdnse.debug1("http.request() supports the TCP protocol only, your request to %s cannot be completed.", host) return http_error("Unsupported protocol.") end end @@ -1256,7 +1256,7 @@ function generic_request(host, port, method, path, options) local digest_auth = options and options.auth and options.auth.digest if digest_auth and not have_ssl then - stdnse.print_debug("http: digest auth requires openssl.") + stdnse.debug1("http: digest auth requires openssl.") end if digest_auth and have_ssl then @@ -1267,7 +1267,7 @@ function generic_request(host, port, method, path, options) local r = generic_request(host, port, method, path, options_with_auth_removed) local h = r.header['www-authenticate'] if not r.status or (h and not string.find(h:lower(), "digest.-realm")) then - stdnse.print_debug("http: the target doesn't support digest auth or there was an error during request.") + stdnse.debug1("http: the target doesn't support digest auth or there was an error during request.") return http_error("The target doesn't support digest auth or there was an error during request.") end -- Compute the response hash @@ -1381,7 +1381,7 @@ function redirect_ok(host, port) counter = counter - 1 for i, rule in ipairs( rules ) do if ( not(rule( url, host, port )) ) then - --stdnse.print_debug("Rule failed: %d", i) + --stdnse.debug1("Rule failed: %d", i) return false end end @@ -1603,19 +1603,19 @@ end -- Deprecated pipeline functions function pGet( host, port, path, options, ignored, allReqs ) - stdnse.print_debug(1, "WARNING: pGet() is deprecated. Use pipeline_add() instead.") + stdnse.debug1("WARNING: pGet() is deprecated. Use pipeline_add() instead.") return pipeline_add(path, options, allReqs, 'GET') end function pHead( host, port, path, options, ignored, allReqs ) - stdnse.print_debug(1, "WARNING: pHead() is deprecated. Use pipeline_add instead.") + stdnse.debug1("WARNING: pHead() is deprecated. Use pipeline_add instead.") return pipeline_add(path, options, allReqs, 'HEAD') end function addPipeline(host, port, path, options, ignored, allReqs, method) - stdnse.print_debug(1, "WARNING: addPipeline() is deprecated! Use pipeline_add instead.") + stdnse.debug1("WARNING: addPipeline() is deprecated! Use pipeline_add instead.") return pipeline_add(path, options, allReqs, method) end function pipeline(host, port, allReqs) - stdnse.print_debug(1, "WARNING: pipeline() is deprecated. Use pipeline_go() instead.") + stdnse.debug1("WARNING: pipeline() is deprecated. Use pipeline_go() instead.") return pipeline_go(host, port, allReqs) end @@ -1678,7 +1678,7 @@ end -- @return A list of responses, in the same order as the requests were queued. -- Each response is a table as described in the module documentation. function pipeline_go(host, port, all_requests) - stdnse.print_debug("Total number of pipelined requests: " .. #all_requests) + stdnse.debug1("Total number of pipelined requests: " .. #all_requests) local responses local response local partial @@ -1687,7 +1687,7 @@ function pipeline_go(host, port, all_requests) -- Check for an empty request if (#all_requests == 0) then - stdnse.print_debug(1, "Warning: empty set of requests passed to http.pipeline()") + stdnse.debug1("Warning: empty set of requests passed to http.pipeline()") return responses end @@ -1713,7 +1713,7 @@ function pipeline_go(host, port, all_requests) limit = limit > #all_requests and #all_requests or limit local max_pipeline = stdnse.get_script_args("http.max-pipeline") or limit -- how many requests should be pipelined local count = 1 - stdnse.print_debug(1, "Number of requests allowed by pipeline: " .. limit) + stdnse.debug1("Number of requests allowed by pipeline: " .. limit) while #responses < #all_requests do local j, batch_end @@ -1752,7 +1752,7 @@ function pipeline_go(host, port, all_requests) local req_sent = 0 -- start sending the requests and pipeline them in batches of max_pipeline elements while start <= len do - stdnse.print_debug(2, "HTTP pipeline: number of requests in current batch: %d, already sent: %d, responses from current batch: %d, all responses received: %d",len,start-1,count,#responses) + stdnse.debug2("HTTP pipeline: number of requests in current batch: %d, already sent: %d, responses from current batch: %d, all responses received: %d",len,start-1,count,#responses) local req = {} if max_pipeline == limit then req = requests @@ -1772,8 +1772,8 @@ function pipeline_go(host, port, all_requests) while inner_count < num_req and #responses < #all_requests do response, partial = next_response(socket, all_requests[#responses + 1].method, partial) if not response then - stdnse.print_debug("HTTP pipeline: there was a problem while receiving responses.") - stdnse.print_debug(3, "The request was:\n%s",req) + stdnse.debug1("HTTP pipeline: there was a problem while receiving responses.") + stdnse.debug3("The request was:\n%s",req) fail = true break end @@ -1787,15 +1787,15 @@ function pipeline_go(host, port, all_requests) socket:close() if count == 0 then - stdnse.print_debug("Received 0 of %d expected responses.\nGiving up on pipeline.", limit); + stdnse.debug1("Received 0 of %d expected responses.\nGiving up on pipeline.", limit); break elseif count < req_sent then - stdnse.print_debug("Received only %d of %d expected responses.\nDecreasing max pipelined requests to %d.", count, req_sent, count) + stdnse.debug1("Received only %d of %d expected responses.\nDecreasing max pipelined requests to %d.", count, req_sent, count) limit = count end end - stdnse.print_debug("Number of received responses: " .. #responses) + stdnse.debug1("Number of received responses: " .. #responses) return responses end @@ -1993,17 +1993,17 @@ function parse_date(s) tz = "GMT" end if not day then - stdnse.print_debug(1, "http.parse_date: can't parse date \"%s\": unknown format.", s) + stdnse.debug1("http.parse_date: can't parse date \"%s\": unknown format.", s) return nil end -- Look up the numeric code for month. month = MONTH_MAP[month_name] if not month then - stdnse.print_debug(1, "http.parse_date: unknown month name \"%s\".", month_name) + stdnse.debug1("http.parse_date: unknown month name \"%s\".", month_name) return nil end if tz ~= "GMT" then - stdnse.print_debug(1, "http.parse_date: don't know time zone \"%s\", only \"GMT\".", tz) + stdnse.debug1("http.parse_date: don't know time zone \"%s\", only \"GMT\".", tz) return nil end day = tonumber(day) @@ -2169,26 +2169,26 @@ function can_use_head(host, port, result_404, path) local data = head( host, port, path ) if data then if data.status and data.status == 302 and data.header and data.header.location then - stdnse.print_debug(1, "HTTP: Warning: Host returned 302 and not 200 when performing HEAD.") + stdnse.debug1("HTTP: Warning: Host returned 302 and not 200 when performing HEAD.") return false end if data.status and data.status == 200 and data.header then -- check that a body wasn't returned if #data.body > 0 then - stdnse.print_debug(1, "HTTP: Warning: Host returned data when performing HEAD.") + stdnse.debug1("HTTP: Warning: Host returned data when performing HEAD.") return false end - stdnse.print_debug(1, "HTTP: Host supports HEAD.") + stdnse.debug1("HTTP: Host supports HEAD.") return true, data end - stdnse.print_debug(1, "HTTP: Didn't receive expected response to HEAD request (got %s).", get_status_string(data)) + stdnse.debug1("HTTP: Didn't receive expected response to HEAD request (got %s).", get_status_string(data)) return false end - stdnse.print_debug(1, "HTTP: HEAD request completely failed.") + stdnse.debug1("HTTP: HEAD request completely failed.") return false end @@ -2294,17 +2294,17 @@ function identify_404(host, port) data = get(host, port, URL_404_1) if(data == nil) then - stdnse.print_debug(1, "HTTP: Failed while testing for 404 status code") + stdnse.debug1("HTTP: Failed while testing for 404 status code") return false, "Failed while testing for 404 error message" end if(data.status and data.status == 404) then - stdnse.print_debug(1, "HTTP: Host returns proper 404 result.") + stdnse.debug1("HTTP: Host returns proper 404 result.") return true, 404 end if(data.status and data.status == 200) then - stdnse.print_debug(1, "HTTP: Host returns 200 instead of 404.") + stdnse.debug1("HTTP: Host returns 200 instead of 404.") -- Clean up the body (for example, remove the URI). This makes it easier to validate later if(data.body) then @@ -2312,7 +2312,7 @@ function identify_404(host, port) local data2 = get(host, port, URL_404_2) local data3 = get(host, port, URL_404_3) if(data2 == nil or data3 == nil) then - stdnse.print_debug(1, "HTTP: Failed while testing for extra 404 error messages") + stdnse.debug1("HTTP: Failed while testing for extra 404 error messages") return false, "Failed while testing for extra 404 error messages" end @@ -2323,7 +2323,7 @@ function identify_404(host, port) if(type(data2.status) ~= "number") then data2.status = -1 end - stdnse.print_debug(1, "HTTP: HTTP 404 status changed for second request (became %d).", data2.status) + stdnse.debug1("HTTP: HTTP 404 status changed for second request (became %d).", data2.status) return false, string.format("HTTP 404 status changed for second request (became %d).", data2.status) end @@ -2332,7 +2332,7 @@ function identify_404(host, port) if(type(data3.status) ~= "number") then data3.status = -1 end - stdnse.print_debug(1, "HTTP: HTTP 404 status changed for third request (became %d).", data3.status) + stdnse.debug1("HTTP: HTTP 404 status changed for third request (became %d).", data3.status) return false, string.format("HTTP 404 status changed for third request (became %d).", data3.status) end @@ -2341,33 +2341,33 @@ function identify_404(host, port) local clean_body2 = clean_404(data2.body) local clean_body3 = clean_404(data3.body) if(clean_body ~= clean_body2) then - stdnse.print_debug(1, "HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response.") - stdnse.print_debug(1, "HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.") + stdnse.debug1("HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response.") + stdnse.debug1("HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.") return false, string.format("Two known 404 pages returned valid and different pages; unable to identify valid response.") end if(clean_body ~= clean_body3) then - stdnse.print_debug(1, "HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).") - stdnse.print_debug(1, "HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.") + stdnse.debug1("HTTP: Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).") + stdnse.debug1("HTTP: If you investigate the server and it's possible to clean up the pages, please post to nmap-dev mailing list.") return false, string.format("Two known 404 pages returned valid and different pages; unable to identify valid response (happened when checking a folder).") end return true, 200, clean_body end - stdnse.print_debug(1, "HTTP: The 200 response didn't contain a body.") + stdnse.debug1("HTTP: The 200 response didn't contain a body.") return true, 200 end -- Loop through any expected error codes for _,code in pairs(bad_responses) do if(data.status and data.status == code) then - stdnse.print_debug(1, "HTTP: Host returns %s instead of 404 File Not Found.", get_status_string(data)) + stdnse.debug1("HTTP: Host returns %s instead of 404 File Not Found.", get_status_string(data)) return true, code end end - stdnse.print_debug(1, "Unexpected response returned for 404 check: %s", get_status_string(data)) + stdnse.debug1("Unexpected response returned for 404 check: %s", get_status_string(data)) return true, data.status end @@ -2398,17 +2398,17 @@ function page_exists(data, result_404, known_404, page, displayall) -- If the 404 response is also "200", deal with it (check if the body matches) if(#data.body == 0) then -- I observed one server that returned a blank string instead of an error, on some occasions - stdnse.print_debug(1, "HTTP: Page returned a totally empty body; page likely doesn't exist") + stdnse.debug1("HTTP: Page returned a totally empty body; page likely doesn't exist") return false elseif(clean_404(data.body) ~= known_404) then - stdnse.print_debug(1, "HTTP: Page returned a body that doesn't match known 404 body, therefore it exists (%s)", page) + stdnse.debug1("HTTP: Page returned a body that doesn't match known 404 body, therefore it exists (%s)", page) return true else return false end else -- If 404s return something other than 200, and we got a 200, we're good to go - stdnse.print_debug(1, "HTTP: Page was '%s', it exists! (%s)", get_status_string(data), page) + stdnse.debug1("HTTP: Page was '%s', it exists! (%s)", get_status_string(data), page) return true end else @@ -2416,7 +2416,7 @@ function page_exists(data, result_404, known_404, page, displayall) if(data.status ~= 404 and data.status ~= result_404) then -- If this check succeeded, then the page isn't a standard 404 -- it could be a redirect, authentication request, etc. Unless the user -- asks for everything (with a script argument), only display 401 Authentication Required here. - stdnse.print_debug(1, "HTTP: Page didn't match the 404 response (%s) (%s)", get_status_string(data), page) + stdnse.debug1("HTTP: Page didn't match the 404 response (%s) (%s)", get_status_string(data), page) if(data.status == 401) then -- "Authentication Required" return true @@ -2431,7 +2431,7 @@ function page_exists(data, result_404, known_404, page, displayall) end end else - stdnse.print_debug(1, "HTTP: HTTP request failed (is the host still up?)") + stdnse.debug1("HTTP: HTTP request failed (is the host still up?)") return false end end diff --git a/nselib/httpspider.lua b/nselib/httpspider.lua index d67803f9f..babe89adb 100644 --- a/nselib/httpspider.lua +++ b/nselib/httpspider.lua @@ -294,7 +294,7 @@ LinkExtractor = { if ( self.options.maxdepth and self.options.maxdepth >= 0 ) then local depth = self:getDepth( url ) if ( -1 == depth or depth > self.options.maxdepth ) then - stdnse.print_debug(3, "%s: Skipping link depth: %d; b_url=%s; url=%s", LIBRARY_NAME, depth, tostring(self.options.base_url), tostring(url)) + stdnse.debug3("%s: Skipping link depth: %d; b_url=%s; url=%s", LIBRARY_NAME, depth, tostring(self.options.base_url), tostring(url)) return false end end @@ -302,7 +302,7 @@ LinkExtractor = { -- withindomain trumps any whitelisting if ( self.options.withindomain ) then if ( not(self.options.withindomain(url)) ) then - stdnse.print_debug(2, "%s: Link is not within domain: %s", LIBRARY_NAME, tostring(url)) + stdnse.debug2("%s: Link is not within domain: %s", LIBRARY_NAME, tostring(url)) return false end end @@ -310,7 +310,7 @@ LinkExtractor = { -- withinhost trumps any whitelisting if ( self.options.withinhost ) then if ( not(self.options.withinhost(url)) ) then - stdnse.print_debug(2, "%s: Link is not within host: %s", LIBRARY_NAME, tostring(url)) + stdnse.debug2("%s: Link is not within host: %s", LIBRARY_NAME, tostring(url)) return false end end @@ -319,7 +319,7 @@ LinkExtractor = { if ( #self.options.blacklist > 0 ) then for _, func in ipairs(self.options.blacklist) do if ( func(url) ) then - stdnse.print_debug(2, "%s: Blacklist match: %s", LIBRARY_NAME, tostring(url)) + stdnse.debug2("%s: Blacklist match: %s", LIBRARY_NAME, tostring(url)) valid = false break end @@ -331,7 +331,7 @@ LinkExtractor = { valid = false for _, func in ipairs(self.options.whitelist) do if ( func(url) ) then - stdnse.print_debug(2, "%s: Whitelist match: %s", LIBRARY_NAME, tostring(url)) + stdnse.debug2("%s: Whitelist match: %s", LIBRARY_NAME, tostring(url)) valid = true break end @@ -379,10 +379,10 @@ LinkExtractor = { local valid = self:validate_link(url) if ( valid ) then - stdnse.print_debug(3, "%s: Adding link: %s", LIBRARY_NAME, tostring(url)) + stdnse.debug3("%s: Adding link: %s", LIBRARY_NAME, tostring(url)) links[tostring(url)] = true elseif ( tostring(url) ) then - stdnse.print_debug(3, "%s: Skipping url: %s", LIBRARY_NAME, link) + stdnse.debug3("%s: Skipping url: %s", LIBRARY_NAME, link) end end end @@ -441,11 +441,11 @@ URL = { self.domain= self.host:match("^[^%.]-%.(.*)") return true elseif( self.raw:match("^javascript:") ) then - stdnse.print_debug(2, "%s: Skipping javascript url: %s", LIBRARY_NAME, self.raw) + stdnse.debug2("%s: Skipping javascript url: %s", LIBRARY_NAME, self.raw) elseif( self.raw:match("^mailto:") ) then - stdnse.print_debug(2, "%s: Skipping mailto link: %s", LIBRARY_NAME, self.raw) + stdnse.debug2("%s: Skipping mailto link: %s", LIBRARY_NAME, self.raw) else - stdnse.print_debug(2, "%s: WARNING: Failed to parse url: %s", LIBRARY_NAME, self.raw) + stdnse.debug2("%s: WARNING: Failed to parse url: %s", LIBRARY_NAME, self.raw) end return false end, @@ -527,7 +527,7 @@ UrlQueue = { if ( u ) then table.insert(self.urls, u) else - stdnse.print_debug("ERROR: Invalid URL: %s", url) + stdnse.debug1("ERROR: Invalid URL: %s", url) end end end, @@ -690,7 +690,7 @@ Crawler = { end end - stdnse.print_debug(2, "%s: %s", LIBRARY_NAME, o:getLimitations()) + stdnse.debug2("%s: %s", LIBRARY_NAME, o:getLimitations()) return o end, @@ -790,16 +790,16 @@ Crawler = { end if ( self.options.maxpagecount ) then - stdnse.print_debug(2, "%s: Fetching url [%d of %d]: %s", LIBRARY_NAME, count, self.options.maxpagecount, tostring(url)) + stdnse.debug2("%s: Fetching url [%d of %d]: %s", LIBRARY_NAME, count, self.options.maxpagecount, tostring(url)) else - stdnse.print_debug(2, "%s: Fetching url: %s", LIBRARY_NAME, tostring(url)) + stdnse.debug2("%s: Fetching url: %s", LIBRARY_NAME, tostring(url)) end local scrape = true if not (self.options.doscraping(url)) then - stdnse.print_debug(2, "%s: Scraping is not allowed for url: %s", LIBRARY_NAME, tostring(url)) + stdnse.debug2("%s: Scraping is not allowed for url: %s", LIBRARY_NAME, tostring(url)) scrape = false end @@ -819,10 +819,10 @@ Crawler = { end end if is_web_file then - stdnse.print_debug(2, "%s: Using GET: %s", LIBRARY_NAME, file) + stdnse.debug2("%s: Using GET: %s", LIBRARY_NAME, file) response = http.get(url:getHost(), url:getPort(), url:getFile(), { timeout = self.options.timeout, redirect_ok = self.options.redirect_ok, no_cache = self.options.no_cache } ) else - stdnse.print_debug(2, "%s: Using HEAD: %s", LIBRARY_NAME, file) + stdnse.debug2("%s: Using HEAD: %s", LIBRARY_NAME, file) response = http.head(url:getHost(), url:getPort(), url:getFile()) end else @@ -854,7 +854,7 @@ Crawler = { end table.insert(response_queue, { true, { url = url, response = response } } ) while ( PREFETCH_SIZE < #response_queue ) do - stdnse.print_debug(2, "%s: Response queue full, waiting ...", LIBRARY_NAME) + stdnse.debug2("%s: Response queue full, waiting ...", LIBRARY_NAME) condvar "wait" end condvar "signal" @@ -866,7 +866,7 @@ Crawler = { loadScriptArguments = function(self) local sn = self.options.scriptname if ( not(sn) ) then - stdnse.print_debug("%s: WARNING: Script argument could not be loaded as scriptname was not set", LIBRARY_NAME) + stdnse.debug1("%s: WARNING: Script argument could not be loaded as scriptname was not set", LIBRARY_NAME) return end diff --git a/nselib/iax2.lua b/nselib/iax2.lua index f42ec63d1..f1b8481f5 100644 --- a/nselib/iax2.lua +++ b/nselib/iax2.lua @@ -76,7 +76,7 @@ IAX2 = { local pos, frame_type = bin.unpack("C", data) if ( bit.band(frame_type, 0x80) == 0 ) then print("frame_type", stdnse.tohex(frame_type)) - stdnse.print_debug(2, "Frametype not supported") + stdnse.debug2("Frametype not supported") return end header.type = IAX2.PacketType.FULL diff --git a/nselib/ike.lua b/nselib/ike.lua index 05bca7ac4..02dfe1fdf 100644 --- a/nselib/ike.lua +++ b/nselib/ike.lua @@ -106,7 +106,7 @@ local function load_fingerprints() -- Check if fingerprints are cached if(nmap.registry.ike_fingerprints ~= nil) then - stdnse.print_debug(1, "ike: Loading cached fingerprints") + stdnse.debug1("ike: Loading cached fingerprints") return nmap.registry.ike_fingerprints end @@ -115,11 +115,11 @@ local function load_fingerprints() filename_full = nmap.fetchfile('nselib/data/ike-fingerprints.lua') -- Load the file - stdnse.print_debug(1, "ike: Loading fingerprints: %s", filename_full) + stdnse.debug1("ike: Loading fingerprints: %s", filename_full) local env = setmetatable({fingerprints = {}}, {__index = _G}); file = loadfile(filename_full, "t", env) if( not(file) ) then - stdnse.print_debug(1, "ike: Couldn't load the file: %s", filename_full) + stdnse.debug1("ike: Couldn't load the file: %s", filename_full) return false, "Couldn't load fingerprint file: " .. filename_full end file() @@ -175,9 +175,9 @@ local function extract_payloads(packet) -- debug if PAYLOADS[np] == 'VID' then - stdnse.print_debug(2, 'IKE: Found IKE Header: %s: %s - %s', np, PAYLOADS[np], payload) + stdnse.debug2('IKE: Found IKE Header: %s: %s - %s', np, PAYLOADS[np], payload) else - stdnse.print_debug(2, 'IKE: Found IKE Header: %s: %s', np, PAYLOADS[np]) + stdnse.debug2('IKE: Found IKE Header: %s: %s', np, PAYLOADS[np]) end -- Store payload @@ -241,7 +241,7 @@ local function lookup(vendor_ids) local debug_string = '' if row.vendor ~= nil then debug_string = debug_string .. row.vendor .. ' ' end if row.version ~= nil then debug_string = debug_string .. row.version end - stdnse.print_debug(2, "IKE: Fingerprint: %s matches %s", vendor_id, debug_string) + stdnse.debug2("IKE: Fingerprint: %s matches %s", vendor_id, debug_string) -- Only store the first match if info.vendor == nil then @@ -251,7 +251,7 @@ local function lookup(vendor_ids) elseif row.category == 'attribute' then info.attribs[ #info.attribs + 1] = row - stdnse.print_debug(2, "IKE: Attribute: %s matches %s", vendor_id, row.text) + stdnse.debug2("IKE: Attribute: %s matches %s", vendor_id, row.text) break end end @@ -280,7 +280,7 @@ local function lookup(vendor_ids) if info.vendor.vendor ~= nil then debug_string = debug_string .. info.vendor.vendor .. ' ' end if info.vendor.version ~= nil then debug_string = debug_string .. info.vendor.version .. ' ' end if info.vendor.ostype ~= nil then debug_string = debug_string .. info.vendor.ostype end - stdnse.print_debug(2, 'IKE: No vendor match, but ordering match found: %s', debug_string) + stdnse.debug2('IKE: No vendor match, but ordering match found: %s', debug_string) return info @@ -292,7 +292,7 @@ local function lookup(vendor_ids) debug_string = '' if info.vendor.vendor ~= nil then debug_string = debug_string .. info.vendor.vendor .. ' to ' end if row.ostype ~= nil then debug_string = debug_string .. row.ostype end - stdnse.print_debug(2, 'IKE: Vendor and ordering match. OS updated: %s', debug_string) + stdnse.debug2('IKE: Vendor and ordering match. OS updated: %s', debug_string) return info @@ -302,7 +302,7 @@ local function lookup(vendor_ids) debug_string = '' if info.vendor.vendor ~= nil then debug_string = debug_string .. info.vendor.vendor .. ' vs ' end if row.vendor ~= nil then debug_string = debug_string .. row.vendor end - stdnse.print_debug(2, 'IKE: Found an ordering match, but vendors do not match. %s', debug_string) + stdnse.debug2('IKE: Found an ordering match, but vendors do not match. %s', debug_string) end end diff --git a/nselib/ipOps.lua b/nselib/ipOps.lua index 55c1c4005..b7e9089e9 100644 --- a/nselib/ipOps.lua +++ b/nselib/ipOps.lua @@ -162,7 +162,7 @@ end --@return The string representing the address. fromdword = function( ip ) if type( ip ) ~= "number" then - stdnse.print_debug(1, "Error in ipOps.todword: Expected IPv4 address.") + stdnse.debug1("Error in ipOps.todword: Expected IPv4 address.") return nil end diff --git a/nselib/ipp.lua b/nselib/ipp.lua index b6b6047d3..4ab118036 100644 --- a/nselib/ipp.lua +++ b/nselib/ipp.lua @@ -267,7 +267,7 @@ IPP = { end if ( not(group) ) then - stdnse.print_debug(2, "Unexpected tag: %d", tag) + stdnse.debug2("Unexpected tag: %d", tag) return end diff --git a/nselib/iscsi.lua b/nselib/iscsi.lua index 2a80d8a16..e424e195d 100644 --- a/nselib/iscsi.lua +++ b/nselib/iscsi.lua @@ -348,7 +348,7 @@ Packet = { table.insert(resp.records, record) break else - stdnse.print_debug("ERROR: iscsi.TextResponse: Unknown target record (%s)", k) + stdnse.debug1("ERROR: iscsi.TextResponse: Unknown target record (%s)", k) end end @@ -669,7 +669,7 @@ Helper = { end if ( resp.status_code ~= 0 ) then - stdnse.print_debug(3, "ERROR: iscsi.Helper.login: Authentication failed (error code: %d)", resp.status_code) + stdnse.debug3("ERROR: iscsi.Helper.login: Authentication failed (error code: %d)", resp.status_code) return false, resp elseif ( auth_method:upper()=="NONE" ) then return true, resp diff --git a/nselib/jdwp.lua b/nselib/jdwp.lua index 303be26d3..f54096984 100644 --- a/nselib/jdwp.lua +++ b/nselib/jdwp.lua @@ -19,7 +19,7 @@ -- -- local status,socket = jdwp.connect(host,port) -- if not status then --- stdnse.print_debug("error, %s",socket) +-- stdnse.debug1("error, %s",socket) -- end -- local version_info -- status, version_info = jdwp.getVersion(socket,0) @@ -176,7 +176,7 @@ JDWPReplyPacket = { if flags == 0x80 then return true, JDWPReplyPacket:new(length,id,error_code,data) end - stdnse.print_debug(2,"JDWP error parsing reply. Wrong reply packet flag. Raw data: ", stdnse.tohex(reply_packet)) + stdnse.debug2("JDWP error parsing reply. Wrong reply packet flag. Raw data: ", stdnse.tohex(reply_packet)) return false, "JDWP error parsing reply." end @@ -194,21 +194,21 @@ function connect(host,port) socket:set_timeout(10000) local status, err = socket:connect(host, port) if not status then - stdnse.print_debug(2,"JDWP could not connect: %s",err) + stdnse.debug2("JDWP could not connect: %s",err) return status, err end status, err = socket:send(JDWP_CONSTANTS.handshake) if not status then - stdnse.print_debug(2,"JDWP could not send handshake: %s",err) + stdnse.debug2("JDWP could not send handshake: %s",err) return status, err end status, result = socket:receive() if not status then - stdnse.print_debug(2,"JDWP could not receive handshake: %s",result) + stdnse.debug2("JDWP could not receive handshake: %s",result) return status, result end if result == JDWP_CONSTANTS.handshake then - stdnse.print_debug("JDWP handshake successful.") + stdnse.debug1("JDWP handshake successful.") return true, socket end return false, "JDWP handshake unsuccessful." @@ -255,7 +255,7 @@ end local function extract_string(data,pos) local string_size if pos > #data then - stdnse.print_debug(2,"JDWP extract_string() position higher than data length, probably incomplete data received.") + stdnse.debug2("JDWP extract_string() position higher than data length, probably incomplete data received.") return pos, nil end pos, string_size = bin.unpack(">I",data,pos) @@ -311,7 +311,7 @@ function getVersion(socket,id) local command = JDWPCommandPacket:new(id,1,1,nil) -- Version Command (1) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP getVersion() error : %s",data) + stdnse.debug2("JDWP getVersion() error : %s",data) return false,data end -- parse data @@ -348,7 +348,7 @@ function getClassBySignature(socket,id,signature) local command = JDWPCommandPacket:new(id,1,2,toUTF8(signature)) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP getClassBySignature() error : %s",data) + stdnse.debug2("JDWP getClassBySignature() error : %s",data) return false,data end -- parse data @@ -381,7 +381,7 @@ function getAllThreads(socket,id) local command = JDWPCommandPacket:new(id,1,4,nil) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP getAllThreads() error: %s", data) + stdnse.debug2("JDWP getAllThreads() error: %s", data) return false,data end -- parse data @@ -407,13 +407,13 @@ function resumeVM(socket,id) local command = JDWPCommandPacket:new(id,1,9,nil) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP resumeVM() error: %s", data) + stdnse.debug2("JDWP resumeVM() error: %s", data) return false,data end -- wait for event notification status, data = receive_all(socket) if not status then - stdnse.print_debug(2,"JDWP resumeVM() event notification failed: %s", data) + stdnse.debug2("JDWP resumeVM() event notification failed: %s", data) end return true, nil end @@ -431,7 +431,7 @@ function createString(socket,id,ascii_string) local command = JDWPCommandPacket:new(id,1,11,toUTF8(ascii_string)) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP createString() error: %s", data) + stdnse.debug2("JDWP createString() error: %s", data) return false,data end local _,stringID = bin.unpack(">L",data) @@ -456,7 +456,7 @@ function getAllClassesWithGeneric(socket,id) local command = JDWPCommandPacket:new(id,1,20,nil) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP getAllClassesWithGeneric() error: %s", data) + stdnse.debug2("JDWP getAllClassesWithGeneric() error: %s", data) return false,data end -- parse data @@ -499,7 +499,7 @@ function getSignatureWithGeneric(socket,id,classID) local command = JDWPCommandPacket:new(id,2,13,bin.pack(">L",classID)) -- Version Command (1) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP getVersion() error : %s",data) + stdnse.debug2("JDWP getVersion() error : %s",data) return false,data end local _,signature = extract_string(data,0) @@ -526,7 +526,7 @@ function getMethodsWithGeneric(socket,id,classID) local command = JDWPCommandPacket:new(id,2,15,bin.pack(">L",classID)) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP getMethodsWithGeneric() error : %s",data) + stdnse.debug2("JDWP getMethodsWithGeneric() error : %s",data) return false,data end -- parse data @@ -579,7 +579,7 @@ function invokeStaticMethod(socket,id,classID,methodID,numberOfArguments,argumen local command = JDWPCommandPacket:new(id,3,3,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP invokeStaticMethod() error: %s", data) + stdnse.debug2("JDWP invokeStaticMethod() error: %s", data) return false,data end return true,data @@ -610,11 +610,11 @@ function newClassInstance(socket,id,classID,threadID,methodID,numberOfArguments, local command = JDWPCommandPacket:new(id,3,4,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP newClassInstance() error: %s", data) + stdnse.debug2("JDWP newClassInstance() error: %s", data) return false,data end -- parse data - stdnse.print_debug("newClassInstance data: %s",stdnse.tohex(data)) + stdnse.debug1("newClassInstance data: %s",stdnse.tohex(data)) local pos, tag = bin.unpack(">C",data) local objectID pos, objectID = bin.unpack(">L",data,pos) @@ -639,7 +639,7 @@ function newArrayInstance(socket,id,arrayType,length) local command = JDWPCommandPacket:new(id,4,1,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP newArrayInstance() error: %s", data) + stdnse.debug2("JDWP newArrayInstance() error: %s", data) return false,data end local pos,_ , tag, arrayID @@ -664,11 +664,11 @@ function getRuntimeType(socket,id,objectID) local command = JDWPCommandPacket:new(id,9,1,bin.pack(">L",objectID)) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP resumeVM() error: %s", data) + stdnse.debug2("JDWP resumeVM() error: %s", data) return false,data end local _,tag,runtime_type = bin.unpack(">CL",data) - stdnse.print_debug("runtime type: %d",runtime_type) + stdnse.debug1("runtime type: %d",runtime_type) return true,runtime_type end @@ -698,10 +698,10 @@ function invokeObjectMethod(socket,id,objectID,threadID,classID,methodID,numberO local command = JDWPCommandPacket:new(id,9,6,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP invokeObjectMethod() error: %s", data) + stdnse.debug2("JDWP invokeObjectMethod() error: %s", data) return false,data end - stdnse.print_debug("invoke obj method data: %s ",stdnse.tohex(data)) + stdnse.debug1("invoke obj method data: %s ",stdnse.tohex(data)) return true,data end @@ -721,7 +721,7 @@ function readString(socket,id,stringID) local command = JDWPCommandPacket:new(id,10,1,bin.pack(">L",stringID)) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP readString() error: %s", data) + stdnse.debug2("JDWP readString() error: %s", data) return false,data end local _,result = extract_string(data,0) @@ -746,7 +746,7 @@ function getThreadName(socket,id,threadID) local command = JDWPCommandPacket:new(id,11,1,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP getThreadName() error: %s", data) + stdnse.debug2("JDWP getThreadName() error: %s", data) return false,data end -- parse data @@ -768,7 +768,7 @@ function suspendThread(socket,id,threadID) local command = JDWPCommandPacket:new(id,11,2,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP suspendThread() error: %s", data) + stdnse.debug2("JDWP suspendThread() error: %s", data) return false,data end return true, nil @@ -789,10 +789,10 @@ function threadStatus(socket,id,threadID) local command = JDWPCommandPacket:new(id,11,4,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP threadStatus() error: %s", data) + stdnse.debug2("JDWP threadStatus() error: %s", data) return false,data end - stdnse.print_debug("threadStatus %s",stdnse.tohex(data)) + stdnse.debug1("threadStatus %s",stdnse.tohex(data)) return true, data end @@ -813,7 +813,7 @@ function setArrayValues(socket,id,objectID,idx,values) local command = JDWPCommandPacket:new(id,13,3,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP setArrayValues() error: %s", data) + stdnse.debug2("JDWP setArrayValues() error: %s", data) return false,data end return true, nil @@ -835,7 +835,7 @@ function setThreadSinglestep(socket,id,threadID) local command = JDWPCommandPacket:new(id,15,1,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP setThreadSinglestep() error: %s", data) + stdnse.debug2("JDWP setThreadSinglestep() error: %s", data) return false,data end local _, requestID = bin.unpack(">i",data) @@ -855,7 +855,7 @@ function clearThreadSinglestep(socket,id,eventID) local command = JDWPCommandPacket:new(id,15,2,params) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP clearThreadSinglestep() error: %s", data) + stdnse.debug2("JDWP clearThreadSinglestep() error: %s", data) return false,data end return true,nil @@ -879,7 +879,7 @@ function getReflectedType(socket,id,classObjectID) local command = JDWPCommandPacket:new(id,17,1,bin.pack(">L",classObjectID)) local status, data = executeCommand(socket,command) if not status then - stdnse.print_debug(2,"JDWP getReflectedType() error: %s", data) + stdnse.debug2("JDWP getReflectedType() error: %s", data) return false,data end local reflected_type = { @@ -904,7 +904,7 @@ function findMethod(socket,class,methodName,skipFirst) return false end for _, method in ipairs(methods) do -- find first constructor and first defineClass() method - stdnse.print_debug(2,"Method name: %s", method.name) + stdnse.debug2("Method name: %s", method.name) if methodID == nil then if string.find(method.name,methodName) then if skipFirst then @@ -933,7 +933,7 @@ function injectClass(socket,class_bytes) -- find byte array class id needed to create new array to load our bytecode into status,classes = getAllClassesWithGeneric(socket,0) if not status then - stdnse.print_debug("getAllClassesWithGeneric failed: %s", classes) + stdnse.debug1("getAllClassesWithGeneric failed: %s", classes) return false end local byteArrayID @@ -944,10 +944,10 @@ function injectClass(socket,class_bytes) end end if byteArrayID == nil then - stdnse.print_debug("finding byte array id failed") + stdnse.debug1("finding byte array id failed") return false end - stdnse.print_debug("Found byte[] id %d",byteArrayID) + stdnse.debug1("Found byte[] id %d",byteArrayID) -- find SecureClassLoader id by signature status, classes = getClassBySignature(socket,0,"Ljava/security/SecureClassLoader;") @@ -955,7 +955,7 @@ function injectClass(socket,class_bytes) return false end local secureClassLoader = classes[1].referenceTypeID - stdnse.print_debug("Found SecureClassLoader id %d",secureClassLoader) + stdnse.debug1("Found SecureClassLoader id %d",secureClassLoader) -- find SecureClassLoader() constructor local constructorMethodID = findMethod(socket,secureClassLoader,"",true) -- find ClassLoader id by signature @@ -964,13 +964,13 @@ function injectClass(socket,class_bytes) return false end local classLoader = classes[1].referenceTypeID - stdnse.print_debug("Found ClassLoader id %d",classes[1].referenceTypeID) + stdnse.debug1("Found ClassLoader id %d",classes[1].referenceTypeID) -- find ClassLoader's defineClass() method local defineClassMethodID = findMethod(socket,classLoader,"defineClass",false) -- find ClassLoader's resolveClass() method local resolveClassMethodID = findMethod(socket,classLoader,"resolveClass",false) if constructorMethodID == nil or defineClassMethodID == nil or resolveClassMethodID == nil then - stdnse.print_debug("Either constructor, defineClass or resolveClass method could not be found %s,%s,%s", type(constructorMethodID), type(defineClassMethodID),type(resolveClassMethodID)) + stdnse.debug1("Either constructor, defineClass or resolveClass method could not be found %s,%s,%s", type(constructorMethodID), type(defineClassMethodID),type(resolveClassMethodID)) return false end @@ -979,18 +979,18 @@ function injectClass(socket,class_bytes) local arrayID status, arrayID = newArrayInstance(socket,0,byteArrayID,#class_bytes) if not status then - stdnse.print_debug("New array failed: %s", arrayID) + stdnse.debug1("New array failed: %s", arrayID) return false end - stdnse.print_debug("Created new byte array of length %d",#class_bytes) + stdnse.debug1("Created new byte array of length %d",#class_bytes) -- set array values local temp status, temp = setArrayValues(socket,0,arrayID,0,class_bytes) if not status then - stdnse.print_debug("Set values failed: %s", temp) + stdnse.debug1("Set values failed: %s", temp) return end - stdnse.print_debug("Set array values to injected class bytes") + stdnse.debug1("Set array values to injected class bytes") -- get main thread id -- in order to load a new class file, thread must be suspended by an event @@ -998,58 +998,58 @@ function injectClass(socket,class_bytes) local threads status,threads = getAllThreads(socket,0) if not status then - stdnse.print_debug("get threads failed: %s", threads) + stdnse.debug1("get threads failed: %s", threads) return false end local main_thread local eventID - stdnse.print_debug("Looking for main thread...") + stdnse.debug1("Looking for main thread...") for _,thread in ipairs(threads) do local thread_name status, thread_name = getThreadName(socket,0,thread) if not status then - stdnse.print_debug("getThreadName failed: %s", thread_name) + stdnse.debug1("getThreadName failed: %s", thread_name) return false end if thread_name == "main" then - stdnse.print_debug("Setting singlesteping to main thread.") + stdnse.debug1("Setting singlesteping to main thread.") status, eventID = setThreadSinglestep(socket,0,thread) main_thread = thread break end end if main_thread == nil then - stdnse.print_debug("couldn't find main thread") + stdnse.debug1("couldn't find main thread") return false end -- to trigger the singlestep event, VM must be resumed - stdnse.print_debug("Resuming VM and waiting for single step event from main thread...") + stdnse.debug1("Resuming VM and waiting for single step event from main thread...") local status, _ = resumeVM(socket,0) -- clear singlestep since we need to run our code in this thread and we don't want it to stop after each instruction clearThreadSinglestep(socket,0,eventID) - stdnse.print_debug("Cleared singlesteping from main thread.") + stdnse.debug1("Cleared singlesteping from main thread.") -- instantiate new class loader local class_loader_instance status, class_loader_instance = newClassInstance(socket,0,secureClassLoader,main_thread,constructorMethodID,0,nil) if not status then - stdnse.print_debug("newClassInstance failed: %s", class_loader_instance) + stdnse.debug1("newClassInstance failed: %s", class_loader_instance) return false end - stdnse.print_debug("Created new instance of SecureClassLoader.") + stdnse.debug1("Created new instance of SecureClassLoader.") local injectedClass -- invoke defineClass with byte array that contains our bytecode local defineClassArgs = bin.pack(">CLCiCi",0x5b,arrayID,0x49,0,0x49,#class_bytes) -- argument tags taken from http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/types.html#wp9502 - stdnse.print_debug("Calling secureClassLoader.defineClass(byte[],int,int) ...") + stdnse.debug1("Calling secureClassLoader.defineClass(byte[],int,int) ...") status, injectedClass = invokeObjectMethod(socket,0,class_loader_instance,main_thread,secureClassLoader,defineClassMethodID,3,defineClassArgs) if not status then - stdnse.print_debug("invokeObjectMethod failed: %s", injectedClass) + stdnse.debug1("invokeObjectMethod failed: %s", injectedClass) end -- resolve (Java's way of saying link) loaded class status, _ = invokeObjectMethod(socket,0,class_loader_instance,main_thread,secureClassLoader,resolveClassMethodID,1,injectedClass) -- call with injectedClass which still has a tag if not status then - stdnse.print_debug("invokeObjectMethod failed:") + stdnse.debug1("invokeObjectMethod failed:") end -- extract the injected class' ID local tag,injectedClassID @@ -1064,17 +1064,17 @@ function injectClass(socket,class_bytes) status, _ = invokeObjectMethod(socket,0,injectedClassID,main_thread,runtime_type,getMethodsMethod,0,nil) - stdnse.print_debug("New class defined. Injected class id : %d",injectedClassID) + stdnse.debug1("New class defined. Injected class id : %d",injectedClassID) local sig, reflected_type status, sig = getSignatureWithGeneric(socket,0,injectedClassID) - stdnse.print_debug("Injected class signature: %s", sig) + stdnse.debug1("Injected class signature: %s", sig) status, reflected_type = getReflectedType(socket,0,injectedClassID) -- find injected class constructor local injectedConstructor = findMethod(socket,injectedClassID,"",false) if injectedConstructor == nil then - stdnse.print_debug("Couldn't find either evil method or constructor") + stdnse.debug1("Couldn't find either evil method or constructor") return false end diff --git a/nselib/json.lua b/nselib/json.lua index 786e2127b..5eeace4f0 100644 --- a/nselib/json.lua +++ b/nselib/json.lua @@ -182,7 +182,7 @@ end --Some local shortcuts local function dbg(str,...) - stdnse.print_debug("Json:"..str, ...) + stdnse.debug1("Json:"..str, ...) end local function d4(str,...) if nmap.debugging() > 3 then dbg(str, ...) end @@ -193,7 +193,7 @@ end --local dbg =stdnse.print_debug local function dbg_err(str,...) - stdnse.print_debug("json-ERR:"..str, ...) + stdnse.debug1("json-ERR:"..str, ...) end -- See section 2.5 for escapes. diff --git a/nselib/ldap.lua b/nselib/ldap.lua index e0c5feb3c..a38c81e3a 100644 --- a/nselib/ldap.lua +++ b/nselib/ldap.lua @@ -225,7 +225,7 @@ end function searchRequest( socket, params ) local searchResEntries = { errorMessage="", resultCode = 0} - local catch = function() socket:close() stdnse.print_debug("SearchRequest failed") end + local catch = function() socket:close() stdnse.debug1("SearchRequest failed") end local try = nmap.new_try(catch) local attributes = params.attributes local request = encode(params.baseObject) @@ -343,7 +343,7 @@ end -- @return err string containing error message function bindRequest( socket, params ) - local catch = function() socket:close() stdnse.print_debug("bindRequest failed") end + local catch = function() socket:close() stdnse.debug1("bindRequest failed") end local try = nmap.new_try(catch) local ldapAuth = encode( { _ldaptype = 80, params.password } ) local bindReq = encode( params.version ) .. encode( params.username ) .. ldapAuth @@ -396,7 +396,7 @@ end function unbindRequest( socket ) local ldapMsg, packet - local catch = function() socket:close() stdnse.print_debug("bindRequest failed") end + local catch = function() socket:close() stdnse.debug1("bindRequest failed") end local try = nmap.new_try(catch) local encoder = asn1.ASN1Encoder:new() diff --git a/nselib/membase.lua b/nselib/membase.lua index 5664d6c9b..24496081e 100644 --- a/nselib/membase.lua +++ b/nselib/membase.lua @@ -165,7 +165,7 @@ TAP = { -- @return status true on success, false on failure parse = function(self) if ( 24 > #self.data ) then - stdnse.print_debug("membase: Header packet too short (%d bytes)", #self.data) + stdnse.debug1("membase: Header packet too short (%d bytes)", #self.data) return false, "Packet to short" end local pos @@ -286,7 +286,7 @@ Helper = { local header = TAP.Response.Header:new(data) if ( header.opcode ~= req.header.opcode ) then - stdnse.print_debug("WARNING: Received invalid op code, request contained (%d), response contained (%d)", req.header.opcode, header.opcode) + stdnse.debug1("WARNING: Received invalid op code, request contained (%d), response contained (%d)", req.header.opcode, header.opcode) end if ( not(TAP.Response.Decoder[tonumber(header.opcode)]) ) then diff --git a/nselib/mobileme.lua b/nselib/mobileme.lua index 20311ccf1..2d7d3079e 100644 --- a/nselib/mobileme.lua +++ b/nselib/mobileme.lua @@ -75,12 +75,12 @@ MobileMe = { if ( response.status == 200 ) then local status, resp = json.parse(response.body) if ( not(status) ) then - stdnse.print_debug(2, "Failed to parse JSON response from server") + stdnse.debug2("Failed to parse JSON response from server") return false, "Failed to parse JSON response from server" end if ( resp.statusCode ~= "200" ) then - stdnse.print_debug(2, "Failed to send message to server") + stdnse.debug2("Failed to send message to server") return false, "Failed to send message to server" end end diff --git a/nselib/mongodb.lua b/nselib/mongodb.lua index 2de381d54..782cea89f 100644 --- a/nselib/mongodb.lua +++ b/nselib/mongodb.lua @@ -28,7 +28,7 @@ local arg_DB = stdnse.get_script_args("mongodb.db") -- Some lazy shortcuts local function dbg(str,...) - stdnse.print_debug(3, "MngoDb:"..str, ...) + stdnse.debug3("MngoDb:"..str, ...) end --local dbg =stdnse.print_debug @@ -55,7 +55,7 @@ local err =stdnse.print_debug --module("bson", package.seeall) --require("bin") local function dbg_err(str,...) - stdnse.print_debug("Bson-ERR:"..str, ...) + stdnse.debug1("Bson-ERR:"..str, ...) end --local err =stdnse.log_error @@ -558,7 +558,7 @@ function query(socket, data) --Create an error handler local catch = function() socket:close() - stdnse.print_debug("Query failed") + stdnse.debug1("Query failed") end local try = nmap.new_try(catch) diff --git a/nselib/msrpc.lua b/nselib/msrpc.lua index e8660d519..b9033af8a 100644 --- a/nselib/msrpc.lua +++ b/nselib/msrpc.lua @@ -234,7 +234,7 @@ function bind(smbstate, interface_uuid, interface_version, transfer_syntax) local pos, align local result - stdnse.print_debug(2, "MSRPC: Sending Bind() request") + stdnse.debug2("MSRPC: Sending Bind() request") -- Use the only transfer_syntax value I know of. if(transfer_syntax == nil) then @@ -280,7 +280,7 @@ function bind(smbstate, interface_uuid, interface_version, transfer_syntax) return false, result end - stdnse.print_debug(3, "MSRPC: Received Bind() result") + stdnse.debug3("MSRPC: Received Bind() result") -- Make these easier to access. parameters = result['parameters'] @@ -402,7 +402,7 @@ function call_function(smbstate, opnum, arguments) arguments ) - stdnse.print_debug(3, "MSRPC: Calling function 0x%02x with %d bytes of arguments", #arguments, opnum) + stdnse.debug3("MSRPC: Calling function 0x%02x with %d bytes of arguments", #arguments, opnum) -- Pass the information up to the smb layer status, result = smb.write_file(smbstate, data, 0) @@ -475,7 +475,7 @@ function call_function(smbstate, opnum, arguments) result['arguments'] = arguments - stdnse.print_debug(3, "MSRPC: Function call successful, %d bytes of returned arguments", #result['arguments']) + stdnse.debug3("MSRPC: Function call successful, %d bytes of returned arguments", #result['arguments']) return true, result end @@ -493,7 +493,7 @@ function call_lanmanapi(smbstate, opnum, paramdesc, datadesc, data) data ) - stdnse.print_debug(1, "MSRPC: Sending Browser Service request") + stdnse.debug1("MSRPC: Sending Browser Service request") status, result = smb.send_transaction_named_pipe(smbstate, parameters, nil, "\\PIPE\\LANMAN", true) if(not(status)) then @@ -530,14 +530,14 @@ function rap_netserverenum2(smbstate, domain, server_type, detail_level) local parameters = result.parameters local data = result.data - stdnse.print_debug(1, "MSRPC: Parsing Browser Service response") + stdnse.debug1("MSRPC: Parsing Browser Service response") local pos, status, convert, entry_count, available_entries = bin.unpack("S",data,pos) else - stdnse.print_debug("unknown address type %x",address_type) + stdnse.debug1("unknown address type %x",address_type) end end end @@ -1344,7 +1344,7 @@ function samr_connect4(smbstate, server) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling Connect4() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling Connect4() [%s]", smbstate['ip']) -- [in,string,charset(UTF16)] uint16 *system_name, arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. server, true) @@ -1363,7 +1363,7 @@ function samr_connect4(smbstate, server) return false, result end - stdnse.print_debug(3, "MSRPC: Connect4() returned successfully") + stdnse.debug3("MSRPC: Connect4() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -1398,7 +1398,7 @@ function samr_enumdomains(smbstate, connect_handle) local result local pos, align - stdnse.print_debug(2, "MSRPC: Calling EnumDomains() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling EnumDomains() [%s]", smbstate['ip']) -- [in,ref] policy_handle *connect_handle, arguments = msrpctypes.marshall_policy_handle(connect_handle) @@ -1419,7 +1419,7 @@ function samr_enumdomains(smbstate, connect_handle) return false, result end - stdnse.print_debug(3, "MSRPC: EnumDomains() returned successfully") + stdnse.debug3("MSRPC: EnumDomains() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -1461,7 +1461,7 @@ function samr_lookupdomain(smbstate, connect_handle, domain) local pos, align local referent_id - stdnse.print_debug(2, "MSRPC: Calling LookupDomain(%s) [%s]", domain, smbstate['ip']) + stdnse.debug2("MSRPC: Calling LookupDomain(%s) [%s]", domain, smbstate['ip']) -- [in,ref] policy_handle *connect_handle, arguments = msrpctypes.marshall_policy_handle(connect_handle) @@ -1478,7 +1478,7 @@ function samr_lookupdomain(smbstate, connect_handle, domain) return false, result end - stdnse.print_debug(3, "MSRPC: LookupDomain() returned successfully") + stdnse.debug3("MSRPC: LookupDomain() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -1514,7 +1514,7 @@ function samr_opendomain(smbstate, connect_handle, sid) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling OpenDomain(%s) [%s]", sid, smbstate['ip']) + stdnse.debug2("MSRPC: Calling OpenDomain(%s) [%s]", sid, smbstate['ip']) -- [in,ref] policy_handle *connect_handle, arguments = msrpctypes.marshall_policy_handle(connect_handle) @@ -1534,7 +1534,7 @@ function samr_opendomain(smbstate, connect_handle, sid) return false, result end - stdnse.print_debug(3, "MSRPC: OpenDomain() returned successfully") + stdnse.debug3("MSRPC: OpenDomain() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -1570,7 +1570,7 @@ function samr_enumdomainusers(smbstate, domain_handle) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling EnumDomainUsers() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling EnumDomainUsers() [%s]", smbstate['ip']) -- [in,ref] policy_handle *domain_handle, arguments = msrpctypes.marshall_policy_handle(domain_handle) @@ -1594,7 +1594,7 @@ function samr_enumdomainusers(smbstate, domain_handle) return false, result end - stdnse.print_debug(3, "MSRPC: EnumDomainUsers() returned successfully") + stdnse.debug3("MSRPC: EnumDomainUsers() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -1651,7 +1651,7 @@ function samr_querydisplayinfo(smbstate, domain_handle, index, count) -- This loop is because, in my testing, if I asked for all the results at once, it would blow up (ERR_BUFFER_OVERFLOW). So, instead, -- I put a little loop here and grab the names individually. - stdnse.print_debug(2, "MSRPC: Calling QueryDisplayInfo(%d) [%s]", index, smbstate['ip']) + stdnse.debug2("MSRPC: Calling QueryDisplayInfo(%d) [%s]", index, smbstate['ip']) -- [in,ref] policy_handle *domain_handle, arguments = msrpctypes.marshall_policy_handle(domain_handle) @@ -1679,7 +1679,7 @@ function samr_querydisplayinfo(smbstate, domain_handle, index, count) return false, result end - stdnse.print_debug(3, "MSRPC: QueryDisplayInfo() returned successfully", i) + stdnse.debug3("MSRPC: QueryDisplayInfo() returned successfully", i) -- Make arguments easier to use arguments = result['arguments'] @@ -1741,7 +1741,7 @@ function samr_querydomaininfo2(smbstate, domain_handle, level) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling QueryDomainInfo2(%d) [%s]", level, smbstate['ip']) + stdnse.debug2("MSRPC: Calling QueryDomainInfo2(%d) [%s]", level, smbstate['ip']) -- [in,ref] policy_handle *domain_handle, arguments = msrpctypes.marshall_policy_handle(domain_handle) @@ -1757,7 +1757,7 @@ function samr_querydomaininfo2(smbstate, domain_handle, level) return false, result end - stdnse.print_debug(3, "MSRPC: QueryDomainInfo2() returned successfully") + stdnse.debug3("MSRPC: QueryDomainInfo2() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2066,7 +2066,7 @@ end -- -- -- pos, result['return'] = msrpctypes.unmarshall_int32(arguments, pos) ---stdnse.print_debug("Return = %08x\n", result['return']) +--stdnse.debug1("Return = %08x\n", result['return']) -- if(result['return'] == nil) then -- return false, "Read off the end of the packet (samr.getmembersinalias)" -- end @@ -2091,7 +2091,7 @@ function samr_close(smbstate, handle) local pos, align - stdnse.print_debug(2, "MSRPC: Calling Close() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling Close() [%s]", smbstate['ip']) -- [in,out,ref] policy_handle *handle arguments = msrpctypes.marshall_policy_handle(handle) @@ -2102,7 +2102,7 @@ function samr_close(smbstate, handle) return false, result end - stdnse.print_debug(3, "MSRPC: Close() returned successfully") + stdnse.debug3("MSRPC: Close() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2135,7 +2135,7 @@ function lsa_openpolicy2(smbstate, server) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling LsarOpenPolicy2() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling LsarOpenPolicy2() [%s]", smbstate['ip']) -- [in,unique] [string,charset(UTF16)] uint16 *system_name, arguments = msrpctypes.marshall_unicode_ptr(server, true) @@ -2154,7 +2154,7 @@ function lsa_openpolicy2(smbstate, server) return false, result end - stdnse.print_debug(3, "MSRPC: LsarOpenPolicy2() returned successfully") + stdnse.debug3("MSRPC: LsarOpenPolicy2() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2193,7 +2193,7 @@ function lsa_lookupnames2(smbstate, policy_handle, names) local result local pos, align - stdnse.print_debug(2, "MSRPC: Calling LsarLookupNames2(%s) [%s]", stdnse.strjoin(", ", names), smbstate['ip']) + stdnse.debug2("MSRPC: Calling LsarLookupNames2(%s) [%s]", stdnse.strjoin(", ", names), smbstate['ip']) -- [in] policy_handle *handle, @@ -2229,7 +2229,7 @@ function lsa_lookupnames2(smbstate, policy_handle, names) return false, result end - stdnse.print_debug(3, "MSRPC: LsarLookupNames2() returned successfully") + stdnse.debug3("MSRPC: LsarLookupNames2() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2285,7 +2285,7 @@ function lsa_lookupsids2(smbstate, policy_handle, sids) local result local pos, align - stdnse.print_debug(2, "MSRPC: Calling LsarLookupSids2(%s) [%s]", stdnse.strjoin(", ", sids), smbstate['ip']) + stdnse.debug2("MSRPC: Calling LsarLookupSids2(%s) [%s]", stdnse.strjoin(", ", sids), smbstate['ip']) -- [in] policy_handle *handle, arguments = msrpctypes.marshall_policy_handle(policy_handle) @@ -2343,7 +2343,7 @@ function lsa_lookupsids2(smbstate, policy_handle, sids) return false, smb.get_status_name(result['return']) .. " (lsa.lookupsids2)" end - stdnse.print_debug(3, "MSRPC: LsarLookupSids2(): Returning") + stdnse.debug3("MSRPC: LsarLookupSids2(): Returning") return true, result end @@ -2359,7 +2359,7 @@ function lsa_close(smbstate, handle) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling LsaClose() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling LsaClose() [%s]", smbstate['ip']) -- [in,out] policy_handle *handle arguments = msrpctypes.marshall_policy_handle(handle) @@ -2385,7 +2385,7 @@ function lsa_close(smbstate, handle) return false, smb.get_status_name(result['return']) .. " (lsa.close)" end - stdnse.print_debug(3, "MSRPC: LsaClose() returned successfully") + stdnse.debug3("MSRPC: LsaClose() returned successfully") return true, result end @@ -2413,7 +2413,7 @@ function winreg_openhku(smbstate) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling OpenHKU() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling OpenHKU() [%s]", smbstate['ip']) -- [in] uint16 *system_name, arguments = msrpctypes.marshall_int16_ptr(0x1337, true) @@ -2429,7 +2429,7 @@ function winreg_openhku(smbstate) return false, result end - stdnse.print_debug(3, "MSRPC: OpenHKU() returned successfully") + stdnse.debug3("MSRPC: OpenHKU() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2463,7 +2463,7 @@ function winreg_openhklm(smbstate) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling OpenHKLM() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling OpenHKLM() [%s]", smbstate['ip']) -- [in] uint16 *system_name, arguments = msrpctypes.marshall_int16_ptr(0x1337, true) @@ -2479,7 +2479,7 @@ function winreg_openhklm(smbstate) return false, result end - stdnse.print_debug(3, "MSRPC: OpenHKLM() returned successfully") + stdnse.debug3("MSRPC: OpenHKLM() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2512,7 +2512,7 @@ function winreg_openhkpd(smbstate) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling OpenHKPD() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling OpenHKPD() [%s]", smbstate['ip']) -- [in] uint16 *system_name, arguments = msrpctypes.marshall_int16_ptr(0x1337, true) @@ -2528,7 +2528,7 @@ function winreg_openhkpd(smbstate) return false, result end - stdnse.print_debug(3, "MSRPC: OpenHKPD() returned successfully") + stdnse.debug3("MSRPC: OpenHKPD() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2561,7 +2561,7 @@ function winreg_openhkcu(smbstate) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling OpenHKCU() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling OpenHKCU() [%s]", smbstate['ip']) -- [in] uint16 *system_name, arguments = msrpctypes.marshall_int16_ptr(0x1337, true) @@ -2577,7 +2577,7 @@ function winreg_openhkcu(smbstate) return false, result end - stdnse.print_debug(3, "MSRPC: OpenHKCU() returned successfully") + stdnse.debug3("MSRPC: OpenHKCU() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2619,7 +2619,7 @@ function winreg_enumkey(smbstate, handle, index, name) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling EnumKey(%d) [%s]", index, smbstate['ip']) + stdnse.debug2("MSRPC: Calling EnumKey(%d) [%s]", index, smbstate['ip']) -- [in,ref] policy_handle *handle, arguments = msrpctypes.marshall_policy_handle(handle) @@ -2644,7 +2644,7 @@ function winreg_enumkey(smbstate, handle, index, name) return false, result end - stdnse.print_debug(3, "MSRPC: EnumKey() returned successfully") + stdnse.debug3("MSRPC: EnumKey() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2689,7 +2689,7 @@ function winreg_openkey(smbstate, handle, keyname) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling OpenKey(%s) [%s]", keyname, smbstate['ip']) + stdnse.debug2("MSRPC: Calling OpenKey(%s) [%s]", keyname, smbstate['ip']) -- [in,ref] policy_handle *parent_handle, arguments = msrpctypes.marshall_policy_handle(handle) @@ -2712,7 +2712,7 @@ function winreg_openkey(smbstate, handle, keyname) return false, result end - stdnse.print_debug(3, "MSRPC: OpenKey() returned successfully") + stdnse.debug3("MSRPC: OpenKey() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2749,7 +2749,7 @@ function winreg_queryinfokey(smbstate, handle) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling QueryInfoKey() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling QueryInfoKey() [%s]", smbstate['ip']) -- [in,ref] policy_handle *handle, arguments = msrpctypes.marshall_policy_handle(handle) @@ -2773,7 +2773,7 @@ function winreg_queryinfokey(smbstate, handle) return false, result end - stdnse.print_debug(3, "MSRPC: QueryInfoKey() returned successfully") + stdnse.debug3("MSRPC: QueryInfoKey() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2834,7 +2834,7 @@ function winreg_queryvalue(smbstate, handle, value) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling QueryValue(%s) [%s]", value, smbstate['ip']) + stdnse.debug2("MSRPC: Calling QueryValue(%s) [%s]", value, smbstate['ip']) -- [in,ref] policy_handle *handle, @@ -2861,7 +2861,7 @@ function winreg_queryvalue(smbstate, handle, value) return false, result end - stdnse.print_debug(3, "MSRPC: QueryValue() returned successfully") + stdnse.debug3("MSRPC: QueryValue() returned successfully") local length, referent_id -- Make arguments easier to use @@ -2889,7 +2889,7 @@ function winreg_queryvalue(smbstate, handle, value) elseif(result['type'] == "REG_NONE") then result['value'] = "" else - stdnse.print_debug("MSRPC ERROR: Unknown type: %s", result['type']) + stdnse.debug1("MSRPC ERROR: Unknown type: %s", result['type']) result['value'] = result['type'] end else @@ -2929,7 +2929,7 @@ function winreg_closekey(smbstate, handle) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling CloseKey() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling CloseKey() [%s]", smbstate['ip']) -- [in,out,ref] policy_handle *handle arguments = msrpctypes.marshall_policy_handle(handle) @@ -2940,7 +2940,7 @@ function winreg_closekey(smbstate, handle) return false, result end - stdnse.print_debug(3, "MSRPC: CloseKey() returned successfully") + stdnse.debug3("MSRPC: CloseKey() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -2973,7 +2973,7 @@ function svcctl_openscmanagera(smbstate, machinename) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling OpenSCManagerA() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling OpenSCManagerA() [%s]", smbstate['ip']) -- [in] [string,charset(UTF16)] uint16 *MachineName, arguments = msrpctypes.marshall_ascii_ptr("\\\\" .. machinename) @@ -2993,7 +2993,7 @@ function svcctl_openscmanagera(smbstate, machinename) return false, result end - stdnse.print_debug(3, "MSRPC: OpenSCManagerA() returned successfully") + stdnse.debug3("MSRPC: OpenSCManagerA() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3034,7 +3034,7 @@ function svcctl_openscmanagerw(smbstate, machinename) -- return svcctl_openscmanagera(smbstate, machinename) -- end - stdnse.print_debug(2, "MSRPC: Calling OpenSCManagerW() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling OpenSCManagerW() [%s]", smbstate['ip']) -- [in] [string,charset(UTF16)] uint16 *MachineName, arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. machinename, true) @@ -3054,7 +3054,7 @@ function svcctl_openscmanagerw(smbstate, machinename) return false, result end - stdnse.print_debug(3, "MSRPC: OpenSCManagerW() returned successfully") + stdnse.debug3("MSRPC: OpenSCManagerW() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3090,7 +3090,7 @@ function svcctl_closeservicehandle(smbstate, handle) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling CloseServiceHandle() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling CloseServiceHandle() [%s]", smbstate['ip']) -- [in,out,ref] policy_handle *handle arguments = msrpctypes.marshall_policy_handle(handle) @@ -3102,7 +3102,7 @@ function svcctl_closeservicehandle(smbstate, handle) return false, result end - stdnse.print_debug(3, "MSRPC: OpenSCManagerA() returned successfully") + stdnse.debug3("MSRPC: OpenSCManagerA() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3135,7 +3135,7 @@ function svcctl_createservicew(smbstate, handle, service_name, display_name, pat local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling CreateServiceW() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling CreateServiceW() [%s]", smbstate['ip']) -- [in,ref] policy_handle *scmanager_handle, arguments = msrpctypes.marshall_policy_handle(handle) @@ -3192,7 +3192,7 @@ function svcctl_createservicew(smbstate, handle, service_name, display_name, pat return false, result end - stdnse.print_debug(3, "MSRPC: CreateServiceW() returned successfully") + stdnse.debug3("MSRPC: CreateServiceW() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3242,7 +3242,7 @@ function svcctl_deleteservice(smbstate, handle) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling DeleteService() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling DeleteService() [%s]", smbstate['ip']) -- [in,ref] policy_handle *handle arguments = msrpctypes.marshall_policy_handle(handle) @@ -3254,7 +3254,7 @@ function svcctl_deleteservice(smbstate, handle) return false, result end - stdnse.print_debug(3, "MSRPC: DeleteService() returned successfully") + stdnse.debug3("MSRPC: DeleteService() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3289,7 +3289,7 @@ function svcctl_openservicew(smbstate, handle, name) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling OpenServiceW() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling OpenServiceW() [%s]", smbstate['ip']) -- [in,ref] policy_handle *scmanager_handle, arguments = msrpctypes.marshall_policy_handle(handle) @@ -3308,7 +3308,7 @@ function svcctl_openservicew(smbstate, handle, name) return false, result end - stdnse.print_debug(3, "MSRPC: OpenServiceW() returned successfully") + stdnse.debug3("MSRPC: OpenServiceW() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3344,7 +3344,7 @@ function svcctl_startservicew(smbstate, handle, args) local status, result local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling StartServiceW() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling StartServiceW() [%s]", smbstate['ip']) -- [in,ref] policy_handle *handle, arguments = msrpctypes.marshall_policy_handle(handle) @@ -3365,7 +3365,7 @@ function svcctl_startservicew(smbstate, handle, args) return false, result end - stdnse.print_debug(3, "MSRPC: StartServiceW() returned successfully") + stdnse.debug3("MSRPC: StartServiceW() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3400,7 +3400,7 @@ function svcctl_controlservice(smbstate, handle, control) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling ControlService() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling ControlService() [%s]", smbstate['ip']) -- [in,ref] policy_handle *handle, arguments = msrpctypes.marshall_policy_handle(handle) @@ -3417,7 +3417,7 @@ function svcctl_controlservice(smbstate, handle, control) return false, result end - stdnse.print_debug(3, "MSRPC: ControlService() returned successfully") + stdnse.debug3("MSRPC: ControlService() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3453,7 +3453,7 @@ function svcctl_queryservicestatus(smbstate, handle, control) local arguments local pos, align - stdnse.print_debug(2, "MSRPC: Calling QueryServiceStatus() [%s]", smbstate['ip']) + stdnse.debug2("MSRPC: Calling QueryServiceStatus() [%s]", smbstate['ip']) -- [in,ref] policy_handle *handle, arguments = msrpctypes.marshall_policy_handle(handle) @@ -3467,7 +3467,7 @@ function svcctl_queryservicestatus(smbstate, handle, control) return false, result end - stdnse.print_debug(3, "MSRPC: QueryServiceStatus() returned successfully") + stdnse.debug3("MSRPC: QueryServiceStatus() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3512,7 +3512,7 @@ function atsvc_jobadd(smbstate, server, command, time) -- TODO end - stdnse.print_debug(2, "MSRPC: Calling AddJob(%s) [%s]", command, smbstate['ip']) + stdnse.debug2("MSRPC: Calling AddJob(%s) [%s]", command, smbstate['ip']) -- [in,unique,string,charset(UTF16)] uint16 *servername, arguments = msrpctypes.marshall_unicode_ptr(server, true) @@ -3528,7 +3528,7 @@ function atsvc_jobadd(smbstate, server, command, time) return false, result end - stdnse.print_debug(3, "MSRPC: AddJob() returned successfully") + stdnse.debug3("MSRPC: AddJob() returned successfully") -- Make arguments easier to use arguments = result['arguments'] @@ -3692,7 +3692,7 @@ end function samr_enum_groups(host) local i, j - stdnse.print_debug(1, "MSRPC: Attempting to enumerate groups on %s", host.ip) + stdnse.debug1("MSRPC: Attempting to enumerate groups on %s", host.ip) -- Create the SMB session local status, smbstate = start_smb(host, SAMR_PATH, true) @@ -3770,7 +3770,7 @@ function samr_enum_groups(host) end -- Print some output - stdnse.print_debug(1, "MSRPC: Found %d groups in %s", #enumaliases_result['sam']['entries'], domain) + stdnse.debug1("MSRPC: Found %d groups in %s", #enumaliases_result['sam']['entries'], domain) -- Record the results local group_rids = {} @@ -3810,7 +3810,7 @@ function samr_enum_groups(host) end -- Print some output - stdnse.print_debug(1, "MSRPC: Adding group '%s' (RID: %d) with %d members", domains[domain][group_rid]['name'], group_rid, #member_sids) + stdnse.debug1("MSRPC: Adding group '%s' (RID: %d) with %d members", domains[domain][group_rid]['name'], group_rid, #member_sids) -- Save the output domains[domain][group_rid]['member_sids'] = member_sids @@ -3962,7 +3962,7 @@ function lsa_enum_users(host) status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids) if(status == false) then - stdnse.print_debug(1, "Error looking up RIDs: %s", lookupsids2_result) + stdnse.debug1("Error looking up RIDs: %s", lookupsids2_result) else -- Put the details for each name into an array -- NOTE: Be sure to mirror any changes here in the next bit! @@ -3996,7 +3996,7 @@ function lsa_enum_users(host) -- Try converting this group of RIDs into names status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids) if(status == false) then - stdnse.print_debug(1, "Error looking up RIDs: %s", lookupsids2_result) + stdnse.debug1("Error looking up RIDs: %s", lookupsids2_result) else -- Put the details for each name into an array for j = 1, #lookupsids2_result['names']['names'], 1 do @@ -4063,7 +4063,7 @@ function get_user_list(host) status_lsa, result_lsa = lsa_enum_users(host) if(status_lsa == false) then - stdnse.print_debug("MSRPC: Failed to enumerate users through LSA: %s", result_lsa) + stdnse.debug1("MSRPC: Failed to enumerate users through LSA: %s", result_lsa) else for i = 1, #result_lsa, 1 do if(result_lsa[i]['name'] ~= nil and result_lsa[i]['type'] == "SID_NAME_USER") then @@ -4074,7 +4074,7 @@ function get_user_list(host) status_samr, result_samr = samr_enum_users(host) if(status_samr == false) then - stdnse.print_debug("MSRPC: Failed to enumerate users through SAMR: %s", result_samr) + stdnse.debug1("MSRPC: Failed to enumerate users through SAMR: %s", result_samr) else for i = 1, #result_samr, 1 do if(result_samr[i]['name'] ~= nil and result_samr[i]['type'] == "SID_NAME_USER") then @@ -4352,7 +4352,7 @@ end function service_create(host, servicename, path) local status, smbstate, bind_result, open_result, create_result, close_result - stdnse.print_debug(1, "Creating service: %s (%s)", servicename, path) + stdnse.debug1("Creating service: %s (%s)", servicename, path) -- Create the SMB session status, smbstate = start_smb(host, SVCCTL_PATH) @@ -4368,7 +4368,7 @@ function service_create(host, servicename, path) end -- Open the service manager - stdnse.print_debug(2, "Opening the remote service manager") + stdnse.debug2("Opening the remote service manager") status, open_result = svcctl_openscmanagerw(smbstate, host.ip) if(status == false) then smb.stop(smbstate) @@ -4376,7 +4376,7 @@ function service_create(host, servicename, path) end -- Create the service - stdnse.print_debug(2, "Creating the service", servicename) + stdnse.debug2("Creating the service", servicename) status, create_result = svcctl_createservicew(smbstate, open_result['handle'], servicename, servicename, path) if(status == false) then smb.stop(smbstate) @@ -4416,7 +4416,7 @@ end function service_start(host, servicename, args) local status, smbstate, bind_result, open_result, open_service_result, start_result, close_result, query_result - stdnse.print_debug(1, "Starting service: %s", servicename) + stdnse.debug1("Starting service: %s", servicename) -- Create the SMB session status, smbstate = start_smb(host, SVCCTL_PATH) @@ -4432,7 +4432,7 @@ function service_start(host, servicename, args) end -- Open the service manager - stdnse.print_debug(1, "Opening the remote service manager") + stdnse.debug1("Opening the remote service manager") status, open_result = svcctl_openscmanagerw(smbstate, host.ip) if(status == false) then smb.stop(smbstate) @@ -4440,7 +4440,7 @@ function service_start(host, servicename, args) end -- Get a handle to the service - stdnse.print_debug(2, "Getting a handle to the service") + stdnse.debug2("Getting a handle to the service") status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename) if(status == false) then smb.stop(smbstate) @@ -4448,7 +4448,7 @@ function service_start(host, servicename, args) end -- Start it - stdnse.print_debug(2, "Starting the service") + stdnse.debug2("Starting the service") status, start_result = svcctl_startservicew(smbstate, open_service_result['handle'], args) if(status == false) then smb.stop(smbstate) @@ -4456,7 +4456,7 @@ function service_start(host, servicename, args) end -- Wait for it to start (TODO: Check the query result better) - stdnse.print_debug(1, "Waiting for the service to start") + stdnse.debug1("Waiting for the service to start") repeat status, query_result = svcctl_queryservicestatus(smbstate, open_service_result['handle']) if(status == false) then @@ -4498,7 +4498,7 @@ end function service_stop(host, servicename) local status, smbstate, bind_result, open_result, open_service_result, control_result, close_result, query_result - stdnse.print_debug(1, "Stopping service: %s", servicename) + stdnse.debug1("Stopping service: %s", servicename) -- Create the SMB session status, smbstate = start_smb(host, SVCCTL_PATH) @@ -4514,7 +4514,7 @@ function service_stop(host, servicename) end -- Open the service manager - stdnse.print_debug(2, "Opening the remote service manager") + stdnse.debug2("Opening the remote service manager") status, open_result = svcctl_openscmanagerw(smbstate, host.ip) if(status == false) then smb.stop(smbstate) @@ -4522,7 +4522,7 @@ function service_stop(host, servicename) end -- Get a handle to the service - stdnse.print_debug(2, "Getting a handle to the service") + stdnse.debug2("Getting a handle to the service") status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename) if(status == false) then smb.stop(smbstate) @@ -4530,7 +4530,7 @@ function service_stop(host, servicename) end -- Stop it - stdnse.print_debug(2, "Stopping the service") + stdnse.debug2("Stopping the service") status, control_result = svcctl_controlservice(smbstate, open_service_result['handle'], "SERVICE_CONTROL_STOP") if(status == false) then smb.stop(smbstate) @@ -4538,7 +4538,7 @@ function service_stop(host, servicename) end -- Wait for it to stop (TODO: Check the query result better) - stdnse.print_debug(2, "Waiting for the service to stop") + stdnse.debug2("Waiting for the service to stop") repeat status, query_result = svcctl_queryservicestatus(smbstate, open_service_result['handle']) if(status == false) then @@ -4577,7 +4577,7 @@ end function service_delete(host, servicename) local status, smbstate, bind_result, open_result, open_service_result, delete_result, close_result - stdnse.print_debug(1, "Deleting service: %s", servicename) + stdnse.debug1("Deleting service: %s", servicename) -- Create the SMB session status, smbstate = start_smb(host, SVCCTL_PATH) @@ -4593,7 +4593,7 @@ function service_delete(host, servicename) end -- Open the service manager - stdnse.print_debug(2, "Opening the remote service manager") + stdnse.debug2("Opening the remote service manager") status, open_result = svcctl_openscmanagerw(smbstate, host.ip) if(status == false) then smb.stop(smbstate) @@ -4601,7 +4601,7 @@ function service_delete(host, servicename) end -- Get a handle to the service - stdnse.print_debug(2, "Getting a handle to the service: %s", servicename) + stdnse.debug2("Getting a handle to the service: %s", servicename) status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename) if(status == false) then smb.stop(smbstate) @@ -4609,7 +4609,7 @@ function service_delete(host, servicename) end -- Delete the service - stdnse.print_debug(2, "Deleting the service") + stdnse.debug2("Deleting the service") status, delete_result = svcctl_deleteservice(smbstate, open_service_result['handle']) if(status == false) then smb.stop(smbstate) diff --git a/nselib/msrpcperformance.lua b/nselib/msrpcperformance.lua index d52c9a043..cef7c7732 100644 --- a/nselib/msrpcperformance.lua +++ b/nselib/msrpcperformance.lua @@ -41,7 +41,7 @@ local function parse_perf_title_database(data, pos) if(number == nil) then return false, "Couldn't parse the title database: end of string encountered early" elseif(tonumber(number) == nil) then -- Not sure if this actually happens, but it doesn't hurt to check - stdnse.print_debug(1, "MSRPC: ERROR: Couldn't parse the title database: string found where number expected (%d: '%s')", i, number) + stdnse.debug1("MSRPC: ERROR: Couldn't parse the title database: string found where number expected (%d: '%s')", i, number) return false, "Couldn't parse the title database" end @@ -510,14 +510,14 @@ function get_performance_data(host, objects) end -- Start setting up the result object - --stdnse.print_debug("Index = %d\n", object_type['ObjectNameTitleIndex']) + --stdnse.debug1("Index = %d\n", object_type['ObjectNameTitleIndex']) local object_name = result['title_database'][object_type['ObjectNameTitleIndex']] result[object_name] = {} - --stdnse.print_debug("\n\nOBJECT: %s\n", object_name) - --stdnse.print_debug(" Counters: %d\n", object_type['NumCounters']) - --stdnse.print_debug(" Instances: %d\n", object_type['NumInstances']) - --stdnse.print_debug("-----------------\n") + --stdnse.debug1("\n\nOBJECT: %s\n", object_name) + --stdnse.debug1(" Counters: %d\n", object_type['NumCounters']) + --stdnse.debug1(" Instances: %d\n", object_type['NumInstances']) + --stdnse.debug1("-----------------\n") -- Bring the position to the beginning of the counter definitions pos = object_start + object_type['HeaderLength'] @@ -529,7 +529,7 @@ function get_performance_data(host, objects) msrpc.stop_smb(smbstate) return false, pos end - --stdnse.print_debug(" Counter definition #%2d: [%d bytes] %s\n", j, counter_definitions[j]['CounterSize'], result['title_database'][counter_definitions[j]['CounterNameTitleIndex']]) + --stdnse.debug1(" Counter definition #%2d: [%d bytes] %s\n", j, counter_definitions[j]['CounterSize'], result['title_database'][counter_definitions[j]['CounterNameTitleIndex']]) end -- Bring the position to the beginning of the instances (or counters) @@ -556,11 +556,11 @@ function get_performance_data(host, objects) -- Bring the pos to the start of the counter block pos = instance_start + object_instances[j]['ByteLength'] - --stdnse.print_debug("\n INSTANCE: %s\n", instance_name) - --stdnse.print_debug(" Length: %d\n", object_instances[j]['ByteLength']) - --stdnse.print_debug(" NameOffset: %d\n", object_instances[j]['NameOffset']) - --stdnse.print_debug(" NameLength: %d\n", object_instances[j]['NameLength']) - --stdnse.print_debug(" --------------\n") + --stdnse.debug1("\n INSTANCE: %s\n", instance_name) + --stdnse.debug1(" Length: %d\n", object_instances[j]['ByteLength']) + --stdnse.debug1(" NameOffset: %d\n", object_instances[j]['NameOffset']) + --stdnse.debug1(" NameLength: %d\n", object_instances[j]['NameLength']) + --stdnse.debug1(" --------------\n") -- The counter block local status, counter_block @@ -580,7 +580,7 @@ function get_performance_data(host, objects) end local counter_name = result['title_database'][counter_definitions[k]['CounterNameTitleIndex']] - --stdnse.print_debug(" %s: %s\n", counter_name, counter_result) + --stdnse.debug1(" %s: %s\n", counter_name, counter_result) -- Save it in the result result[object_name][instance_name][counter_name] = counter_result @@ -600,7 +600,7 @@ function get_performance_data(host, objects) end local counter_name = result['title_database'][counter_definitions[k]['CounterNameTitleIndex']] - --stdnse.print_debug(" %s: %s\n", counter_name, counter_result) + --stdnse.debug1(" %s: %s\n", counter_name, counter_result) -- Save it in the result result[object_name][counter_name] = counter_result diff --git a/nselib/msrpctypes.lua b/nselib/msrpctypes.lua index 20aa9d42e..c8be37ea3 100644 --- a/nselib/msrpctypes.lua +++ b/nselib/msrpctypes.lua @@ -131,7 +131,7 @@ local ALL = 'ALL' function string_to_unicode(string, do_null) local i - stdnse.print_debug(4, "MSRPC: Entering string_to_unicode(string = %s)", string) + stdnse.debug4("MSRPC: Entering string_to_unicode(string = %s)", string) if(do_null == nil) then do_null = false @@ -143,7 +143,7 @@ function string_to_unicode(string, do_null) end if(string == nil) then - stdnse.print_debug(1, "MSRPC: WARNING: couldn't convert value to string in string_to_unicode()") + stdnse.debug1("MSRPC: WARNING: couldn't convert value to string in string_to_unicode()") end @@ -159,7 +159,7 @@ function string_to_unicode(string, do_null) result = result .. "\0\0" end - stdnse.print_debug(4, "MSRPC: Leaving string_to_unicode()") + stdnse.debug4("MSRPC: Leaving string_to_unicode()") return result end @@ -174,12 +174,12 @@ end --@return (pos, string) The new position and the string read, again imitating bin.unpack. If there was an -- attempt to read off the end of the string, then 'nil' is returned for both parameters. function unicode_to_string(buffer, pos, length, do_null) - stdnse.print_debug(4, "MSRPC: Entering unicode_to_string(pos = %d, length = %d)", pos, length) + stdnse.debug4("MSRPC: Entering unicode_to_string(pos = %d, length = %d)", pos, length) local endpos = pos + length * 2 - 1 if endpos > #buffer then - stdnse.print_debug(1, "MSRPC: ERROR: Ran off the end of a string in unicode_to_string(), this likely means we are reading a packet incorrectly. Please report! (pos = %d, #buffer = %d, endpos = %d)", pos, #buffer, endpos) + stdnse.debug1("MSRPC: ERROR: Ran off the end of a string in unicode_to_string(), this likely means we are reading a packet incorrectly. Please report! (pos = %d, #buffer = %d, endpos = %d)", pos, #buffer, endpos) return nil, nil end @@ -193,7 +193,7 @@ function unicode_to_string(buffer, pos, length, do_null) -- Align to 4-byte boundary endpos = endpos + (endpos + 1 - pos) % 4 - stdnse.print_debug(4, "MSRPC: Leaving unicode_to_string()") + stdnse.debug4("MSRPC: Leaving unicode_to_string()") return endpos + 1, str end @@ -246,7 +246,7 @@ end local function marshall_ptr(location, func, args, value) local result = "" - stdnse.print_debug(4, "MSRPC: Entering marshall_ptr(location = %s)", location) + stdnse.debug4("MSRPC: Entering marshall_ptr(location = %s)", location) -- If we're marshalling the HEAD section, add a REFERENT_ID. if(location == HEAD or location == ALL) then @@ -266,7 +266,7 @@ local function marshall_ptr(location, func, args, value) end end - stdnse.print_debug(4, "MSRPC: Leaving marshall_ptr()") + stdnse.debug4("MSRPC: Leaving marshall_ptr()") return result end @@ -307,7 +307,7 @@ end -- the result is nil for null pointers, or the data for -- valid pointers. local function unmarshall_ptr(location, data, pos, func, args, result) - stdnse.print_debug(4, "MSRPC: Entering unmarshall_ptr()") + stdnse.debug4("MSRPC: Entering unmarshall_ptr()") if(args == nil) then args = {} end @@ -316,7 +316,7 @@ local function unmarshall_ptr(location, data, pos, func, args, result) local referent_id pos, referent_id = bin.unpack("data, and a table representing the datatype. local function unmarshall_guid(data, pos) local guid = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_guid()") + stdnse.debug4("MSRPC: Entering unmarshall_guid()") pos, guid['time_low'], guid['time_high'], guid['time_hi_and_version'], guid['clock_seq'], guid['node'] = bin.unpack("data, and a table representing the datatype. function unmarshall_policy_handle(data, pos) local policy_handle = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_policy_handle()") + stdnse.debug4("MSRPC: Entering unmarshall_policy_handle()") pos, policy_handle['handle_type'] = unmarshall_int32(data, pos) pos, policy_handle['uuid'] = unmarshall_guid(data, pos) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_policy_handle()") + stdnse.debug4("MSRPC: Leaving unmarshall_policy_handle()") return pos, policy_handle end @@ -1546,7 +1546,7 @@ function unmarshall_dom_sid2(data, pos) -- Note that authority is big endian (I guess it's an array, not really an integer like we're handling it) pos, sid['authority_high'], sid['authority_low'] = bin.unpack(">SI", data, pos) if(sid['authority_low'] == nil) then - stdnse.print_debug(1, "MSRPC: ERROR: Ran off the end of a packet in unmarshall_dom_sid2(). Please report!") + stdnse.debug1("MSRPC: ERROR: Ran off the end of a packet in unmarshall_dom_sid2(). Please report!") end sid['authority'] = bit.bor(bit.lshift(sid['authority_high'], 32), sid['authority_low']) @@ -1591,15 +1591,15 @@ function marshall_dom_sid2(sid) local pos_next local sid_array = {} local result = "" - stdnse.print_debug(4, "MSRPC: Entering marshall_dom_sid2()") + stdnse.debug4("MSRPC: Entering marshall_dom_sid2()") if(string.find(sid, "^S%-") == nil) then - stdnse.print_debug(1, "MSRPC: ERROR: Invalid SID encountered: %s\n", sid) + stdnse.debug1("MSRPC: ERROR: Invalid SID encountered: %s\n", sid) return nil end if(string.find(sid, "%-%d+$") == nil) then - stdnse.print_debug(1, "MSRPC: ERROR: Invalid SID encountered: %s\n", sid) + stdnse.debug1("MSRPC: ERROR: Invalid SID encountered: %s\n", sid) return nil end @@ -1633,7 +1633,7 @@ function marshall_dom_sid2(sid) result = result .. bin.pack("nil if it wasn't found. function lsa_SidType_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering lsa_SidType_tostr()") + stdnse.debug4("MSRPC: Entering lsa_SidType_tostr()") result = lsa_SidType_str[val] - stdnse.print_debug(4, "MSRPC: Leaving lsa_SidType_tostr()") + stdnse.debug4("MSRPC: Leaving lsa_SidType_tostr()") return result end @@ -1902,11 +1902,11 @@ local lsa_LookupNamesLevel_str = -- found. function marshall_lsa_LookupNamesLevel(names_level) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_lsa_LookupNamesLevel()") + stdnse.debug4("MSRPC: Entering marshall_lsa_LookupNamesLevel()") result = marshall_Enum32(names_level, lsa_LookupNamesLevel) - stdnse.print_debug(4, "MSRPC: Leaving marshall_lsa_LookupNamesLevel()") + stdnse.debug4("MSRPC: Leaving marshall_lsa_LookupNamesLevel()") return result end @@ -1917,11 +1917,11 @@ end --@return (pos, str) The new position, and the string representing the datatype. function unmarshall_lsa_LookupNamesLevel(data, pos) local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_lsa_LookupNamesLevel()") + stdnse.debug4("MSRPC: Entering unmarshall_lsa_LookupNamesLevel()") pos, str = unmarshall_Enum32(data, pos, lsa_LookupNamesLevel) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_lsa_LookupNamesLevel()") + stdnse.debug4("MSRPC: Leaving unmarshall_lsa_LookupNamesLevel()") return pos, str end @@ -1932,11 +1932,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function lsa_LookupNamesLevel_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering lsa_LookupNamesLevel_tostr()") + stdnse.debug4("MSRPC: Entering lsa_LookupNamesLevel_tostr()") result = lsa_LookupNamesLevel_str[val] - stdnse.print_debug(4, "MSRPC: Leaving lsa_LookupNamesLevel_tostr()") + stdnse.debug4("MSRPC: Leaving lsa_LookupNamesLevel_tostr()") return result end @@ -1962,7 +1962,7 @@ end --@return A string representing the marshalled data. local function marshall_lsa_TranslatedSid2(location, sid_type, rid, sid_index, unknown) local result = "" - stdnse.print_debug(4, "MSRPC: Entering marshall_lsa_TranslatedSid2()") + stdnse.debug4("MSRPC: Entering marshall_lsa_TranslatedSid2()") -- Set some default values if(sid_type == nil) then sid_type = "SID_NAME_USE_NONE" end @@ -1980,7 +1980,7 @@ local function marshall_lsa_TranslatedSid2(location, sid_type, rid, sid_index, u if(location == BODY or location == ALL) then end - stdnse.print_debug(4, "MSRPC: Leaving marshall_lsa_TranslatedSid2()") + stdnse.debug4("MSRPC: Leaving marshall_lsa_TranslatedSid2()") return result end @@ -2047,7 +2047,7 @@ end --@return A string representing the marshalled data. local function marshall_lsa_TranslatedName2(location, sid_type, name, sid_index, unknown) local result = "" - stdnse.print_debug(4, "MSRPC: Entering marshall_lsa_TranslatedName2()") + stdnse.debug4("MSRPC: Entering marshall_lsa_TranslatedName2()") -- Set some default values if(sid_type == nil) then sid_type = "SID_NAME_USE_NONE" end @@ -2066,7 +2066,7 @@ local function marshall_lsa_TranslatedName2(location, sid_type, name, sid_index, result = result .. marshall_lsa_String_internal(BODY, name) end - stdnse.print_debug(4, "MSRPC: Leaving marshall_lsa_TranslatedName2()") + stdnse.debug4("MSRPC: Leaving marshall_lsa_TranslatedName2()") return result end @@ -2082,7 +2082,7 @@ end -- anything. --@return (pos, result) The new position in data, and a table representing the datatype. local function unmarshall_lsa_TranslatedName2(location, data, pos, result) - stdnse.print_debug(4, "MSRPC: Entering unmarshall_lsa_TranslatedName2()") + stdnse.debug4("MSRPC: Entering unmarshall_lsa_TranslatedName2()") if(result == nil) then result = {} end @@ -2099,7 +2099,7 @@ local function unmarshall_lsa_TranslatedName2(location, data, pos, result) pos, result['name'] = unmarshall_lsa_String_internal(BODY, data, pos, result['name']) end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_lsa_TranslatedName2()") + stdnse.debug4("MSRPC: Leaving unmarshall_lsa_TranslatedName2()") return pos, result end @@ -2118,7 +2118,7 @@ end function marshall_lsa_TransSidArray2(sids) local result = "" local array = {} - stdnse.print_debug(4, "MSRPC: Entering marshall_lsa_TransSidArray2()") + stdnse.debug4("MSRPC: Entering marshall_lsa_TransSidArray2()") result = result .. marshall_int32(#sids) @@ -2130,7 +2130,7 @@ function marshall_lsa_TransSidArray2(sids) result = result .. marshall_ptr(ALL, marshall_array, {array}, array) - stdnse.print_debug(4, "MSRPC: Leaving marshall_lsa_TransSidArray2()") + stdnse.debug4("MSRPC: Leaving marshall_lsa_TransSidArray2()") return result end @@ -2158,7 +2158,7 @@ end local function unmarshall_lsa_StringLarge(location, data, pos, result) local length, size local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_lsa_StringLarge()") + stdnse.debug4("MSRPC: Entering unmarshall_lsa_StringLarge()") if(location == HEAD or location == ALL) then pos, length = unmarshall_int16(data, pos, false) @@ -2171,7 +2171,7 @@ local function unmarshall_lsa_StringLarge(location, data, pos, result) pos, str = unmarshall_ptr(BODY, data, pos, unmarshall_unicode, {false}, result) end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_lsa_StringLarge()") + stdnse.debug4("MSRPC: Leaving unmarshall_lsa_StringLarge()") return pos, str end @@ -2196,7 +2196,7 @@ end -- anything. --@return (pos, result) The new position in data, and a table representing the datatype. local function unmarshall_lsa_DomainInfo(location, data, pos, result) - stdnse.print_debug(4, "MSRPC: Entering unmarshall_lsa_DomainInfo()") + stdnse.debug4("MSRPC: Entering unmarshall_lsa_DomainInfo()") if(result == nil) then result = {} end @@ -2211,7 +2211,7 @@ local function unmarshall_lsa_DomainInfo(location, data, pos, result) pos, result['sid'] = unmarshall_ptr(BODY, data, pos, unmarshall_dom_sid2, {}, result['sid']) end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_lsa_DomainInfo()") + stdnse.debug4("MSRPC: Leaving unmarshall_lsa_DomainInfo()") return pos, result end @@ -2230,7 +2230,7 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_lsa_RefDomainList(data, pos) local result = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_lsa_RefDomainList()") + stdnse.debug4("MSRPC: Entering unmarshall_lsa_RefDomainList()") -- Head pos, result['count'] = unmarshall_int32(data, pos) @@ -2240,7 +2240,7 @@ function unmarshall_lsa_RefDomainList(data, pos) -- Body pos, result['domains'] = unmarshall_ptr(BODY, data, pos, unmarshall_array, {result['count'], unmarshall_lsa_DomainInfo, {}}, result['domains']) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_lsa_RefDomainList()") + stdnse.debug4("MSRPC: Leaving unmarshall_lsa_RefDomainList()") return pos, result end @@ -2252,11 +2252,11 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_lsa_RefDomainList_ptr(data, pos) local result - stdnse.print_debug(4, "MSRPC: Entering unmarshall_lsa_RefDomainList_ptr()") + stdnse.debug4("MSRPC: Entering unmarshall_lsa_RefDomainList_ptr()") pos, result = unmarshall_ptr(ALL, data, pos, unmarshall_lsa_RefDomainList, nil) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_lsa_RefDomainList_ptr()") + stdnse.debug4("MSRPC: Leaving unmarshall_lsa_RefDomainList_ptr()") return pos, result end @@ -2274,12 +2274,12 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_lsa_TransSidArray2(data, pos) local result = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_lsa_TransSidArray2()") + stdnse.debug4("MSRPC: Entering unmarshall_lsa_TransSidArray2()") pos, result['count'] = unmarshall_int32(data, pos) pos, result['sid'] = unmarshall_ptr(ALL, data, pos, unmarshall_array, {result['count'], unmarshall_lsa_TranslatedSid2, {}}) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_lsa_TransSidArray2()") + stdnse.debug4("MSRPC: Leaving unmarshall_lsa_TransSidArray2()") return pos, result end @@ -2300,14 +2300,14 @@ end --@return A string representing the marshalled data. function marshall_lsa_QosInfo() local result = "" - stdnse.print_debug(4, "MSRPC: Entering marshall_lsa_QosInfo()") + stdnse.debug4("MSRPC: Entering marshall_lsa_QosInfo()") result = result .. marshall_int32(12) result = result .. marshall_int16(2, false) result = result .. marshall_int8(1, false) result = result .. marshall_int8(0, false) - stdnse.print_debug(4, "MSRPC: Leaving marshall_lsa_QosInfo()") + stdnse.debug4("MSRPC: Leaving marshall_lsa_QosInfo()") return result end @@ -2330,7 +2330,7 @@ end --@return A string representing the marshalled data. function marshall_lsa_ObjectAttribute() local result = "" - stdnse.print_debug(4, "MSRPC: Entering marshall_lsa_ObjectAttribute()") + stdnse.debug4("MSRPC: Entering marshall_lsa_ObjectAttribute()") result = result .. marshall_int32(24) result = result .. marshall_int32(0) -- Null'ing out these pointers for now. Maybe we'll need them in the future... @@ -2339,7 +2339,7 @@ function marshall_lsa_ObjectAttribute() result = result .. marshall_int32(0) result = result .. marshall_ptr(ALL, marshall_lsa_QosInfo, {}) - stdnse.print_debug(4, "MSRPC: Leaving marshall_lsa_ObjectAttribute()") + stdnse.debug4("MSRPC: Leaving marshall_lsa_ObjectAttribute()") return result end @@ -2359,11 +2359,11 @@ end --@return A string representing the marshalled data. local function marshall_lsa_SidPtr(location, sid) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_lsa_SidPtr()") + stdnse.debug4("MSRPC: Entering marshall_lsa_SidPtr()") result = marshall_ptr(location, marshall_dom_sid2, {sid}, sid) - stdnse.print_debug(4, "MSRPC: Leaving marshall_lsa_SidPtr()") + stdnse.debug4("MSRPC: Leaving marshall_lsa_SidPtr()") return result end @@ -2448,7 +2448,7 @@ end function marshall_lsa_TransNameArray2(names) local result = "" local array = {} - stdnse.print_debug(4, "MSRPC: Entering marshall_lsa_TransNameArray2()") + stdnse.debug4("MSRPC: Entering marshall_lsa_TransNameArray2()") if(names == nil) then result = result .. marshall_int32(0) @@ -2465,7 +2465,7 @@ function marshall_lsa_TransNameArray2(names) result = result .. marshall_ptr(ALL, marshall_array, {array}, array) - stdnse.print_debug(4, "MSRPC: Leaving marshall_lsa_TransNameArray2()") + stdnse.debug4("MSRPC: Leaving marshall_lsa_TransNameArray2()") return result end @@ -2477,12 +2477,12 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_lsa_TransNameArray2(data, pos) local result = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_lsa_TransNameArray2()") + stdnse.debug4("MSRPC: Entering unmarshall_lsa_TransNameArray2()") pos, result['count'] = unmarshall_int32(data, pos) pos, result['names'] = unmarshall_ptr(ALL, data, pos, unmarshall_array, {result['count'], unmarshall_lsa_TranslatedName2, {}}) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_lsa_TransNameArray2()") + stdnse.debug4("MSRPC: Leaving unmarshall_lsa_TransNameArray2()") return pos, result end @@ -2532,11 +2532,11 @@ local winreg_AccessMask_str = --@return A string representing the marshalled data. function marshall_winreg_AccessMask(accessmask) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_winreg_AccessMask()") + stdnse.debug4("MSRPC: Entering marshall_winreg_AccessMask()") result = marshall_Enum32(accessmask, winreg_AccessMask) - stdnse.print_debug(4, "MSRPC: Leaving marshall_winreg_AccessMask()") + stdnse.debug4("MSRPC: Leaving marshall_winreg_AccessMask()") return result end @@ -2547,11 +2547,11 @@ end --@return (pos, str) The new position, and the string representing the datatype. function unmarshall_winreg_AccessMask(data, pos) local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_winreg_AccessMask()") + stdnse.debug4("MSRPC: Entering unmarshall_winreg_AccessMask()") pos, str = unmarshall_Enum32(data, pos, winreg_AccessMask) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_winreg_AccessMask()") + stdnse.debug4("MSRPC: Leaving unmarshall_winreg_AccessMask()") return pos, str end @@ -2562,11 +2562,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function winreg_AccessMask_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering winreg_AccessMask_tostr()") + stdnse.debug4("MSRPC: Entering winreg_AccessMask_tostr()") result = winreg_AccessMask_str[val] - stdnse.print_debug(4, "MSRPC: Leaving winreg_AccessMask_tostr()") + stdnse.debug4("MSRPC: Leaving winreg_AccessMask_tostr()") return result end @@ -2612,11 +2612,11 @@ winreg_Type_str = -- found. function marshall_winreg_Type(winregtype) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_winreg_Type()") + stdnse.debug4("MSRPC: Entering marshall_winreg_Type()") result = marshall_Enum32(winregtype, winreg_Type) - stdnse.print_debug(4, "MSRPC: Leaving marshall_winreg_Type()") + stdnse.debug4("MSRPC: Leaving marshall_winreg_Type()") return result end @@ -2627,11 +2627,11 @@ end --@return (pos, str) The new position, and the string representing the datatype. function unmarshall_winreg_Type(data, pos) local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_winreg_Type()") + stdnse.debug4("MSRPC: Entering unmarshall_winreg_Type()") pos, str = unmarshall_Enum32(data, pos, winreg_Type) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_winreg_Type()") + stdnse.debug4("MSRPC: Leaving unmarshall_winreg_Type()") return pos, str end @@ -2643,11 +2643,11 @@ end -- found. function marshall_winreg_Type_ptr(winreg_type) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_winreg_Type_ptr()") + stdnse.debug4("MSRPC: Entering marshall_winreg_Type_ptr()") result = marshall_ptr(ALL, marshall_winreg_Type, {winreg_type}, winreg_type) - stdnse.print_debug(4, "MSRPC: Leaving marshall_winreg_Type_ptr()") + stdnse.debug4("MSRPC: Leaving marshall_winreg_Type_ptr()") return result end @@ -2658,11 +2658,11 @@ end --@return (pos, str) The new position, and the string representing the datatype. function unmarshall_winreg_Type_ptr(data, pos) local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_winreg_Type_ptr()") + stdnse.debug4("MSRPC: Entering unmarshall_winreg_Type_ptr()") pos, str = unmarshall_ptr(ALL, data, pos, unmarshall_winreg_Type, {}) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_winreg_Type_ptr()") + stdnse.debug4("MSRPC: Leaving unmarshall_winreg_Type_ptr()") return pos, str end @@ -2673,11 +2673,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function winreg_Type_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering winreg_Type_tostr()") + stdnse.debug4("MSRPC: Entering winreg_Type_tostr()") result = winreg_Type_str[val] - stdnse.print_debug(4, "MSRPC: Leaving winreg_Type_tostr()") + stdnse.debug4("MSRPC: Leaving winreg_Type_tostr()") return result end @@ -2700,7 +2700,7 @@ end --@return A string representing the marshalled data. function marshall_winreg_StringBuf(table, max_length) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_winreg_StringBuf()") + stdnse.debug4("MSRPC: Entering marshall_winreg_StringBuf()") local name = table['name'] local length @@ -2728,7 +2728,7 @@ function marshall_winreg_StringBuf(table, max_length) result = bin.pack("nil if it wasn't found. function srvsvc_ShareType_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering srvsvc_ShareType_tostr()") + stdnse.debug4("MSRPC: Entering srvsvc_ShareType_tostr()") result = srvsvc_ShareType_str[val] - stdnse.print_debug(4, "MSRPC: Leaving srvsvc_ShareType_tostr()") + stdnse.debug4("MSRPC: Leaving srvsvc_ShareType_tostr()") return result end @@ -2913,11 +2913,11 @@ end --@return A string representing the marshalled data. local function marshall_srvsvc_NetShareInfo0(location, name) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_srvsvc_NetShareInfo0()") + stdnse.debug4("MSRPC: Entering marshall_srvsvc_NetShareInfo0()") result = marshall_ptr(location, marshall_unicode, {name, true}, name) - stdnse.print_debug(4, "MSRPC: Leaving marshall_srvsvc_NetShareInfo0()") + stdnse.debug4("MSRPC: Leaving marshall_srvsvc_NetShareInfo0()") return result end @@ -2935,7 +2935,7 @@ end -- anything. --@return (pos, result) The new position in data, and a table representing the datatype. local function unmarshall_srvsvc_NetShareInfo0(location, data, pos, result) - stdnse.print_debug(4, "MSRPC: Entering unmarshall_srvsvc_NetShareInfo0()") + stdnse.debug4("MSRPC: Entering unmarshall_srvsvc_NetShareInfo0()") if(result == nil) then result = {} end @@ -2948,7 +2948,7 @@ local function unmarshall_srvsvc_NetShareInfo0(location, data, pos, result) pos, result['name'] = unmarshall_ptr(BODY, data, pos, unmarshall_unicode, {true}, result['name']) end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_srvsvc_NetShareInfo0()") + stdnse.debug4("MSRPC: Leaving unmarshall_srvsvc_NetShareInfo0()") return pos, result end @@ -2972,14 +2972,14 @@ end --@return A string representing the marshalled data. local function marshall_srvsvc_NetShareInfo1(location, name, sharetype, comment) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_srvsvc_NetShareInfo1()") + stdnse.debug4("MSRPC: Entering marshall_srvsvc_NetShareInfo1()") local name = marshall_ptr(location, marshall_unicode, {name, true}, name) local sharetype = marshall_basetype(location, marshall_srvsvc_ShareType, {sharetype}) local comment = marshall_ptr(location, marshall_unicode, {comment, true}, comment) result = bin.pack("data, and a table representing the datatype. local function unmarshall_srvsvc_NetShareInfo1(location, data, pos, result) - stdnse.print_debug(4, "MSRPC: Entering unmarshall_srvsvc_NetShareInfo1()") + stdnse.debug4("MSRPC: Entering unmarshall_srvsvc_NetShareInfo1()") if(result == nil) then result = {} end @@ -3014,7 +3014,7 @@ local function unmarshall_srvsvc_NetShareInfo1(location, data, pos, result) pos, result['comment'] = unmarshall_ptr(BODY, data, pos, unmarshall_unicode, {true}, result['comment']) end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_srvsvc_NetShareInfo1()") + stdnse.debug4("MSRPC: Leaving unmarshall_srvsvc_NetShareInfo1()") return pos, result end @@ -3049,7 +3049,7 @@ end --@return A string representing the marshalled data. local function marshall_srvsvc_NetShareInfo2(location, name, sharetype, comment, permissions, max_users, current_users, path, password) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_srvsvc_NetShareInfo2()") + stdnse.debug4("MSRPC: Entering marshall_srvsvc_NetShareInfo2()") local name = marshall_ptr(location, marshall_unicode, {name, true}, name) local sharetype = marshall_basetype(location, marshall_srvsvc_ShareType, {sharetype}) local comment = marshall_ptr(location, marshall_unicode, {comment, true}, comment) @@ -3061,7 +3061,7 @@ local function marshall_srvsvc_NetShareInfo2(location, name, sharetype, comment, result = name .. sharetype .. comment .. permissions .. max_users .. current_users .. path .. password - stdnse.print_debug(4, "MSRPC: Leaving marshall_srvsvc_NetShareInfo2()") + stdnse.debug4("MSRPC: Leaving marshall_srvsvc_NetShareInfo2()") return result end @@ -3080,7 +3080,7 @@ end -- anything. --@return (pos, result) The new position in data, and a table representing the datatype. local function unmarshall_srvsvc_NetShareInfo2(location, data, pos, result) - stdnse.print_debug(4, "MSRPC: Entering unmarshall_srvsvc_NetShareInfo2()") + stdnse.debug4("MSRPC: Entering unmarshall_srvsvc_NetShareInfo2()") if(result == nil) then result = {} end @@ -3103,7 +3103,7 @@ local function unmarshall_srvsvc_NetShareInfo2(location, data, pos, result) pos, result['password'] = unmarshall_ptr(BODY, data, pos, unmarshall_unicode, {true}, result['password']) end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_srvsvc_NetShareInfo2()") + stdnse.debug4("MSRPC: Leaving unmarshall_srvsvc_NetShareInfo2()") return pos, result end @@ -3121,7 +3121,7 @@ end function marshall_srvsvc_NetShareCtr0(NetShareCtr0) local i local result = "" - stdnse.print_debug(4, "MSRPC: Entering marshall_srvsvc_NetShareCtr0()") + stdnse.debug4("MSRPC: Entering marshall_srvsvc_NetShareCtr0()") if(NetShareCtr0 == nil) then result = result .. bin.pack("data, and a table representing the datatype. local function unmarshall_srvsvc_NetSessInfo10(location, data, pos, result) - stdnse.print_debug(4, "MSRPC: Entering unmarshall_srvsvc_NetSessInfo10()") + stdnse.debug4("MSRPC: Entering unmarshall_srvsvc_NetSessInfo10()") if(result == nil) then result = {} end @@ -3437,7 +3437,7 @@ local function unmarshall_srvsvc_NetSessInfo10(location, data, pos, result) pos, result['user'] = unmarshall_ptr(BODY, data, pos, unmarshall_unicode, {true}, result['user']) end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_srvsvc_NetSessInfo10()") + stdnse.debug4("MSRPC: Leaving unmarshall_srvsvc_NetSessInfo10()") return pos, result end @@ -3455,7 +3455,7 @@ end function marshall_srvsvc_NetSessCtr10(NetSessCtr10) local i local result = "" - stdnse.print_debug(4, "MSRPC: Entering marshall_srvsvc_NetSessCtr10()") + stdnse.debug4("MSRPC: Entering marshall_srvsvc_NetSessCtr10()") if(NetSessCtr10 == nil) then result = result .. bin.pack("data, and a table representing the datatype. function unmarshall_srvsvc_Statistics(data, pos) local response = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_srvsvc_Statistics()") + stdnse.debug4("MSRPC: Entering unmarshall_srvsvc_Statistics()") pos, response['start'] = unmarshall_int32(data, pos) pos, response['fopens'] = unmarshall_int32(data, pos) @@ -3613,7 +3613,7 @@ function unmarshall_srvsvc_Statistics(data, pos) pos, response['reqbufneed'] = unmarshall_int32(data, pos) pos, response['bigbufneed'] = unmarshall_int32(data, pos) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_srvsvc_Statistics()") + stdnse.debug4("MSRPC: Leaving unmarshall_srvsvc_Statistics()") return pos, response end @@ -3627,11 +3627,11 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_srvsvc_Statistics_ptr(data, pos) local result - stdnse.print_debug(4, "MSRPC: Entering unmarshall_srvsvc_Statistics_ptr()") + stdnse.debug4("MSRPC: Entering unmarshall_srvsvc_Statistics_ptr()") pos, result = unmarshall_ptr(ALL, data, pos, unmarshall_srvsvc_Statistics, {}) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_srvsvc_Statistics_ptr()") + stdnse.debug4("MSRPC: Leaving unmarshall_srvsvc_Statistics_ptr()") return pos, result end @@ -3669,11 +3669,11 @@ local samr_ConnectAccessMask_str = -- found. function marshall_samr_ConnectAccessMask(accessmask) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_samr_ConnectAccessMask()") + stdnse.debug4("MSRPC: Entering marshall_samr_ConnectAccessMask()") result = marshall_Enum32(accessmask, samr_ConnectAccessMask) - stdnse.print_debug(4, "MSRPC: Leaving marshall_samr_ConnectAccessMask()") + stdnse.debug4("MSRPC: Leaving marshall_samr_ConnectAccessMask()") return result end @@ -3684,11 +3684,11 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_samr_ConnectAccessMask(data, pos) local result - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_ConnectAccessMask()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_ConnectAccessMask()") pos, result = unmarshall_Enum32(data, pos, samr_ConnectAccessMask) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_ConnectAccessMask()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_ConnectAccessMask()") return pos, result end @@ -3699,11 +3699,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function samr_ConnectAccessMask_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering samr_ConnectAccessMask_tostr()") + stdnse.debug4("MSRPC: Entering samr_ConnectAccessMask_tostr()") result = samr_ConnectAccessMask_str[val] - stdnse.print_debug(4, "MSRPC: Leaving samr_ConnectAccessMask_tostr()") + stdnse.debug4("MSRPC: Leaving samr_ConnectAccessMask_tostr()") return result end @@ -3744,11 +3744,11 @@ local samr_DomainAccessMask_str = -- found. function marshall_samr_DomainAccessMask(accessmask) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_samr_DomainAccessMask()") + stdnse.debug4("MSRPC: Entering marshall_samr_DomainAccessMask()") result = marshall_Enum32(accessmask, samr_DomainAccessMask) - stdnse.print_debug(4, "MSRPC: Leaving marshall_samr_DomainAccessMask()") + stdnse.debug4("MSRPC: Leaving marshall_samr_DomainAccessMask()") return result end @@ -3759,11 +3759,11 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_samr_DomainAccessMask(data, pos) local result - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_DomainAccessMask()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_DomainAccessMask()") pos, result = unmarshall_Enum32(data, pos, samr_DomainAccessMask) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_DomainAccessMask()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_DomainAccessMask()") return pos, result end @@ -3774,11 +3774,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function samr_DomainAccessMask_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering samr_DomainAccessMask_tostr()") + stdnse.debug4("MSRPC: Entering samr_DomainAccessMask_tostr()") result = samr_DomainAccessMask_str[val] - stdnse.print_debug(4, "MSRPC: Leaving samr_DomainAccessMask_tostr()") + stdnse.debug4("MSRPC: Leaving samr_DomainAccessMask_tostr()") return result end @@ -3837,11 +3837,11 @@ local samr_AcctFlags_str = -- found. function marshall_samr_AcctFlags(flags) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_samr_AcctFlags()") + stdnse.debug4("MSRPC: Entering marshall_samr_AcctFlags()") result = marshall_Enum32(flags, samr_AcctFlags) - stdnse.print_debug(4, "MSRPC: Leaving marshall_samr_AcctFlags()") + stdnse.debug4("MSRPC: Leaving marshall_samr_AcctFlags()") return result end @@ -3852,11 +3852,11 @@ end --@return (pos, str) The new position, and the string representing the datatype. function unmarshall_samr_AcctFlags(data, pos) local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_AcctFlags()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_AcctFlags()") pos, str = unmarshall_Enum32_array(data, pos, samr_AcctFlags) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_AcctFlags()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_AcctFlags()") return pos, str end @@ -3867,11 +3867,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function samr_AcctFlags_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering samr_AcctFlags_tostr()") + stdnse.debug4("MSRPC: Entering samr_AcctFlags_tostr()") result = samr_AcctFlags_str[val] - stdnse.print_debug(4, "MSRPC: Leaving samr_AcctFlags_tostr()") + stdnse.debug4("MSRPC: Leaving samr_AcctFlags_tostr()") return result end @@ -3902,11 +3902,11 @@ local samr_PasswordProperties_str = -- found. function marshall_samr_PasswordProperties(properties) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_samr_PasswordProperties()") + stdnse.debug4("MSRPC: Entering marshall_samr_PasswordProperties()") result = marshall_Enum32(properties, samr_PasswordProperties) - stdnse.print_debug(4, "MSRPC: Leaving marshall_samr_PasswordProperties()") + stdnse.debug4("MSRPC: Leaving marshall_samr_PasswordProperties()") return result end @@ -3917,11 +3917,11 @@ end --@return (pos, str) The new position, and the string representing the datatype. function unmarshall_samr_PasswordProperties(data, pos) local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_PasswordProperties()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_PasswordProperties()") pos, str = unmarshall_Enum32_array(data, pos, samr_PasswordProperties) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_PasswordProperties()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_PasswordProperties()") return pos, str end @@ -3932,11 +3932,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function samr_PasswordProperties_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering samr_PasswordProperties_tostr()") + stdnse.debug4("MSRPC: Entering samr_PasswordProperties_tostr()") result = samr_PasswordProperties_str[val] - stdnse.print_debug(4, "MSRPC: Leaving samr_PasswordProperties_tostr()") + stdnse.debug4("MSRPC: Leaving samr_PasswordProperties_tostr()") return result end @@ -3962,7 +3962,7 @@ end -- anything. --@return (pos, result) The new position in data, and a table representing the datatype. local function unmarshall_samr_SamEntry(location, data, pos, result) - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_SamEntry()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_SamEntry()") if(result == nil) then result = {} end @@ -3977,7 +3977,7 @@ local function unmarshall_samr_SamEntry(location, data, pos, result) pos, result['name'] = unmarshall_lsa_String_internal(BODY, data, pos, result['name']) end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_SamEntry()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_SamEntry()") return pos, result end @@ -3995,12 +3995,12 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_samr_SamArray(data, pos) local result = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_SamArray()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_SamArray()") pos, result['count'] = unmarshall_int32(data, pos) pos, result['entries'] = unmarshall_ptr(ALL, data, pos, unmarshall_array, {result['count'], unmarshall_samr_SamEntry, {}}) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_SamArray()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_SamArray()") return pos, result end @@ -4012,11 +4012,11 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_samr_SamArray_ptr(data, pos) local result - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_SamArray_ptr()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_SamArray_ptr()") pos, result = unmarshall_ptr(ALL, data, pos, unmarshall_samr_SamArray, {}) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_SamArray_ptr()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_SamArray_ptr()") return pos, result end @@ -4045,7 +4045,7 @@ end -- anything. --@return (pos, result) The new position in data, and a table representing the datatype. local function unmarshall_samr_DispEntryGeneral(location, data, pos, result) - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_DispEntryGeneral()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_DispEntryGeneral()") if(result == nil) then result = {} end @@ -4066,7 +4066,7 @@ local function unmarshall_samr_DispEntryGeneral(location, data, pos, result) pos, result['full_name'] = unmarshall_lsa_String_internal(BODY, data, pos, result['full_name']) end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_DispEntryGeneral()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_DispEntryGeneral()") return pos, result end @@ -4084,12 +4084,12 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_samr_DispInfoGeneral(data, pos) local result = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_DispInfoGeneral()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_DispInfoGeneral()") pos, result['count'] = unmarshall_int32(data, pos) pos, result['entries'] = unmarshall_ptr(ALL, data, pos, unmarshall_array, {result['count'], unmarshall_samr_DispEntryGeneral, {}}) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_DispInfoGeneral()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_DispInfoGeneral()") return pos, result end @@ -4113,18 +4113,18 @@ end function unmarshall_samr_DispInfo(data, pos) local level local result - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_DispInfo()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_DispInfo()") pos, level = unmarshall_int16(data, pos) if(level == 1) then pos, result = unmarshall_samr_DispInfoGeneral(data, pos) else - stdnse.print_debug(1, "MSRPC: ERROR: Server returned an unknown level for samr_DispInfo: %d", level) + stdnse.debug1("MSRPC: ERROR: Server returned an unknown level for samr_DispInfo: %d", level) pos, result = nil, nil end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_DispInfo()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_DispInfo()") return pos, result end @@ -4146,7 +4146,7 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_samr_DomInfo1(data, pos) local result = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_DomInfo1()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_DomInfo1()") pos, result['min_password_length'] = unmarshall_int16(data, pos, false) pos, result['password_history_length'] = unmarshall_int16(data, pos, false) @@ -4154,7 +4154,7 @@ function unmarshall_samr_DomInfo1(data, pos) pos, result['max_password_age'] = unmarshall_hyper(data, pos) pos, result['min_password_age'] = unmarshall_hyper(data, pos) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_DomInfo1()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_DomInfo1()") return pos, result end @@ -4172,12 +4172,12 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_samr_DomInfo8(data, pos) local result = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_DomInfo8()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_DomInfo8()") pos, result['sequence_num'] = unmarshall_hyper(data, pos) pos, result['domain_create_time'] = unmarshall_NTTIME(data, pos) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_DomInfo8()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_DomInfo8()") return pos, result end @@ -4196,13 +4196,13 @@ end --@return (pos, result) The new position in data, and a table representing the datatype. function unmarshall_samr_DomInfo12(data, pos) local result = {} - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_DomInfo12()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_DomInfo12()") pos, result['lockout_duration'] = unmarshall_hyper(data, pos) pos, result['lockout_window'] = unmarshall_hyper(data, pos) pos, result['lockout_threshold'] = unmarshall_int16(data, pos) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_DomInfo12()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_DomInfo12()") return pos, result end @@ -4232,7 +4232,7 @@ end function unmarshall_samr_DomainInfo(data, pos) local level local result - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_DomainInfo()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_DomainInfo()") pos, level = unmarshall_int16(data, pos) @@ -4243,11 +4243,11 @@ function unmarshall_samr_DomainInfo(data, pos) elseif(level == 12) then pos, result = unmarshall_samr_DomInfo12(data, pos) else - stdnse.print_debug(1, "MSRPC: ERROR: Server returned an unknown level for samr_DomainInfo: %d", level) + stdnse.debug1("MSRPC: ERROR: Server returned an unknown level for samr_DomainInfo: %d", level) pos, result = nil, nil end - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_DomainInfo()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_DomainInfo()") return pos, result end @@ -4260,11 +4260,11 @@ end -- nil if there was an error. function unmarshall_samr_DomainInfo_ptr(data, pos) local result - stdnse.print_debug(4, "MSRPC: Entering unmarshall_samr_DomainInfo_ptr()") + stdnse.debug4("MSRPC: Entering unmarshall_samr_DomainInfo_ptr()") pos, result = unmarshall_ptr(ALL, data, pos, unmarshall_samr_DomainInfo, {}) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_samr_DomainInfo_ptr()") + stdnse.debug4("MSRPC: Leaving unmarshall_samr_DomainInfo_ptr()") return pos, result end @@ -4328,11 +4328,11 @@ local svcctl_ControlCode_str = -- found. function marshall_svcctl_ControlCode(flags) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_svcctl_ControlCode()") + stdnse.debug4("MSRPC: Entering marshall_svcctl_ControlCode()") result = marshall_Enum32(flags, svcctl_ControlCode) - stdnse.print_debug(4, "MSRPC: Leaving marshall_svcctl_ControlCode()") + stdnse.debug4("MSRPC: Leaving marshall_svcctl_ControlCode()") return result end @@ -4343,11 +4343,11 @@ end --@return (pos, str) The new position, and the string representing the datatype. function unmarshall_svcctl_ControlCode(data, pos) local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_svcctl_ControlCode()") + stdnse.debug4("MSRPC: Entering unmarshall_svcctl_ControlCode()") pos, str = unmarshall_Enum32_array(data, pos, svcctl_ControlCode) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_svcctl_ControlCode()") + stdnse.debug4("MSRPC: Leaving unmarshall_svcctl_ControlCode()") return pos, str end @@ -4358,11 +4358,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function svcctl_ControlCode_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering svcctl_ControlCode_tostr()") + stdnse.debug4("MSRPC: Entering svcctl_ControlCode_tostr()") result = svcctl_ControlCode_str[val] - stdnse.print_debug(4, "MSRPC: Leaving svcctl_ControlCode_tostr()") + stdnse.debug4("MSRPC: Leaving svcctl_ControlCode_tostr()") return result end @@ -4386,11 +4386,11 @@ local svcctl_Type = -- found. function marshall_svcctl_Type(flags) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_svcctl_Type()") + stdnse.debug4("MSRPC: Entering marshall_svcctl_Type()") result = marshall_Enum32(flags, svcctl_Type) - stdnse.print_debug(4, "MSRPC: Leaving marshall_svcctl_Type()") + stdnse.debug4("MSRPC: Leaving marshall_svcctl_Type()") return result end @@ -4401,11 +4401,11 @@ end --@return (pos, str) The new position, and the string representing the datatype. function unmarshall_svcctl_Type(data, pos) local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_svcctl_Type()") + stdnse.debug4("MSRPC: Entering unmarshall_svcctl_Type()") pos, str = unmarshall_Enum32_array(data, pos, svcctl_Type) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_svcctl_Type()") + stdnse.debug4("MSRPC: Leaving unmarshall_svcctl_Type()") return pos, str end @@ -4416,11 +4416,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function svcctl_Type_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering svcctl_Type_tostr()") + stdnse.debug4("MSRPC: Entering svcctl_Type_tostr()") result = svcctl_Type_str[val] - stdnse.print_debug(4, "MSRPC: Leaving svcctl_Type_tostr()") + stdnse.debug4("MSRPC: Leaving svcctl_Type_tostr()") return result end]]-- @@ -4440,11 +4440,11 @@ local svcctl_State = -- found. function marshall_svcctl_State(flags) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_svcctl_State()") + stdnse.debug4("MSRPC: Entering marshall_svcctl_State()") result = marshall_Enum32(flags, svcctl_State) - stdnse.print_debug(4, "MSRPC: Leaving marshall_svcctl_State()") + stdnse.debug4("MSRPC: Leaving marshall_svcctl_State()") return result end @@ -4455,11 +4455,11 @@ end --@return (pos, str) The new position, and the string representing the datatype. function unmarshall_svcctl_State(data, pos) local str - stdnse.print_debug(4, "MSRPC: Entering unmarshall_svcctl_State()") + stdnse.debug4("MSRPC: Entering unmarshall_svcctl_State()") pos, str = unmarshall_Enum32_array(data, pos, svcctl_State) - stdnse.print_debug(4, "MSRPC: Leaving unmarshall_svcctl_State()") + stdnse.debug4("MSRPC: Leaving unmarshall_svcctl_State()") return pos, str end @@ -4470,11 +4470,11 @@ end --@return A string suitable for displaying to the user, or nil if it wasn't found. function svcctl_State_tostr(val) local result - stdnse.print_debug(4, "MSRPC: Entering svcctl_State_tostr()") + stdnse.debug4("MSRPC: Entering svcctl_State_tostr()") result = svcctl_State_str[val] - stdnse.print_debug(4, "MSRPC: Leaving svcctl_State_tostr()") + stdnse.debug4("MSRPC: Leaving svcctl_State_tostr()") return result end]]-- @@ -4556,11 +4556,11 @@ local atsvc_DaysOfMonth = -- found. function marshall_atsvc_DaysOfMonth(flags) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_atsvc_DaysOfMonth()") + stdnse.debug4("MSRPC: Entering marshall_atsvc_DaysOfMonth()") result = marshall_Enum32(flags, atsvc_DaysOfMonth) - stdnse.print_debug(4, "MSRPC: Leaving marshall_atsvc_DaysOfMonth()") + stdnse.debug4("MSRPC: Leaving marshall_atsvc_DaysOfMonth()") return result end @@ -4581,11 +4581,11 @@ local atsvc_Flags = -- found. function marshall_atsvc_Flags(flags) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_atsvc_Flags()") + stdnse.debug4("MSRPC: Entering marshall_atsvc_Flags()") result = marshall_Enum8(flags, atsvc_Flags, false) - stdnse.print_debug(4, "MSRPC: Leaving marshall_atsvc_Flags()") + stdnse.debug4("MSRPC: Leaving marshall_atsvc_Flags()") return result end @@ -4608,11 +4608,11 @@ local atsvc_DaysOfWeek = -- found. function marshall_atsvc_DaysOfWeek(flags) local result - stdnse.print_debug(4, "MSRPC: Entering marshall_atsvc_DaysOfWeek()") + stdnse.debug4("MSRPC: Entering marshall_atsvc_DaysOfWeek()") result = marshall_Enum8(flags, atsvc_DaysOfWeek, false) - stdnse.print_debug(4, "MSRPC: Leaving marshall_atsvc_DaysOfWeek()") + stdnse.debug4("MSRPC: Leaving marshall_atsvc_DaysOfWeek()") return result end diff --git a/nselib/mssql.lua b/nselib/mssql.lua index 79f518ffc..2ae45b8e4 100644 --- a/nselib/mssql.lua +++ b/nselib/mssql.lua @@ -293,7 +293,7 @@ SqlServerVersionInfo = elseif versionNumber:match( "^%d+%.%d+%.%d+" ) then major, minor, revision = versionNumber:match( "^(%d+)%.(%d+)%.(%d+)" ) else - stdnse.print_debug( 1, "%s: SetVersionNumber: versionNumber is not in correct format: %s", "MSSQL", versionNumber or "nil" ) + stdnse.debug1("%s: SetVersionNumber: versionNumber is not in correct format: %s", "MSSQL", versionNumber or "nil" ) end self:SetVersion( major, minor, revision, subBuild, source ) @@ -534,7 +534,7 @@ SSRP = table.insert( instanceStrings, instanceString ) until (not firstInstanceEnd) - stdnse.print_debug( 2, "%s: SSRP Substrings:\n %s", SSRP.DEBUG_ID, stdnse.strjoin( "\n ", instanceStrings ) ) + stdnse.debug2("%s: SSRP Substrings:\n %s", SSRP.DEBUG_ID, stdnse.strjoin( "\n ", instanceStrings ) ) local instances = {} for _, instanceString in ipairs( instanceStrings ) do @@ -556,7 +556,7 @@ SSRP = if status then pipeName = namedpipes.make_pipe_name( host.ip, pipeSubPath ) elseif pipeName ~= nil then - stdnse.print_debug( 1, "%s: Invalid pipe name:\n%s", SSRP.DEBUG_ID, pipeName ) + stdnse.debug1("%s: Invalid pipe name:\n%s", SSRP.DEBUG_ID, pipeName ) end instance.pipeName = pipeName @@ -574,11 +574,11 @@ SSRP = pos, messageType, dataLength = bin.unpack("SS", bytes, pos) if not (optionPos and optionLength) then - stdnse.print_debug( 2, "%s: Could not unpack optionPos and optionLength.", "MSSQL" ) + stdnse.debug2("%s: Could not unpack optionPos and optionLength.", "MSSQL" ) return false, "Invalid pre-login response" end optionPos = optionPos + 1 -- convert from 0-based index to 1-based index if ( (optionPos + optionLength) > (#bytes + 1) ) then - stdnse.print_debug( 2, "%s: Pre-login response: pos+len for option type %s is beyond end of data.", "MSSQL", optionType ) - stdnse.print_debug( 2, "%s: (optionPos: %s) (optionLength: %s)", "MSSQL", optionPos, optionLength ) + stdnse.debug2("%s: Pre-login response: pos+len for option type %s is beyond end of data.", "MSSQL", optionType ) + stdnse.debug2("%s: (optionPos: %s) (optionLength: %s)", "MSSQL", optionPos, optionLength ) return false, "Invalid pre-login response" end if ( optionLength ~= expectedOptionLength and expectedOptionLength ~= -1 ) then - stdnse.print_debug( 2, "%s: Option data is incorrect size in pre-login response. ", "MSSQL" ) - stdnse.print_debug( 2, "%s: (optionType: %s) (optionLength: %s)", "MSSQL", optionType, optionLength ) + stdnse.debug2("%s: Option data is incorrect size in pre-login response. ", "MSSQL" ) + stdnse.debug2("%s: (optionType: %s) (optionLength: %s)", "MSSQL", optionType, optionLength ) return false, "Invalid pre-login response" end optionData = bytes:sub( optionPos, optionPos + optionLength - 1 ) if #optionData ~= optionLength then - stdnse.print_debug( 2, "%s: Could not read sufficient bytes from version data.", "MSSQL" ) + stdnse.debug2("%s: Could not read sufficient bytes from version data.", "MSSQL" ) return false, "Invalid pre-login response" end @@ -1961,14 +1961,14 @@ TDSStream = { end local status, result, connectionType, errorMessage - stdnse.print_debug( 3, "%s: Connection preferences for %s: %s", + stdnse.debug3("%s: Connection preferences for %s: %s", "MSSQL", instanceInfo:GetName(), stdnse.strjoin( ", ", connectionPreference ) ) for _, connectionType in ipairs( connectionPreference ) do if connectionType == "TCP" then if not ( instanceInfo.port ) then - stdnse.print_debug( 3, "%s: Cannot connect to %s via TCP because port table is not set.", + stdnse.debug3("%s: Cannot connect to %s via TCP because port table is not set.", "MSSQL", instanceInfo:GetName() ) result = "No TCP port for this instance" else @@ -1979,7 +1979,7 @@ TDSStream = { elseif connectionType == "Named Pipes" or connectionType == "NP" then if not ( instanceInfo.pipeName ) then - stdnse.print_debug( 3, "%s: Cannot connect to %s via named pipes because pipe name is not set.", + stdnse.debug3("%s: Cannot connect to %s via named pipes because pipe name is not set.", "MSSQL", instanceInfo:GetName() ) result = "No named pipe for this instance" else @@ -1988,7 +1988,7 @@ TDSStream = { end else - stdnse.print_debug( 1, "%s: Unknown connection preference: %s", "MSSQL", connectionType ) + stdnse.debug1("%s: Unknown connection preference: %s", "MSSQL", connectionType ) return false, ("ERROR: Unknown connection preference: %s"):format(connectionType) end @@ -2023,7 +2023,7 @@ TDSStream = { if ( self._socket ) then return false, "Already connected via TCP" end if ( SCANNED_PORTS_ONLY and smb.get_port( host ) == nil ) then - stdnse.print_debug( 2, "%s: Connection disallowed: scanned-ports-only is set and no SMB port is available", "MSSQL" ) + stdnse.debug2("%s: Connection disallowed: scanned-ports-only is set and no SMB port is available", "MSSQL" ) return false, "Connection disallowed: scanned-ports-only" end @@ -2050,7 +2050,7 @@ TDSStream = { if ( self._pipe ) then return false, "Already connected via named pipes" end if ( SCANNED_PORTS_ONLY and nmap.get_port_state( host, port ) == nil ) then - stdnse.print_debug( 2, "%s: Connection disallowed: scanned-ports-only is set and port %d was not scanned", "MSSQL", port.number ) + stdnse.debug2("%s: Connection disallowed: scanned-ports-only is set and port %d was not scanned", "MSSQL", port.number ) return false, "Connection disallowed: scanned-ports-only" end @@ -2075,7 +2075,7 @@ TDSStream = { if ( not(status) ) then self._socket = nil - stdnse.print_debug( 2, "%s: Socket connection failed on %s:%s", "MSSQL", host.ip, port.number ) + stdnse.debug2("%s: Socket connection failed on %s:%s", "MSSQL", host.ip, port.number ) return false, "Socket connection failed" end self._name = string.format( "%s:%s", host.ip, port.number ) @@ -2191,7 +2191,7 @@ TDSStream = { -- TDS packet validity check: packet at least as long as the TDS header if ( readBuffer:len() < 8 ) then - stdnse.print_debug( 2, "%s: Receiving (%s): packet is invalid length", "MSSQL", self._name ) + stdnse.debug2("%s: Receiving (%s): packet is invalid length", "MSSQL", self._name ) return false, "Server returned invalid packet" end @@ -2201,7 +2201,7 @@ TDSStream = { -- TDS packet validity check: packet type is Response (0x4) if ( packetType ~= PacketType.Response ) then - stdnse.print_debug( 2, "%s: Receiving (%s): Expected type 0x4 (response), but received type 0x%x", + stdnse.debug2("%s: Receiving (%s): Expected type 0x4 (response), but received type 0x%x", "MSSQL", self._name, packetType ) return false, "Server returned invalid packet" end @@ -2228,7 +2228,7 @@ TDSStream = { -- TDS packet validity check: packet length matches length from header if ( packetLength ~= (thisPacketData:len() + 8) ) then - stdnse.print_debug( 2, "%s: Receiving (%s): Header reports length %d, actual length is %d", + stdnse.debug2("%s: Receiving (%s): Header reports length %d, actual length is %d", "MSSQL", self._name, packetLength, thisPacketData:len() ) return false, "Server returned invalid packet" end @@ -2490,7 +2490,7 @@ Helper = Helper.AddOrMergeInstance( instance ) table.insert( instances_host, instance ) else - stdnse.print_debug( 3, "DiscoverBySmb \n pipe: %s\n result: %s", pipeSubPath, tostring( result ) ) + stdnse.debug3("DiscoverBySmb \n pipe: %s\n result: %s", pipeSubPath, tostring( result ) ) end end @@ -2853,7 +2853,7 @@ Helper = status, response = tdsStream:ConnectEx( instanceInfo ) if ( not status ) then - stdnse.print_debug( 2, "%s: Connection to %s failed: %s", "MSSQL", instanceInfo:GetName(), response or "" ) + stdnse.debug2("%s: Connection to %s failed: %s", "MSSQL", instanceInfo:GetName(), response or "" ) return false, "Connect failed" end @@ -2873,12 +2873,12 @@ Helper = if status then version = preLoginResponse.versionInfo else - stdnse.print_debug( 2, "%s: Parsing of pre-login packet from %s failed: %s", + stdnse.debug2("%s: Parsing of pre-login packet from %s failed: %s", "MSSQL", instanceInfo:GetName(), preLoginResponse or "" ) return false, "Parsing failed" end else - stdnse.print_debug( 2, "%s: Receive for %s failed: %s", "MSSQL", instanceInfo:GetName(), response or "" ) + stdnse.debug2("%s: Receive for %s failed: %s", "MSSQL", instanceInfo:GetName(), response or "" ) return false, "Receive failed" end @@ -2925,7 +2925,7 @@ Helper = end if ( not Helper.WasDiscoveryPerformed( host ) ) then - stdnse.print_debug( 2, "%s: Discovery has not been performed prior to GetTargetInstances() call. Performing discovery now.", "MSSQL" ) + stdnse.debug2("%s: Discovery has not been performed prior to GetTargetInstances() call. Performing discovery now.", "MSSQL" ) Helper.Discover( host ) end @@ -3078,7 +3078,7 @@ Auth = { LmResponse = function( password, nonce ) if ( not(HAVE_SSL) ) then - stdnse.print_debug("ERROR: Nmap is missing OpenSSL") + stdnse.debug1("ERROR: Nmap is missing OpenSSL") return end diff --git a/nselib/mysql.lua b/nselib/mysql.lua index 7b021a3ce..c18f83832 100644 --- a/nselib/mysql.lua +++ b/nselib/mysql.lua @@ -106,7 +106,7 @@ end -- status or error message on failure (status == false) function receiveGreeting( socket ) - local catch = function() socket:close() stdnse.print_debug("receiveGreeting(): failed") end + local catch = function() socket:close() stdnse.debug1("receiveGreeting(): failed") end local try = nmap.new_try(catch) local data = try( socket:receive_bytes(HEADER_SIZE) ) local pos, response, tmp, _ @@ -193,7 +193,7 @@ end -- @return response table or error message on failure function loginRequest( socket, params, username, password, salt ) - local catch = function() socket:close() stdnse.print_debug("loginRequest(): failed") end + local catch = function() socket:close() stdnse.debug1("loginRequest(): failed") end local try = nmap.new_try(catch) local packetno = 1 local authversion = params.authversion or "post41" @@ -330,7 +330,7 @@ end -- @return table containing the following header, fields and data function decodeQueryResponse( socket ) - local catch = function() socket:close() stdnse.print_debug("decodeQueryResponse(): failed") end + local catch = function() socket:close() stdnse.debug1("decodeQueryResponse(): failed") end local try = nmap.new_try(catch) local data, header, pos local rs, blocks = {}, {} @@ -492,7 +492,7 @@ end -- @return rows table containing row tables as decoded by decodeDataPackets function sqlQuery( socket, query ) - local catch = function() socket:close() stdnse.print_debug("sqlQuery(): failed") end + local catch = function() socket:close() stdnse.debug1("sqlQuery(): failed") end local try = nmap.new_try(catch) local packetno = 0 local querylen = query:len() + 1 diff --git a/nselib/ncp.lua b/nselib/ncp.lua index 083cb4d42..c808364aa 100644 --- a/nselib/ncp.lua +++ b/nselib/ncp.lua @@ -587,7 +587,7 @@ Response = { if ( self.data ) then local len = #self.data - pos if ( ( #self.data - pos ) ~= ( self.length - 33 ) ) then - stdnse.print_debug("NCP packet length mismatched") + stdnse.debug1("NCP packet length mismatched") return end end diff --git a/nselib/netbios.lua b/nselib/netbios.lua index d7db82f75..e6e5804e2 100644 --- a/nselib/netbios.lua +++ b/nselib/netbios.lua @@ -41,7 +41,7 @@ types = { -- (eg. "\x20FEEFFDFEDBCACACACACACACACACAAA\x08insecure\x03org") function name_encode(name, scope) - stdnse.print_debug(3, "Encoding name '%s'", name) + stdnse.debug3("Encoding name '%s'", name) -- Truncate or pad the string to 16 bytes if(#name >= 16) then name = string.sub(name, 1, 16) @@ -78,7 +78,7 @@ function name_encode(name, scope) end end - stdnse.print_debug(3, "=> '%s'", L2_encoded) + stdnse.debug3("=> '%s'", L2_encoded) return L2_encoded end @@ -98,7 +98,7 @@ function name_decode(encoded_name) local len = string.byte(encoded_name, 1) local i - stdnse.print_debug(3, "Decoding name '%s'", encoded_name) + stdnse.debug3("Decoding name '%s'", encoded_name) for i = 2, len + 1, 2 do local ch = 0 @@ -121,7 +121,7 @@ function name_decode(encoded_name) scope = string.sub(scope, 1, #scope - 1) end - stdnse.print_debug(3, "=> '%s'", name) + stdnse.debug3("=> '%s'", name) return name, scope end @@ -272,12 +272,12 @@ function do_nbstat(host) local statistics local reg if type(host) == "string" then --ip - stdnse.print_debug(3, "Performing nbstat on host '%s'", host) + stdnse.debug3("Performing nbstat on host '%s'", host) nmap.registry.netbios = nmap.registry.netbios or {} nmap.registry.netbios[host] = nmap.registry.netbios[host] or {} reg = nmap.registry.netbios[host] else - stdnse.print_debug(3, "Performing nbstat on host '%s'", host.ip) + stdnse.debug3("Performing nbstat on host '%s'", host.ip) if host.registry.netbios == nil and nmap.registry.netbios ~= nil and nmap.registry.netbios[host.ip] ~= nil then @@ -289,7 +289,7 @@ function do_nbstat(host) -- Check if it's cached in the registry for this host if(reg["nbstat_names"] ~= nil) then - stdnse.print_debug(3, " |_ [using cached value]") + stdnse.debug3(" |_ [using cached value]") return true, reg["nbstat_names"], reg["nbstat_statistics"] end diff --git a/nselib/nsedebug.lua b/nselib/nsedebug.lua index 00af858e2..d14e335b7 100644 --- a/nselib/nsedebug.lua +++ b/nselib/nsedebug.lua @@ -54,7 +54,7 @@ function tostr(data, indent) end end else - stdnse.print_debug(1, "Error: unknown data type: %s", type(data)) + stdnse.debug1("Error: unknown data type: %s", type(data)) end return table.concat(str) diff --git a/nselib/omp2.lua b/nselib/omp2.lua index e61b4c7e2..74d731cc5 100644 --- a/nselib/omp2.lua +++ b/nselib/omp2.lua @@ -81,13 +81,13 @@ Session = { .. "") if not status then - stdnse.print_debug("ERROR: %s", err) + stdnse.debug1("ERROR: %s", err) return false, err end status, xmldata = self.socket:receive() if not status then - stdnse.print_debug("ERROR: %s", xmldata) + stdnse.debug1("ERROR: %s", xmldata) return false, xmldata end @@ -102,13 +102,13 @@ Session = { status, err = self.socket:send("") if not status then - stdnse.print_debug("ERROR: %s", err) + stdnse.debug1("ERROR: %s", err) return false, err end status, xmldata = self.socket:receive() if not status then - stdnse.print_debug("ERROR: %s", xmldata) + stdnse.debug1("ERROR: %s", xmldata) return false, xmldata end diff --git a/nselib/ospf.lua b/nselib/ospf.lua index b93f7a937..4bd4dcdf2 100644 --- a/nselib/ospf.lua +++ b/nselib/ospf.lua @@ -72,7 +72,7 @@ OSPF = { _, header.auth_data.hash = bin.unpack(">H"..header.auth_data.length, data, header.length+1) else -- Shouldn't happen - stdnse.print_debug("Unknown authentication type " .. header.auth_type) + stdnse.debug1("Unknown authentication type " .. header.auth_type) return nil end header.router_id = ipOps.fromdword(header.router_id) @@ -188,7 +188,7 @@ OSPF = { hello.BDR = ipOps.fromdword(hello.BDR) if ( ( #data - pos + 1 ) % 4 ~= 0 ) then - stdnse.print_debug(2, "Unexpected OSPF packet length, aborting ...") + stdnse.debug2("Unexpected OSPF packet length, aborting ...") return end diff --git a/nselib/packet.lua b/nselib/packet.lua index ed96694a5..a5a03c649 100644 --- a/nselib/packet.lua +++ b/nselib/packet.lua @@ -249,7 +249,7 @@ function Packet:new(packet, packet_len, force_continue) if o.ip_v == 6 then while o:ipv6_is_extension_header() do if not o:ipv6_ext_header_parse(force_continue) or o.ip6_data_offset >= o.packet_len then - stdnse.print_debug("Error while parsing IPv6 extension headers.") + stdnse.debug1("Error while parsing IPv6 extension headers.") return o end end @@ -258,19 +258,19 @@ function Packet:new(packet, packet_len, force_continue) if o.ip_p == IPPROTO_TCP then if not o:tcp_parse(force_continue) then - stdnse.print_debug("Error while parsing TCP packet\n") + stdnse.debug1("Error while parsing TCP packet\n") end elseif o.ip_p == IPPROTO_UDP then if not o:udp_parse(force_continue) then - stdnse.print_debug("Error while parsing UDP packet\n") + stdnse.debug1("Error while parsing UDP packet\n") end elseif o.ip_p == IPPROTO_ICMP then if not o:icmp_parse(force_continue) then - stdnse.print_debug("Error while parsing ICMP packet\n") + stdnse.debug1("Error while parsing ICMP packet\n") end elseif o.ip_p == IPPROTO_ICMPV6 then if not o:icmpv6_parse(force_continue) then - stdnse.print_debug("Error while parsing ICMPv6 packet\n") + stdnse.debug1("Error while parsing ICMPv6 packet\n") end end return o diff --git a/nselib/pgsql.lua b/nselib/pgsql.lua index d9d6e1647..88c023f3f 100644 --- a/nselib/pgsql.lua +++ b/nselib/pgsql.lua @@ -89,7 +89,7 @@ v2 = elseif ( authtype == 0 ) then response.success = true else - stdnse.print_debug("unknown auth type: %d", authtype) + stdnse.debug1("unknown auth type: %d", authtype) end response.authtype = authtype @@ -138,7 +138,7 @@ v2 = return pos, response end else - stdnse.print_debug("Missing decoder for %d", ptype) + stdnse.debug1("Missing decoder for %d", ptype) return -1, ("Missing decoder for %d"):format(ptype) end return -1, "Decoding failed" @@ -159,7 +159,7 @@ v2 = local tmp = "" local ptype, len - local catch = function() socket:close() stdnse.print_debug("processResponse(): failed") end + local catch = function() socket:close() stdnse.debug1("processResponse(): failed") end local try = nmap.new_try(catch) if ( data == nil or data:len() == 0 ) then @@ -218,7 +218,7 @@ v2 = -- result string containing an error message if login fails loginRequest = function ( socket, params, username, password, salt ) - local catch = function() socket:close() stdnse.print_debug("loginRequest(): failed") end + local catch = function() socket:close() stdnse.debug1("loginRequest(): failed") end local try = nmap.new_try(catch) local response = {} local status, data, len, pos, tmp @@ -283,7 +283,7 @@ v3 = elseif ( authtype == 0 ) then response.success = true else - stdnse.print_debug( "unknown auth type: %d", authtype ) + stdnse.debug1("unknown auth type: %d", authtype ) end response.authtype = authtype @@ -397,7 +397,7 @@ v3 = local ptype, len local header - local catch = function() socket:close() stdnse.print_debug("processResponse(): failed") end + local catch = function() socket:close() stdnse.debug1("processResponse(): failed") end local try = nmap.new_try(catch) if ( data:len() - pos < 5 ) then @@ -455,7 +455,7 @@ v3 = return pos, response end else - stdnse.print_debug( "Missing decoder for %d", header.type ) + stdnse.debug1("Missing decoder for %d", header.type ) return -1, ("Missing decoder for %d"):format(header.type) end return -1, "Decoding failed" @@ -474,7 +474,7 @@ v3 = -- result string containing an error message if login fails loginRequest = function ( socket, params, username, password, salt ) - local catch = function() socket:close() stdnse.print_debug("loginRequest(): failed") end + local catch = function() socket:close() stdnse.debug1("loginRequest(): failed") end local try = nmap.new_try(catch) local response, header = {}, {} local status, data, len, tmp, _ @@ -601,7 +601,7 @@ function printErrorMessage( dberror ) return end for k, v in pairs(dberror) do - stdnse.print_debug("%s=%s", k, v) + stdnse.debug1("%s=%s", k, v) end end diff --git a/nselib/pppoe.lua b/nselib/pppoe.lua index fccd4403f..63dffb2e0 100644 --- a/nselib/pppoe.lua +++ b/nselib/pppoe.lua @@ -496,7 +496,7 @@ PPPoE = { if ( PPPoE.TagDecoder[tag] ) then pos, decoded = PPPoE.TagDecoder[tag](data, pos, len) else - stdnse.print_debug("PPPoE: Unsupported tag (%d)", tag) + stdnse.debug1("PPPoE: Unsupported tag (%d)", tag) pos = pos + len end local t = PPPoE.Tag:new(tag, raw) diff --git a/nselib/proxy.lua b/nselib/proxy.lua index 7ca0cd753..00c704695 100644 --- a/nselib/proxy.lua +++ b/nselib/proxy.lua @@ -100,7 +100,7 @@ function test_get(host, port, proxyType, test_url, hostname, pattern) return false, socket end local req = "GET " .. test_url .. " HTTP/1.0\r\nHost: " .. hostname .. "\r\n\r\n" - stdnse.print_debug("GET Request: " .. req) + stdnse.debug1("GET Request: " .. req) return test(socket, req, pattern) end @@ -118,7 +118,7 @@ function test_head(host, port, proxyType, test_url, hostname, pattern) return false, socket end local req = "HEAD " .. test_url .. " HTTP/1.0\r\nHost: " .. hostname .. "\r\n\r\n" - stdnse.print_debug("HEAD Request: " .. req) + stdnse.debug1("HEAD Request: " .. req) return test(socket, req, pattern) end @@ -134,7 +134,7 @@ function test_connect(host, port, proxyType, hostname) return false, socket end local req = "CONNECT " .. hostname .. ":80 HTTP/1.0\r\n\r\n" - stdnse.print_debug("CONNECT Request: " .. req) + stdnse.debug1("CONNECT Request: " .. req) return test(socket, req, false) end @@ -262,7 +262,7 @@ function socksHandshake(socket, version, hostname) err = "Authentication Required" else -- If no Auth is required, try to establish connection - stdnse.print_debug("Socks5: No authentication required") + stdnse.debug1("Socks5: No authentication required") -- Socks5 second payload: Version, Command, Null, Address type, Ip-Address, Port number paystring = '05 01 00 01 ' .. sip .. '00 50' payload = bin.pack("H",paystring) diff --git a/nselib/rdp.lua b/nselib/rdp.lua index 5aafbde78..114d2a1fa 100644 --- a/nselib/rdp.lua +++ b/nselib/rdp.lua @@ -326,7 +326,7 @@ Comm = { local pos, itut_code = bin.unpack("C", data, 6) if ( itut_code == 0xD0 ) then - stdnse.print_debug(2, "RDP: Received ConnectionConfirm response") + stdnse.debug2("RDP: Received ConnectionConfirm response") return true, Response.ConnectionConfirm.parse(data) elseif ( itut_code == 0xF0 ) then return true, Response.MCSConnectResponse.parse(data) diff --git a/nselib/rmi.lua b/nselib/rmi.lua index d23e2e34b..1cbac885e 100644 --- a/nselib/rmi.lua +++ b/nselib/rmi.lua @@ -53,7 +53,7 @@ _ENV = stdnse.module("rmi", stdnse.seeall) local function dbg(str,...) local arg={...} - stdnse.print_debug(3,"RMI:"..str, table.unpack(arg)) + stdnse.debug3("RMI:"..str, table.unpack(arg)) end -- Convenience function to both print an error message and return -- Example usage : @@ -62,7 +62,7 @@ end -- end local function doh(str,...) local arg={...} - stdnse.print_debug("RMI-ERR:"..tostring(str), table.unpack(arg)) + stdnse.debug1("RMI-ERR:"..tostring(str), table.unpack(arg)) return false, str end diff --git a/nselib/rpc.lua b/nselib/rpc.lua index 1ae0d7d7d..284a134ea 100644 --- a/nselib/rpc.lua +++ b/nselib/rpc.lua @@ -367,7 +367,7 @@ Comm = { local tmp status, tmp = self:GetAdditionalBytes( data, pos, HEADER_LEN - ( data:len() - pos ) ) if not status then - stdnse.print_debug(4, + stdnse.debug4( string.format("Comm.DecodeHeader: failed to call GetAdditionalBytes")) return -1, nil end @@ -387,7 +387,7 @@ Comm = { if header.verifier.length - 8 > 0 then status, data = self:GetAdditionalBytes( data, pos, header.verifier.length - 8 ) if not status then - stdnse.print_debug(4, + stdnse.debug4( string.format("Comm.DecodeHeader: failed to call GetAdditionalBytes")) return -1, nil end @@ -1365,10 +1365,10 @@ NFS = { CheckStat = function (self, procedurename, version, status) if (status ~= NFS.StatCode[version].NFS_OK) then if (NFS.StatMsg[status]) then - stdnse.print_debug(4, + stdnse.debug4( string.format("%s failed: %s", procedurename, NFS.StatMsg[status])) else - stdnse.print_debug(4, + stdnse.debug4( string.format("%s failed: code %d", procedurename, status)) end @@ -1438,7 +1438,7 @@ NFS = { status, data = comm:GetAdditionalBytes( data, pos, 4 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1452,7 +1452,7 @@ NFS = { response.attributes = {} status, data = comm:GetAdditionalBytes( data, pos, 4 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1462,7 +1462,7 @@ NFS = { end status, data = comm:GetAdditionalBytes( data, pos, 84 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, attrib = Util.unmarshall_nfsattr(data, pos, comm.version) @@ -1470,7 +1470,7 @@ NFS = { -- opaque data status, data = comm:GetAdditionalBytes( data, pos, 8 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, _ = bin.unpack(">L", data, pos) @@ -1481,7 +1481,7 @@ NFS = { local entry = {} status, data = comm:GetAdditionalBytes( data, pos, 4 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1493,14 +1493,14 @@ NFS = { if ( 3 == comm.version ) then status, data = comm:GetAdditionalBytes( data, pos, 8 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.fileid = Util.unmarshall_uint64(data, pos ) else status, data = comm:GetAdditionalBytes( data, pos, 4 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.fileid = Util.unmarshall_uint32(data, pos) @@ -1508,14 +1508,14 @@ NFS = { status, data = comm:GetAdditionalBytes( data, pos, 4 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.length = Util.unmarshall_uint32(data, pos) status, data = comm:GetAdditionalBytes( data, pos, entry.length ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1523,14 +1523,14 @@ NFS = { if ( 3 == comm.version ) then status, data = comm:GetAdditionalBytes( data, pos, 8 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.cookie = Util.unmarshall_uint64(data, pos) else status, data = comm:GetAdditionalBytes( data, pos, 4 ) if (not(status)) then - stdnse.print_debug(4, "NFS.ReadDirDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.cookie = Util.unmarshall_uint32(data, pos) @@ -1590,7 +1590,7 @@ NFS = { status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1602,20 +1602,20 @@ NFS = { if (comm.version == 3) then status, data = comm:GetAdditionalBytes( data, pos, 4) if (not(status)) then - stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes") return -1, nil end _, len = Util.unmarshall_uint32(data, pos) status, data = comm:GetAdditionalBytes( data, pos, len + 4) if (not(status)) then - stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, lookup.fhandle = bin.unpack( "A" .. len + 4, data, pos) status, data = comm:GetAdditionalBytes( data, pos, 4) if (not(status)) then - stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1624,17 +1624,17 @@ NFS = { if (value_follows ~= 0) then status, data = comm:GetAdditionalBytes(data, pos, 84) if (not(status)) then - stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, lookup.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) else - stdnse.print_debug(4, "NFS.LookUpDecode: File Attributes follow failed") + stdnse.debug4("NFS.LookUpDecode: File Attributes follow failed") end status, data = comm:GetAdditionalBytes( data, pos, 4) if (not(status)) then - stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1643,30 +1643,30 @@ NFS = { if (value_follows ~= 0) then status, data = comm:GetAdditionalBytes(data, pos, 84) if (not(status)) then - stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, lookup.dir_attributes = Util.unmarshall_nfsattr(data, pos, comm.version) else - stdnse.print_debug(4, "NFS.LookUpDecode: File Attributes follow failed") + stdnse.debug4("NFS.LookUpDecode: File Attributes follow failed") end elseif (comm.version < 3) then status, data = comm:GetAdditionalBytes( data, pos, 32) if (not(status)) then - stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, lookup.fhandle = bin.unpack("A32", data, pos) status, data = comm:GetAdditionalBytes( data, pos, 64 ) if (not(status)) then - stdnse.print_debug(4, "NFS.LookUpDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.LookUpDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, lookup.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) else - stdnse.print_debug("NFS.LookUpDecode: NFS unsupported version %d", comm.version) + stdnse.debug1("NFS.LookUpDecode: NFS unsupported version %d", comm.version) return -1, nil end @@ -1711,7 +1711,7 @@ NFS = { status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1722,19 +1722,19 @@ NFS = { status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, value_follows = bin.unpack(">I", data, pos) if value_follows == 0 then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Attributes follow failed") + stdnse.debug4("NFS.ReadDirPlusDecode: Attributes follow failed") return -1, nil end status, data = comm:GetAdditionalBytes( data, pos, 84 ) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1743,7 +1743,7 @@ NFS = { status, data = comm:GetAdditionalBytes(data, pos, 8) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, _ = bin.unpack(">L", data, pos) @@ -1753,7 +1753,7 @@ NFS = { local entry, len = {} status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1764,7 +1764,7 @@ NFS = { end status, data = comm:GetAdditionalBytes(data, pos, 8) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.fileid = bin.unpack(">L", data, pos) @@ -1772,27 +1772,27 @@ NFS = { status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.length = bin.unpack(">I", data, pos) status, data = comm:GetAdditionalBytes( data, pos, entry.length ) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.name = Util.unmarshall_vopaque(entry.length, data, pos) status, data = comm:GetAdditionalBytes(data, pos, 8) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.cookie = bin.unpack(">L", data, pos) status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1801,18 +1801,18 @@ NFS = { if (value_follows ~= 0) then status, data = comm:GetAdditionalBytes(data, pos, 84) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) else - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: %s Attributes follow failed", + stdnse.debug4("NFS.ReadDirPlusDecode: %s Attributes follow failed", entry.name) end status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1821,19 +1821,19 @@ NFS = { if (value_follows ~= 0) then status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end _, len = bin.unpack(">I", data, pos) status, data = comm:GetAdditionalBytes(data, pos, len + 4) if not status then - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.ReadDirPlusDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, entry.fhandle = bin.unpack( "A" .. len + 4, data, pos ) else - stdnse.print_debug(4, "NFS.ReadDirPlusDecode: %s handle follow failed", + stdnse.debug4("NFS.ReadDirPlusDecode: %s handle follow failed", entry.name) end table.insert(response.entries, entry) @@ -1889,7 +1889,7 @@ NFS = { status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.FsStatDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.FsStatDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1903,17 +1903,17 @@ NFS = { if (value_follows ~= 0) then status, data = comm:GetAdditionalBytes(data, pos, 84) if not status then - stdnse.print_debug(4, "NFS.FsStatDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.FsStatDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, fsstat.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) else - stdnse.print_debug(4, "NFS.FsStatDecode: Attributes follow failed") + stdnse.debug4("NFS.FsStatDecode: Attributes follow failed") end status, data = comm:GetAdditionalBytes( data, pos, 52) if not status then - stdnse.print_debug(4, "NFS.FsStatDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.FsStatDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1968,7 +1968,7 @@ NFS = { status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.FsInfoDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.FsInfoDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -1982,17 +1982,17 @@ NFS = { if (value_follows ~= 0) then status, data = comm:GetAdditionalBytes(data, pos, 84) if not status then - stdnse.print_debug(4, "NFS.FsInfoDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.FsInfoDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, fsinfo.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) else - stdnse.print_debug(4, "NFS.FsInfoDecode: Attributes follow failed") + stdnse.debug4("NFS.FsInfoDecode: Attributes follow failed") end status, data = comm:GetAdditionalBytes(data, pos, 48) if not status then - stdnse.print_debug(4, "NFS.FsStatDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.FsStatDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -2050,7 +2050,7 @@ NFS = { status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.PathConfDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.PathConfDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -2064,17 +2064,17 @@ NFS = { if (value_follows ~= 0) then status, data = comm:GetAdditionalBytes(data, pos, 84) if not status then - stdnse.print_debug(4, "NFS.PathConfDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.PathConfDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, pconf.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) else - stdnse.print_debug(4, "NFS.PathConfDecode: Attributes follow failed") + stdnse.debug4("NFS.PathConfDecode: Attributes follow failed") end status, data = comm:GetAdditionalBytes(data, pos, 24) if not status then - stdnse.print_debug(4, "NFS.PathConfDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.PathConfDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -2129,7 +2129,7 @@ NFS = { status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.AccessDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.AccessDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -2143,17 +2143,17 @@ NFS = { if (value_follows ~= 0) then status, data = comm:GetAdditionalBytes(data, pos, 84) if not status then - stdnse.print_debug(4, "NFS.AccessDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.AccessDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, access.attributes = Util.unmarshall_nfsattr(data, pos, comm.version) else - stdnse.print_debug(4, "NFS.AccessDecode: Attributes follow failed") + stdnse.debug4("NFS.AccessDecode: Attributes follow failed") end status, data = comm:GetAdditionalBytes(data, pos, 4) if not status then - stdnse.print_debug(4, "NFS.AccessDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("NFS.AccessDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -2267,7 +2267,7 @@ NFS = { status, data = comm:GetAdditionalBytes( data, pos, 4 ) if (not(status)) then - stdnse.print_debug(4, "GetAttrDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("GetAttrDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -2281,11 +2281,11 @@ NFS = { elseif (comm.version == 3) then status, data = comm:GetAdditionalBytes( data, pos, 84 ) else - stdnse.print_debug(4, "GetAttrDecode: Unsupported version") + stdnse.debug4("GetAttrDecode: Unsupported version") return -1, nil end if ( not(status) ) then - stdnse.print_debug(4, "GetAttrDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("GetAttrDecode: Failed to call GetAdditionalBytes") return -1, nil end return Util.unmarshall_nfsattr(data, pos, comm.version) @@ -2344,7 +2344,7 @@ NFS = { status, data = comm:GetAdditionalBytes( data, pos, 4 ) if (not(status)) then - stdnse.print_debug(4, "StatFsDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("StatFsDecode: Failed to call GetAdditionalBytes") return -1, nil end @@ -2355,7 +2355,7 @@ NFS = { status, data = comm:GetAdditionalBytes( data, pos, 20 ) if (not(status)) then - stdnse.print_debug(4, "StatFsDecode: Failed to call GetAdditionalBytes") + stdnse.debug4("StatFsDecode: Failed to call GetAdditionalBytes") return -1, nil end pos, statfs.transfer_size, statfs.block_size, @@ -2383,20 +2383,20 @@ Helper = { status, mountd = Helper.GetProgramInfo( host, port, "mountd") if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.ShowMounts: GetProgramInfo failed") + stdnse.debug4("rpc.Helper.ShowMounts: GetProgramInfo failed") return status, "rpc.Helper.ShowMounts: GetProgramInfo failed" end mnt_comm = Comm:new('mountd', mountd.version) status, result = mnt_comm:Connect(host, mountd.port) if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.ShowMounts: %s", result) + stdnse.debug4("rpc.Helper.ShowMounts: %s", result) return false, result end status, mounts = mnt:Export(mnt_comm) mnt_comm:Disconnect() if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.ShowMounts: %s", mounts) + stdnse.debug4("rpc.Helper.ShowMounts: %s", mounts) end return status, mounts end, @@ -2421,7 +2421,7 @@ Helper = { status, mountd = Helper.GetProgramInfo( host, port, "mountd") if not status then - stdnse.print_debug(4, "rpc.Helper.MountPath: GetProgramInfo failed") + stdnse.debug4("rpc.Helper.MountPath: GetProgramInfo failed") return nil, "rpc.Helper.MountPath: GetProgramInfo failed" end @@ -2429,14 +2429,14 @@ Helper = { status, err = mnt_comm:Connect(host, mountd.port) if not status then - stdnse.print_debug(4, "rpc.Helper.MountPath: %s", err) + stdnse.debug4("rpc.Helper.MountPath: %s", err) return nil, err end status, fhandle = mnt:Mount(mnt_comm, path) if not status then mnt_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.MountPath: %s", fhandle) + stdnse.debug4("rpc.Helper.MountPath: %s", fhandle) return nil, fhandle end @@ -2459,7 +2459,7 @@ Helper = { local status, ret = mnt:Unmount(mnt_comm, path) mnt_comm:Disconnect() if not status then - stdnse.print_debug(4, "rpc.Helper.UnmountPath: %s", ret) + stdnse.debug4("rpc.Helper.UnmountPath: %s", ret) return nil, ret end @@ -2482,14 +2482,14 @@ Helper = { status, nfsd = Helper.GetProgramInfo(host, port, "nfs") if not status then - stdnse.print_debug(4, "rpc.Helper.NfsOpen: GetProgramInfo failed") + stdnse.debug4("rpc.Helper.NfsOpen: GetProgramInfo failed") return nil, "rpc.Helper.NfsOpen: GetProgramInfo failed" end nfs_comm = Comm:new('nfs', nfsd.version) status, err = nfs_comm:Connect(host, nfsd.port) if not status then - stdnse.print_debug(4, "rpc.Helper.NfsProc: %s", err) + stdnse.debug4("rpc.Helper.NfsProc: %s", err) return nil, err end @@ -2508,7 +2508,7 @@ Helper = { NfsClose = function(nfs_comm) local status, ret = nfs_comm:Disconnect() if not status then - stdnse.print_debug(4, "rpc.Helper.NfsClose: %s", ret) + stdnse.debug4("rpc.Helper.NfsClose: %s", ret) return nil, ret end @@ -2532,13 +2532,13 @@ Helper = { status, mountd = Helper.GetProgramInfo( host, port, "mountd", 2) if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.ExportStats: GetProgramInfo failed") + stdnse.debug4("rpc.Helper.ExportStats: GetProgramInfo failed") return status, "rpc.Helper.ExportStats: GetProgramInfo failed" end status, nfsd = Helper.GetProgramInfo( host, port, "nfs", 2) if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.ExportStats: GetProgramInfo failed") + stdnse.debug4("rpc.Helper.ExportStats: GetProgramInfo failed") return status, "rpc.Helper.ExportStats: GetProgramInfo failed" end mnt_comm = Comm:new('mountd', mountd.version) @@ -2546,20 +2546,20 @@ Helper = { -- TODO: recheck the version mismatch when adding NFSv4 if (nfs_comm.version <= 2 and mnt_comm.version > 2) then - stdnse.print_debug(4,"rpc.Helper.ExportStats: versions mismatch, nfs v%d - mount v%d", + stdnse.debug4("rpc.Helper.ExportStats: versions mismatch, nfs v%d - mount v%d", nfs_comm.version, mnt_comm.version) return false, string.format("versions mismatch, nfs v%d - mount v%d", nfs_comm.version, mnt_comm.version) end status, result = mnt_comm:Connect(host, mountd.port) if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", result) + stdnse.debug4("rpc.Helper.ExportStats: %s", result) return status, result end status, result = nfs_comm:Connect(host, nfsd.port) if ( not(status) ) then mnt_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", result) + stdnse.debug4("rpc.Helper.ExportStats: %s", result) return status, result end @@ -2567,14 +2567,14 @@ Helper = { if ( not(status) ) then mnt_comm:Disconnect() nfs_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", fhandle) + stdnse.debug4("rpc.Helper.ExportStats: %s", fhandle) return status, fhandle end status, stats = nfs:StatFs(nfs_comm, fhandle) if ( not(status) ) then mnt_comm:Disconnect() nfs_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", stats) + stdnse.debug4("rpc.Helper.ExportStats: %s", stats) return status, stats end @@ -2582,7 +2582,7 @@ Helper = { mnt_comm:Disconnect() nfs_comm:Disconnect() if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.ExportStats: %s", fhandle) + stdnse.debug4("rpc.Helper.ExportStats: %s", fhandle) return status, fhandle end return true, stats @@ -2604,13 +2604,13 @@ Helper = { status, mountd = Helper.GetProgramInfo( host, port, "mountd") if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.Dir: GetProgramInfo failed") + stdnse.debug4("rpc.Helper.Dir: GetProgramInfo failed") return status, "rpc.Helper.Dir: GetProgramInfo failed" end status, nfsd = Helper.GetProgramInfo( host, port, "nfs") if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.Dir: GetProgramInfo failed") + stdnse.debug4("rpc.Helper.Dir: GetProgramInfo failed") return status, "rpc.Helper.Dir: GetProgramInfo failed" end @@ -2619,21 +2619,21 @@ Helper = { -- TODO: recheck the version mismatch when adding NFSv4 if (nfs_comm.version <= 2 and mnt_comm.version > 2) then - stdnse.print_debug(4, "rpc.Helper.Dir: versions mismatch, nfs v%d - mount v%d", + stdnse.debug4("rpc.Helper.Dir: versions mismatch, nfs v%d - mount v%d", nfs_comm.version, mnt_comm.version) return false, string.format("versions mismatch, nfs v%d - mount v%d", nfs_comm.version, mnt_comm.version) end status, result = mnt_comm:Connect(host, mountd.port) if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.Dir: %s", result) + stdnse.debug4("rpc.Helper.Dir: %s", result) return status, result end status, result = nfs_comm:Connect(host, nfsd.port) if ( not(status) ) then mnt_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.Dir: %s", result) + stdnse.debug4("rpc.Helper.Dir: %s", result) return status, result end @@ -2641,7 +2641,7 @@ Helper = { if ( not(status) ) then mnt_comm:Disconnect() nfs_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.Dir: %s", fhandle) + stdnse.debug4("rpc.Helper.Dir: %s", fhandle) return status, fhandle end @@ -2649,7 +2649,7 @@ Helper = { if ( not(status) ) then mnt_comm:Disconnect() nfs_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.Dir: %s", dirs) + stdnse.debug4("rpc.Helper.Dir: %s", dirs) return status, dirs end @@ -2657,7 +2657,7 @@ Helper = { mnt_comm:Disconnect() nfs_comm:Disconnect() if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.Dir: %s", fhandle) + stdnse.debug4("rpc.Helper.Dir: %s", fhandle) return status, fhandle end return true, dirs @@ -2680,13 +2680,13 @@ Helper = { status, mountd = Helper.GetProgramInfo( host, port, "mountd") if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.GetAttributes: GetProgramInfo failed") + stdnse.debug4("rpc.Helper.GetAttributes: GetProgramInfo failed") return status, "rpc.Helper.GetAttributes: GetProgramInfo failed" end status, nfsd = Helper.GetProgramInfo( host, port, "nfs") if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.GetAttributes: GetProgramInfo failed") + stdnse.debug4("rpc.Helper.GetAttributes: GetProgramInfo failed") return status, "rpc.Helper.GetAttributes: GetProgramInfo failed" end @@ -2695,7 +2695,7 @@ Helper = { -- TODO: recheck the version mismatch when adding NFSv4 if (nfs_comm.version <= 2 and mnt_comm.version > 2) then - stdnse.print_debug(4, "rpc.Helper.GetAttributes: versions mismatch, nfs v%d - mount v%d", + stdnse.debug4("rpc.Helper.GetAttributes: versions mismatch, nfs v%d - mount v%d", nfs_comm.version, mnt_comm.version) return false, string.format("versions mismatch, nfs v%d - mount v%d", nfs_comm.version, mnt_comm.version) @@ -2703,14 +2703,14 @@ Helper = { status, result = mnt_comm:Connect(host, mountd.port) if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", result) + stdnse.debug4("rpc.Helper.GetAttributes: %s", result) return status, result end status, result = nfs_comm:Connect(host, nfsd.port) if ( not(status) ) then mnt_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", result) + stdnse.debug4("rpc.Helper.GetAttributes: %s", result) return status, result end @@ -2718,7 +2718,7 @@ Helper = { if ( not(status) ) then mnt_comm:Disconnect() nfs_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", fhandle) + stdnse.debug4("rpc.Helper.GetAttributes: %s", fhandle) return status, fhandle end @@ -2726,7 +2726,7 @@ Helper = { if ( not(status) ) then mnt_comm:Disconnect() nfs_comm:Disconnect() - stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", attribs) + stdnse.debug4("rpc.Helper.GetAttributes: %s", attribs) return status, attribs end @@ -2735,7 +2735,7 @@ Helper = { mnt_comm:Disconnect() nfs_comm:Disconnect() if ( not(status) ) then - stdnse.print_debug(4, "rpc.Helper.GetAttributes: %s", fhandle) + stdnse.debug4("rpc.Helper.GetAttributes: %s", fhandle) return status, fhandle end @@ -2769,7 +2769,7 @@ Helper = { status, result = comm:Connect(host, port) if (not(status)) then mutex "done" - stdnse.print_debug(4, "rpc.Helper.RpcInfo: %s", result) + stdnse.debug4("rpc.Helper.RpcInfo: %s", result) return status, result end @@ -2778,7 +2778,7 @@ Helper = { mutex "done" if (not(status)) then - stdnse.print_debug(4, "rpc.Helper.RpcInfo: %s", result) + stdnse.debug4("rpc.Helper.RpcInfo: %s", result) end return status, result @@ -2800,14 +2800,14 @@ Helper = { status, result = comm:Connect(host, port) if (not(status)) then - stdnse.print_debug(4, "rpc.Helper.GetPortForProgram: %s", result) + stdnse.debug4("rpc.Helper.GetPortForProgram: %s", result) return status, result end status, result = portmap:GetPort(comm, program, protocol, 1 ) comm:Disconnect() if (not(status)) then - stdnse.print_debug(4, "rpc.Helper.GetPortForProgram: %s", result) + stdnse.debug4("rpc.Helper.GetPortForProgram: %s", result) end return status, result @@ -2942,7 +2942,7 @@ Util = if Util.FileType[code] then return Util.FileType[code].char else - stdnse.print_debug(1,"FtypeToChar: Unknown file type, mode: %o", mode) + stdnse.debug1("FtypeToChar: Unknown file type, mode: %o", mode) return "" end end, @@ -2956,7 +2956,7 @@ Util = if Util.FileType[code] then return Util.FileType[code].str else - stdnse.print_debug(1,"FtypeToString: Unknown file type, mode: %o", mode) + stdnse.debug1("FtypeToString: Unknown file type, mode: %o", mode) return "" end end, @@ -2972,7 +2972,7 @@ Util = code = bit.bxor(mode, code) else code = mode - stdnse.print_debug(1,"FmodeToOctalString: Unknown file type, mode: %o", mode) + stdnse.debug1("FmodeToOctalString: Unknown file type, mode: %o", mode) end return stdnse.tooctal(code) end, @@ -3178,7 +3178,7 @@ Util = pos, attr.fsid = Util.unmarshall_uint64(data, pos) pos, attr.fileid = Util.unmarshall_nfsfileid3(data, pos) else - stdnse.print_debug(4, "unmarshall_nfsattr: unsupported NFS version %d", + stdnse.debug4("unmarshall_nfsattr: unsupported NFS version %d", nfsversion) return -1, nil end diff --git a/nselib/rtsp.lua b/nselib/rtsp.lua index f742ad5f4..e8d4a95a8 100644 --- a/nselib/rtsp.lua +++ b/nselib/rtsp.lua @@ -169,7 +169,7 @@ Client = { self.socket:set_timeout(self.timeout) local status = self.socket:connect(self.host, self.port) if ( not(status) ) then - stdnse.print_debug(2, "Failed to connect to the server: %s", self.host.ip) + stdnse.debug2("Failed to connect to the server: %s", self.host.ip) return false, ("Failed to connect to the server: %s"):format(self.host.ip) end return true @@ -210,7 +210,7 @@ Client = { -- check if send was successful, in case it wasn't AND -- this is our last retry, ABORT if ( not(status) and 0 == retries - 1 ) then - stdnse.print_debug(2, "Failed to send request to server (%s)", err) + stdnse.debug2("Failed to send request to server (%s)", err) return false, ("Failed to send request to server (%s)"):format(err) -- if send was successful, attempt to receive the response elseif ( status ) then @@ -224,7 +224,7 @@ Client = { local status, err = self:connect() -- if re-connect fails, BAIL out of here if ( not(status) ) then - stdnse.print_debug(2, "Failed to reconnect socket to server (%s)", err) + stdnse.debug2("Failed to reconnect socket to server (%s)", err) return false, ("Failed to reconnect socket to server (%s)"):format(err) end end @@ -232,7 +232,7 @@ Client = { until( status or retries == 0 ) if( not(status) ) then - stdnse.print_debug(2, "Failed to receive response from server (%s)", data) + stdnse.debug2("Failed to receive response from server (%s)", data) return false, ("Failed to receive response from server (%s)"):format(data) end diff --git a/nselib/sasl.lua b/nselib/sasl.lua index f2ea2ebb8..a2dadf3c3 100644 --- a/nselib/sasl.lua +++ b/nselib/sasl.lua @@ -51,7 +51,7 @@ _ENV = stdnse.module("sasl", stdnse.seeall) local HAVE_SSL, openssl = pcall(require, 'openssl') if ( not(HAVE_SSL) ) then - stdnse.print_debug(1, + stdnse.debug1( "sasl.lua: OpenSSL not present, SASL support limited.") end local MECHANISMS = { } @@ -348,7 +348,7 @@ function check_mechanism(mechanism) lmech = mechanism lcallback = MECHANISMS[mechanism] else - stdnse.print_debug(3, + stdnse.debug3( "sasl library does not support '%s' mechanism", mechanism) end end diff --git a/nselib/smb.lua b/nselib/smb.lua index 630e89a60..d746c34b9 100644 --- a/nselib/smb.lua +++ b/nselib/smb.lua @@ -291,12 +291,12 @@ function start(host) state['name'] = result end else - stdnse.print_debug(2, "SMB: Resolved netbios name from cache") + stdnse.debug2("SMB: Resolved netbios name from cache") state['name'] = host.registry['netbios_name'] end nbcache_mutex "done" - stdnse.print_debug(2, "SMB: Starting SMB session for %s (%s)", host.name, host.ip) + stdnse.debug2("SMB: Starting SMB session for %s (%s)", host.name, host.ip) if(port == nil) then return false, "SMB: Couldn't find a valid port to check" @@ -426,7 +426,7 @@ function stop(smb) logoff(smb) end - stdnse.print_debug(2, "SMB: Closing socket") + stdnse.debug2("SMB: Closing socket") if(smb['socket'] ~= nil) then local status, err = smb['socket']:close() @@ -548,7 +548,7 @@ function start_netbios(host, port, name) name = names[i] -- Some debug information - stdnse.print_debug(1, "SMB: Trying to start NetBIOS session with name = '%s'", name) + stdnse.debug1("SMB: Trying to start NetBIOS session with name = '%s'", name) -- Request a NetBIOS session local session_request = bin.pack(">CCSzz", 0x81, -- session request @@ -558,7 +558,7 @@ function start_netbios(host, port, name) netbios.name_encode("NMAP") -- client name ); - stdnse.print_debug(3, "SMB: Connecting to %s", host.ip) + stdnse.debug3("SMB: Connecting to %s", host.ip) socket:set_timeout(TIMEOUT) status, err = socket:connect(host, port, "tcp") if(status == false) then @@ -567,7 +567,7 @@ function start_netbios(host, port, name) end -- Send the session request - stdnse.print_debug(3, "SMB: Sending NetBIOS session request with name %s", name) + stdnse.debug3("SMB: Sending NetBIOS session request with name %s", name) status, err = socket:send(session_request) if(status == false) then socket:close() @@ -576,7 +576,7 @@ function start_netbios(host, port, name) socket:set_timeout(TIMEOUT) -- Receive the session response - stdnse.print_debug(3, "SMB: Receiving NetBIOS session response") + stdnse.debug3("SMB: Receiving NetBIOS session response") status, result = socket:receive_buf(match.numbytes(4), true); if(status == false) then socket:close() @@ -589,12 +589,12 @@ function start_netbios(host, port, name) -- Check for a positive session response (0x82) if result == 0x82 then - stdnse.print_debug(3, "SMB: Successfully established NetBIOS session with server name %s", name) + stdnse.debug3("SMB: Successfully established NetBIOS session with server name %s", name) return true, socket end -- If the session failed, close the socket and try the next name - stdnse.print_debug(1, "SMB: Session request failed, trying next name") + stdnse.debug1("SMB: Session request failed, trying next name") socket:close() -- Try the next name @@ -603,7 +603,7 @@ function start_netbios(host, port, name) until i > #names -- We reached the end of our names list - stdnse.print_debug(1, "SMB: None of the NetBIOS names worked!") + stdnse.debug1("SMB: None of the NetBIOS names worked!") return false, "SMB: Couldn't find a NetBIOS name that works for the server. Sorry!" end @@ -734,10 +734,10 @@ local function message_sign(smb, body) smb['sequence'] = smb['sequence'] + 1 if(smb['mac_key'] == nil) then - stdnse.print_debug(3, "SMB: Not signing message (missing mac_key)") + stdnse.debug3("SMB: Not signing message (missing mac_key)") return body elseif(nmap.registry.args.smbsign == "disable") then - stdnse.print_debug(3, "SMB: Not signing message (disabled by user)") + stdnse.debug3("SMB: Not signing message (disabled by user)") return body end @@ -763,13 +763,13 @@ local function message_check_signature(smb, body) smb['sequence'] = smb['sequence'] + 1 if(smb['mac_key'] == nil) then - stdnse.print_debug(3, "SMB: Not signing message (missing mac_key)") + stdnse.debug3("SMB: Not signing message (missing mac_key)") return true elseif(nmap.registry.args.smbsign ~= "force" and bit.band(smb['security_mode'], 0x0A) ~= 0) then - stdnse.print_debug(3, "SMB: Not signing message (server doesn't support it -- default)") + stdnse.debug3("SMB: Not signing message (server doesn't support it -- default)") return true elseif(nmap.registry.args.smbsign == "disable" or nmap.registry.args.smbsign == "ignore") then - stdnse.print_debug(3, "SMB: Not signing message (disabled by user)") + stdnse.debug3("SMB: Not signing message (disabled by user)") return true end @@ -818,12 +818,12 @@ function smb_send(smb, header, parameters, data, overrides) repeat attempts = attempts - 1 - stdnse.print_debug(3, "SMB: Sending SMB packet (len: %d, attempts remaining: %d)", #out, attempts) + stdnse.debug3("SMB: Sending SMB packet (len: %d, attempts remaining: %d)", #out, attempts) status, err = smb['socket']:send(out) until(status or (attempts == 0)) if(attempts == 0) then - stdnse.print_debug(1, "SMB: Sending packet failed after 5 tries! Giving up.") + stdnse.debug1("SMB: Sending packet failed after 5 tries! Giving up.") end return status, err @@ -845,7 +845,7 @@ function smb_read(smb, read_data) local pos, netbios_data, netbios_length, length, header, parameter_length, parameters, data_length, data local attempts = 5 - stdnse.print_debug(3, "SMB: Receiving SMB packet") + stdnse.debug3("SMB: Receiving SMB packet") -- Receive the response -- we make sure to receive at least 4 bytes, the length of the NetBIOS length smb['socket']:set_timeout(TIMEOUT) @@ -857,7 +857,7 @@ function smb_read(smb, read_data) status, netbios_data = smb['socket']:receive_buf(match.numbytes(4), true); if ( not(status) and netbios_data == "EOF" ) then - stdnse.print_debug(1, "SMB: ERROR: Server disconnected the connection") + stdnse.debug1("SMB: ERROR: Server disconnected the connection") return false, "SMB: ERROR: Server disconnected the connection" end until(status or (attempts == 0)) @@ -893,7 +893,7 @@ function smb_read(smb, read_data) local result = netbios_data .. smb_data if(#result ~= length) then - stdnse.print_debug(1, "SMB: ERROR: Received wrong number of bytes, there will likely be issues (received %d, expected %d)", #result, length) + stdnse.debug1("SMB: ERROR: Received wrong number of bytes, there will likely be issues (received %d, expected %d)", #result, length) return false, string.format("SMB: ERROR: Didn't receive the expected number of bytes; received %d, expected %d. This will almost certainly cause some errors.", #result, length) end @@ -937,7 +937,7 @@ function smb_read(smb, read_data) data = nil end - stdnse.print_debug(3, "SMB: Received %d bytes", #result) + stdnse.debug3("SMB: Received %d bytes", #result) return true, header, parameters, data end @@ -998,7 +998,7 @@ function negotiate_protocol(smb, overrides) end -- Send the negotiate request - stdnse.print_debug(2, "SMB: Sending SMB_COM_NEGOTIATE") + stdnse.debug2("SMB: Sending SMB_COM_NEGOTIATE") local result, err = smb_send(smb, header, parameters, data, overrides) if(status == false) then return false, err @@ -1179,7 +1179,7 @@ local function start_session_basic(smb, log_errors, overrides) ) -- Send the session setup request - stdnse.print_debug(2, "SMB: Sending SMB_COM_SESSION_SETUP_ANDX") + stdnse.debug2("SMB: Sending SMB_COM_SESSION_SETUP_ANDX") result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then return false, err @@ -1221,17 +1221,17 @@ local function start_session_basic(smb, log_errors, overrides) -- Check if they're using an un-supported system if(os == nil or lanmanager == nil or domain == nil) then - stdnse.print_debug(1, "SMB: WARNING: the server is using a non-standard SMB implementation; your mileage may vary (%s)", smb['ip']) + stdnse.debug1("SMB: WARNING: the server is using a non-standard SMB implementation; your mileage may vary (%s)", smb['ip']) elseif(os == "Unix" or string.sub(lanmanager, 1, 5) == "Samba") then - stdnse.print_debug(1, "SMB: WARNING: the server appears to be Unix; your mileage may vary.") + stdnse.debug1("SMB: WARNING: the server appears to be Unix; your mileage may vary.") end -- Check if they were logged in as a guest if(log_errors == nil or log_errors == true) then if(smb['is_guest'] == 1) then - stdnse.print_debug(1, "SMB: Login as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", domain, stdnse.string_or_blank(username)) + stdnse.debug1("SMB: Login as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", domain, stdnse.string_or_blank(username)) else - stdnse.print_debug(2, "SMB: Login as %s\\%s succeeded", domain, stdnse.string_or_blank(username)) + stdnse.debug2("SMB: Login as %s\\%s succeeded", domain, stdnse.string_or_blank(username)) end end @@ -1250,12 +1250,12 @@ local function start_session_basic(smb, log_errors, overrides) end local backoff = math.random() * 10 - stdnse.print_debug(1, "SMB: Server has too many active connections; pausing for %s seconds.", math.floor(backoff * 100) / 100) + stdnse.debug1("SMB: Server has too many active connections; pausing for %s seconds.", math.floor(backoff * 100) / 100) stdnse.sleep(backoff) else -- This username failed, print a warning and keep going if(log_errors == nil or log_errors == true) then - stdnse.print_debug(1, "SMB: Login as %s\\%s failed (%s)", domain, stdnse.string_or_blank(username), get_status_name(status)) + stdnse.debug1("SMB: Login as %s\\%s failed (%s)", domain, stdnse.string_or_blank(username), get_status_name(status)) end -- Go to the next account @@ -1270,7 +1270,7 @@ local function start_session_basic(smb, log_errors, overrides) end if(log_errors ~= false) then - stdnse.print_debug(1, "SMB: ERROR: %s", username) + stdnse.debug1("SMB: ERROR: %s", username) end if (status ~= nil) then @@ -1392,7 +1392,7 @@ local function start_session_extended(smb, log_errors, overrides) ) -- Send the session setup request - stdnse.print_debug(2, "SMB: Sending SMB_COM_SESSION_SETUP_ANDX") + stdnse.debug2("SMB: Sending SMB_COM_SESSION_SETUP_ANDX") result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then return false, err @@ -1451,17 +1451,17 @@ local function start_session_extended(smb, log_errors, overrides) if(status_name == "NT_STATUS_SUCCESS") then -- Check if they're using an un-supported system if(os == nil or lanmanager == nil) then - stdnse.print_debug(1, "SMB: WARNING: the server is using a non-standard SMB implementation; your mileage may vary (%s)", smb['ip']) + stdnse.debug1("SMB: WARNING: the server is using a non-standard SMB implementation; your mileage may vary (%s)", smb['ip']) elseif(os == "Unix" or string.sub(lanmanager, 1, 5) == "Samba") then - stdnse.print_debug(1, "SMB: WARNING: the server appears to be Unix; your mileage may vary.") + stdnse.debug1("SMB: WARNING: the server appears to be Unix; your mileage may vary.") end -- Check if they were logged in as a guest if(log_errors == nil or log_errors == true) then if(smb['is_guest'] == 1) then - stdnse.print_debug(1, "SMB: Extended login to %s as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", smb['ip'], domain, stdnse.string_or_blank(username)) + stdnse.debug1("SMB: Extended login to %s as %s\\%s failed, but was given guest access (username may be wrong, or system may only allow guest)", smb['ip'], domain, stdnse.string_or_blank(username)) else - stdnse.print_debug(2, "SMB: Extended login to %s as %s\\%s succeeded", smb['ip'], domain, stdnse.string_or_blank(username)) + stdnse.debug2("SMB: Extended login to %s as %s\\%s succeeded", smb['ip'], domain, stdnse.string_or_blank(username)) end end @@ -1482,12 +1482,12 @@ local function start_session_extended(smb, log_errors, overrides) end local backoff = math.random() * 10 - stdnse.print_debug(1, "SMB: Server has too many active connections; pausing for %s seconds.", math.floor(backoff * 100) / 100) + stdnse.debug1("SMB: Server has too many active connections; pausing for %s seconds.", math.floor(backoff * 100) / 100) stdnse.sleep(backoff) else -- Display a message to the user, and try the next account if(log_errors == nil or log_errors == true) then - stdnse.print_debug(1, "SMB: Extended login to %s as %s\\%s failed (%s)", smb['ip'], domain, stdnse.string_or_blank(username), status_name) + stdnse.debug1("SMB: Extended login to %s as %s\\%s failed (%s)", smb['ip'], domain, stdnse.string_or_blank(username), status_name) end -- Go to the next account @@ -1508,7 +1508,7 @@ local function start_session_extended(smb, log_errors, overrides) end -- Loop over the accounts if(log_errors == nil or log_errors == true) then - stdnse.print_debug(1, "SMB: ERROR: All logins failed, sorry it didn't work out!") + stdnse.debug1("SMB: ERROR: All logins failed, sorry it didn't work out!") end return false, status_name @@ -1595,7 +1595,7 @@ function tree_connect(smb, path, overrides) ) -- Send the tree connect request - stdnse.print_debug(2, "SMB: Sending SMB_COM_TREE_CONNECT_ANDX") + stdnse.debug2("SMB: Sending SMB_COM_TREE_CONNECT_ANDX") result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then return false, err @@ -1641,7 +1641,7 @@ function tree_disconnect(smb, overrides) header = smb_encode_header(smb, command_codes['SMB_COM_TREE_DISCONNECT'], overrides) -- Send the tree disconnect request - stdnse.print_debug(2, "SMB: Sending SMB_COM_TREE_DISCONNECT") + stdnse.debug2("SMB: Sending SMB_COM_TREE_DISCONNECT") local result, err = smb_send(smb, header, "", "", overrides) if(result == false) then return false, err @@ -1690,7 +1690,7 @@ function logoff(smb, overrides) ) -- Send the tree disconnect request - stdnse.print_debug(2, "SMB: Sending SMB_COM_LOGOFF_ANDX") + stdnse.debug2("SMB: Sending SMB_COM_LOGOFF_ANDX") local result, err = smb_send(smb, header, parameters, "", overrides) if(result == false) then return false, err @@ -1715,7 +1715,7 @@ function logoff(smb, overrides) end if(status == 0xc0000022) then - stdnse.print_debug(1, "SMB: ERROR: Access was denied in 'logoff', indicating a problem with your message signatures") + stdnse.debug1("SMB: ERROR: Access was denied in 'logoff', indicating a problem with your message signatures") return false, "SMB: ERROR: Access was denied in 'logoff', indicating a problem with your message signatures" end if(status ~= 0) then @@ -1774,7 +1774,7 @@ function create_file(smb, path, overrides) data = bin.pack("z", path) -- Send the create file - stdnse.print_debug(2, "SMB: Sending SMB_COM_NT_CREATE_ANDX") + stdnse.debug2("SMB: Sending SMB_COM_NT_CREATE_ANDX") local result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then mutex "done" @@ -1799,7 +1799,7 @@ function create_file(smb, path, overrides) if(error_count > 10) then return false, "SMB: ERROR: Server returned NT_STATUS_PIPE_NOT_AVAILABLE too many times; giving up." end - stdnse.print_debug(1, "WARNING: Server refused connection with NT_STATUS_PIPE_NOT_AVAILABLE; trying again") + stdnse.debug1("WARNING: Server refused connection with NT_STATUS_PIPE_NOT_AVAILABLE; trying again") stdnse.sleep(.2) end until (status ~= 0xc00000ac) @@ -1866,7 +1866,7 @@ function read_file(smb, offset, count, overrides) data = "" -- Send the create file - stdnse.print_debug(2, "SMB: Sending SMB_COM_READ_ANDX") + stdnse.debug2("SMB: Sending SMB_COM_READ_ANDX") local result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then return false, err @@ -1961,7 +1961,7 @@ function write_file(smb, write_data, offset, overrides) data = write_data -- Send the create file - stdnse.print_debug(2, "SMB: Sending SMB_COM_WRITE_ANDX") + stdnse.debug2("SMB: Sending SMB_COM_WRITE_ANDX") local result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then return false, err @@ -2021,7 +2021,7 @@ function close_file(smb, overrides) data = "" -- Send the close file - stdnse.print_debug(2, "SMB: Sending SMB_CLOSE") + stdnse.debug2("SMB: Sending SMB_CLOSE") local result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then return false, err @@ -2070,7 +2070,7 @@ function delete_file(smb, path, overrides) path) -- Send the close file - stdnse.print_debug(2, "SMB: Sending SMB_CLOSE") + stdnse.debug2("SMB: Sending SMB_CLOSE") local result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then return false, err @@ -2152,7 +2152,7 @@ local function send_transaction2(smb, sub_command, function_parameters, function data = data .. (function_data or '') -- Send the transaction request - stdnse.print_debug(2, "SMB: Sending SMB_COM_TRANSACTION2") + stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION2") local result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then return false, err @@ -2299,7 +2299,7 @@ function send_transaction_named_pipe(smb, function_parameters, function_data, pi data = data .. (function_data or '') -- Send the transaction request - stdnse.print_debug(2, "SMB: Sending SMB_COM_TRANSACTION") + stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION") local result, err = smb_send(smb, header, parameters, data, overrides) if(result == false) then return false, err @@ -2386,7 +2386,7 @@ function send_transaction_waitnamedpipe(smb, priority, pipe, overrides) data = bin.pack(" b['account_type'] end) -- Print a debug message - stdnse.print_debug(1, "SMB: Added account '%s' to account list", username) + stdnse.debug1("SMB: Added account '%s' to account list", username) -- Reset the credentials next_account(host, 1) @@ -316,7 +316,7 @@ function init_account(host) -- Add the account, if we got a password if(password == nil and password_hash == nil) then - stdnse.print_debug(1, "SMB: Either smbpass, smbpassword, or smbhash have to be passed as script arguments to use an account") + stdnse.debug1("SMB: Either smbpass, smbpassword, or smbhash have to be passed as script arguments to use an account") else add_account(host, username, domain, password, password_hash, hash_type) end @@ -362,7 +362,7 @@ local function lm_create_hash(password) end password = table.concat(buf) local nsedebug = require 'nsedebug' - stdnse.print_debug("LM Password: %s", stdnse.tohex(password)) + stdnse.debug1("LM Password: %s", stdnse.tohex(password)) end -- If password is under 14 characters, pad it to 14 @@ -436,7 +436,7 @@ function lm_create_response(lanman, challenge) -- Print a warning message if a blank challenge is received, and create a phony challenge. A blank challenge is -- invalid in the protocol, and causes some versions of OpenSSL to abort with no possible error handling. if(challenge == "") then - stdnse.print_debug(1, "SMB: ERROR: Server returned invalid (blank) challenge value (should be 8 bytes); failing login to avoid OpenSSL crash.") + stdnse.debug1("SMB: ERROR: Server returned invalid (blank) challenge value (should be 8 bytes); failing login to avoid OpenSSL crash.") challenge = "AAAAAAAA" end @@ -625,7 +625,7 @@ function get_password_response(ip, username, domain, password, password_hash, ha -- Check for a blank password if(password == nil and password_hash == nil) then - stdnse.print_debug(2, "SMB: Couldn't find password or hash to use (assuming blank)") + stdnse.debug2("SMB: Couldn't find password or hash to use (assuming blank)") password = "" end @@ -641,19 +641,19 @@ function get_password_response(ip, username, domain, password, password_hash, ha else if(password_hash ~= nil) then if(string.find(password_hash, "^" .. string.rep("%x%x", 16) .. "$")) then - stdnse.print_debug(2, "SMB: Found a 16-byte hex string") + stdnse.debug2("SMB: Found a 16-byte hex string") lm_hash = bin.pack("H", password_hash:sub(1, 32)) ntlm_hash = bin.pack("H", password_hash:sub(1, 32)) elseif(string.find(password_hash, "^" .. string.rep("%x%x", 32) .. "$")) then - stdnse.print_debug(2, "SMB: Found a 32-byte hex string") + stdnse.debug2("SMB: Found a 32-byte hex string") lm_hash = bin.pack("H", password_hash:sub(1, 32)) ntlm_hash = bin.pack("H", password_hash:sub(33, 64)) elseif(string.find(password_hash, "^" .. string.rep("%x%x", 16) .. "." .. string.rep("%x%x", 16) .. "$")) then - stdnse.print_debug(2, "SMB: Found two 16-byte hex strings") + stdnse.debug2("SMB: Found two 16-byte hex strings") lm_hash = bin.pack("H", password_hash:sub(1, 32)) ntlm_hash = bin.pack("H", password_hash:sub(34, 65)) else - stdnse.print_debug(1, "SMB: ERROR: Hash(es) provided in an invalid format (should be 32, 64, or 65 hex characters)") + stdnse.debug1("SMB: ERROR: Hash(es) provided in an invalid format (should be 32, 64, or 65 hex characters)") lm_hash = nil ntlm_hash = nil end @@ -662,18 +662,18 @@ function get_password_response(ip, username, domain, password, password_hash, ha -- At this point, we should have a good lm_hash and ntlm_hash if we're getting one if(lm_hash == nil or ntlm_hash == nil) then - stdnse.print_debug(2, "SMB: Couldn't determine which password to use, using a blank one") + stdnse.debug2("SMB: Couldn't determine which password to use, using a blank one") return "", "" end -- Output what we've got so far - stdnse.print_debug(2, "SMB: Lanman hash: %s", stdnse.tohex(lm_hash)) - stdnse.print_debug(2, "SMB: NTLM hash: %s", stdnse.tohex(ntlm_hash)) + stdnse.debug2("SMB: Lanman hash: %s", stdnse.tohex(lm_hash)) + stdnse.debug2("SMB: NTLM hash: %s", stdnse.tohex(ntlm_hash)) -- Hash the password the way the user wants if(hash_type == "v1") then -- LM and NTLM are hashed with their respective algorithms - stdnse.print_debug(2, "SMB: Creating v1 response") + stdnse.debug2("SMB: Creating v1 response") status, lm_response = lm_create_response(lm_hash, challenge) status, ntlm_response = ntlm_create_response(ntlm_hash, challenge) @@ -681,7 +681,7 @@ function get_password_response(ip, username, domain, password, password_hash, ha elseif(hash_type == "lm") then -- LM is hashed with its algorithm, NTLM is blank - stdnse.print_debug(2, "SMB: Creating LMv1 response") + stdnse.debug2("SMB: Creating LMv1 response") status, lm_response = lm_create_response(lm_hash, challenge) ntlm_response = "" @@ -689,7 +689,7 @@ function get_password_response(ip, username, domain, password, password_hash, ha elseif(hash_type == "ntlm") then -- LM and NTLM both use the NTLM algorithm - stdnse.print_debug(2, "SMB: Creating NTLMv1 response") + stdnse.debug2("SMB: Creating NTLMv1 response") status, lm_response = ntlm_create_response(ntlm_hash, challenge) status, ntlm_response = ntlm_create_response(ntlm_hash, challenge) @@ -697,22 +697,22 @@ function get_password_response(ip, username, domain, password, password_hash, ha elseif(hash_type == "v2") then -- LM and NTLM are hashed with their respective v2 algorithms - stdnse.print_debug(2, "SMB: Creating v2 response") + stdnse.debug2("SMB: Creating v2 response") status, lm_response = lmv2_create_response(ntlm_hash, username, domain, challenge) status, ntlm_response = ntlmv2_create_response(ntlm_hash, username, domain, challenge, 24) elseif(hash_type == "lmv2") then -- LM is hashed with its v2 algorithm, NTLM is blank - stdnse.print_debug(2, "SMB: Creating LMv2 response") + stdnse.debug2("SMB: Creating LMv2 response") status, lm_response = lmv2_create_response(ntlm_hash, username, domain, challenge) ntlm_response = "" else -- Default to NTLMv1 if(hash_type ~= nil) then - stdnse.print_debug(1, "SMB: Invalid login type specified ('%s'), using default (NTLM)", hash_type) + stdnse.debug1("SMB: Invalid login type specified ('%s'), using default (NTLM)", hash_type) else - stdnse.print_debug(1, "SMB: No login type specified, using default (NTLM)") + stdnse.debug1("SMB: No login type specified, using default (NTLM)") end status, lm_response = ntlm_create_response(ntlm_hash, challenge) @@ -720,8 +720,8 @@ function get_password_response(ip, username, domain, password, password_hash, ha end - stdnse.print_debug(2, "SMB: Lanman response: %s", stdnse.tohex(lm_response)) - stdnse.print_debug(2, "SMB: NTLM response: %s", stdnse.tohex(ntlm_response)) + stdnse.debug2("SMB: Lanman response: %s", stdnse.tohex(lm_response)) + stdnse.debug2("SMB: NTLM response: %s", stdnse.tohex(ntlm_response)) return lm_response, ntlm_response, mac_key end @@ -830,11 +830,11 @@ function get_host_info_from_security_blob(security_blob) -- Do some validation on the NTLMSSP message if ( identifier ~= "NTLMSSP\0" ) then - stdnse.print_debug( 1, "SMB: Invalid NTLM challenge message: unexpected signature." ) + stdnse.debug1("SMB: Invalid NTLM challenge message: unexpected signature." ) return false, "Invalid NTLM challenge message" -- Per MS-NLMP, this field must be 2 for an NTLM challenge message elseif ( message_type ~= 0x2 ) then - stdnse.print_debug( 1, "SMB: Invalid NTLM challenge message: unexpected message type: %d.", message_type ) + stdnse.debug1("SMB: Invalid NTLM challenge message: unexpected message type: %d.", message_type ) return false, "Invalid message type in NTLM challenge message" end diff --git a/nselib/smtp.lua b/nselib/smtp.lua index faea2e5c9..03c6eba32 100644 --- a/nselib/smtp.lua +++ b/nselib/smtp.lua @@ -227,12 +227,12 @@ check_reply = function(cmd, reply) return true, reply end else - stdnse.print_debug(3, + stdnse.debug3( "SMTP: check_smtp_reply failed: %s not supported", cmd) return false, string.format("SMTP: %s %s", cmd, reply) end end - stdnse.print_debug(3, + stdnse.debug3( "SMTP: check_smtp_reply failed: %s %s", cmd, reply) return false, string.format("SMTP: %s %s", cmd, reply) end @@ -259,14 +259,14 @@ query = function(socket, cmd, data, lines) local st, ret = socket:send(string.format("%s\r\n", cmd)) if not st then socket:close() - stdnse.print_debug(3, "SMTP: failed to send %s request.", cmd) + stdnse.debug3("SMTP: failed to send %s request.", cmd) return st, string.format("SMTP failed to send %s request.", cmd) end st, ret = socket:receive_lines(lines or 1) if not st then socket:close() - stdnse.print_debug(3, "SMTP %s: failed to receive data: %s.", + stdnse.debug3("SMTP %s: failed to receive data: %s.", cmd, (ERROR_MESSAGES[ret] or 'unspecified error')) return st, string.format("SMTP %s: failed to receive data: %s", cmd, (ERROR_MESSAGES[ret] or 'unspecified error')) @@ -580,7 +580,7 @@ end -- -- @param socket connected to server. quit = function(socket) - stdnse.print_debug(3, "SMTP: sending 'QUIT'.") + stdnse.debug3("SMTP: sending 'QUIT'.") socket:send("QUIT\r\n") socket:close() end diff --git a/nselib/snmp.lua b/nselib/snmp.lua index 82c600610..d7f830255 100644 --- a/nselib/snmp.lua +++ b/nselib/snmp.lua @@ -464,7 +464,7 @@ function snmpWalk( socket, base_oid ) status, err = socket:send(payload) if ( not( status ) ) then - stdnse.print_debug("snmp.snmpWalk: Send failed") + stdnse.debug1("snmp.snmpWalk: Send failed") return false, err end @@ -472,7 +472,7 @@ function snmpWalk( socket, base_oid ) if ( not( status ) ) then -- Unless we have a useful error message, don't report it if ( response ~= "ERROR" ) then - stdnse.print_debug("snmp.snmpWalk: Received no answer (%s)", response) + stdnse.debug1("snmp.snmpWalk: Received no answer (%s)", response) return false, response end return false, nil diff --git a/nselib/ssh2.lua b/nselib/ssh2.lua index 1ea561e9e..5bb2c0793 100644 --- a/nselib/ssh2.lua +++ b/nselib/ssh2.lua @@ -86,7 +86,7 @@ transport.payload = function( packet ) assert(packet_length and padding_length) payload_length = packet_length - padding_length - 1 if packet_length ~= packet:len() then - stdnse.print_debug("SSH-2 packet doesn't match length: payload_length is %d but total length is only %d.", packet_length, packet:len()) + stdnse.debug1("SSH-2 packet doesn't match length: payload_length is %d but total length is only %d.", packet_length, packet:len()) return nil end offset, payload = bin.unpack( ">A" .. payload_length, packet, offset ) @@ -179,7 +179,7 @@ fetch_host_key = function( host, port, key_type ) if not tostring(kex_init.server_host_key_algorithms):find( key_type, 1, true ) then -- server does not support host key type - stdnse.print_debug( 2, "Hostkey type '%s' not supported by server.", key_type ) + stdnse.debug2("Hostkey type '%s' not supported by server.", key_type ) return end @@ -225,7 +225,7 @@ fetch_host_key = function( host, port, key_type ) algorithm = "ECDSA" bits = "521" else - stdnse.print_debug( "Unsupported key type: %s", key_type ) + stdnse.debug1("Unsupported key type: %s", key_type ) end return { key=base64.enc(public_host_key), key_type=key_type, fp_input=public_host_key, bits=bits, diff --git a/nselib/sslcert.lua b/nselib/sslcert.lua index 4a73cda3e..48d87e892 100644 --- a/nselib/sslcert.lua +++ b/nselib/sslcert.lua @@ -56,8 +56,8 @@ StartTLS = { status, result = s:receive_lines(1) if not (string.match(result, "^234")) then - stdnse.print_debug(1,"%s",result) - stdnse.print_debug(1,"AUTH TLS failed or unavailable. Enable --script-trace to see what is happening.") + stdnse.debug1("%s",result) + stdnse.debug1("AUTH TLS failed or unavailable. Enable --script-trace to see what is happening.") -- Send QUIT to clean up server side connection local query = "QUIT\r\n" @@ -77,7 +77,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 SMTP server" else @@ -113,7 +113,7 @@ StartTLS = { status, result = s:receive_lines(1) if not (string.match(result, "STARTTLS")) then - stdnse.print_debug(1, "Server doesn't support STARTTLS") + stdnse.debug1("Server doesn't support STARTTLS") return false, "Failed to connect to IMAP server" end @@ -123,7 +123,7 @@ StartTLS = { status, result = s:receive_lines(1) if not (string.match(result, "OK")) then - stdnse.print_debug(1, string.format("Error: %s", result)) + stdnse.debug1(string.format("Error: %s", result)) return false, "Failed to connect to IMAP server" end end @@ -192,7 +192,7 @@ StartTLS = { ldapOp = asn1.intToBER(tmp) if ldapOp.number ~= ExtendedResponse then - stdnse.print_debug(1, string.format( + stdnse.debug1(string.format( "STARTTLS failed (got wrong op number: %d)", ldapOp.number)) return false, "STARTTLS failed" end @@ -202,7 +202,7 @@ StartTLS = { pos, resultCode = ldap.decode(response, pos) if resultCode ~= 0 then - stdnse.print_debug(1, string.format( + stdnse.debug1(string.format( "STARTTLS failed (LDAP error code is: %d)", resultCode)) return false, "STARTTLS failed" end @@ -253,7 +253,7 @@ StartTLS = { status, result = s:receive_lines(1) if not (string.match(result, "OK")) then - stdnse.print_debug(1, string.format("Error: %s", result)) + stdnse.debug1(string.format("Error: %s", result)) return false, "Failed to connect to POP3 server" end end @@ -307,8 +307,8 @@ StartTLS = { status, resultEHLO = s:receive_lines(1) if not (string.match(resultEHLO, "^250")) then - stdnse.print_debug(1,"%s",resultEHLO) - stdnse.print_debug(1,"EHLO with errors or timeout. Enable --script-trace to see what is happening.") + stdnse.debug1("%s",resultEHLO) + stdnse.debug1("EHLO with errors or timeout. Enable --script-trace to see what is happening.") return false, "Failed to connect to SMTP server" end @@ -320,8 +320,8 @@ StartTLS = { status, resultEHLO = s:receive_lines(1) if not (string.match(resultEHLO, "^220")) then - stdnse.print_debug(1,"%s",resultEHLO) - stdnse.print_debug(1,"STARTTLS failed or unavailable. Enable --script-trace to see what is happening.") + stdnse.debug1("%s",resultEHLO) + stdnse.debug1("STARTTLS failed or unavailable. Enable --script-trace to see what is happening.") -- Send QUIT to clean up server side connection local query = "QUIT\r\n" @@ -341,7 +341,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 SMTP server" else @@ -360,30 +360,30 @@ StartTLS = { status, err = sock:connect(host, port) if not status then sock:close() - stdnse.print_debug("Can't send: %s", err) + stdnse.debug1("Can't send: %s", err) return false, "Failed to connect to XMPP server" end status, err = sock:send(xmppStreamStart) if not status then - stdnse.print_debug("Couldn't send: %s", err) + stdnse.debug1("Couldn't send: %s", err) sock:close() return false, "Failed to connect to XMPP server" end status, result = sock:receive() if not status then - stdnse.print_debug("Couldn't receive: %s", err) + stdnse.debug1("Couldn't receive: %s", err) sock:close() return false, "Failed to connect to XMPP server" end status, err = sock:send(xmppStartTLS) if not status then - stdnse.print_debug("Couldn't send: %s", err) + stdnse.debug1("Couldn't send: %s", err) sock:close() return false, "Failed to connect to XMPP server" end status, result = sock:receive() if not status then - stdnse.print_debug("Couldn't receive: %s", err) + stdnse.debug1("Couldn't receive: %s", err) sock:close() return false, "Failed to connect to XMPP server" end @@ -393,7 +393,7 @@ StartTLS = { status, result = sock:receive() -- might not be in the first reply if not status then - stdnse.print_debug("Couldn't receive: %s", err) + stdnse.debug1("Couldn't receive: %s", err) sock:close() return false, "Failed to connect to XMPP server" end @@ -493,7 +493,7 @@ function getCertificate(host, port) if ( host.registry["ssl-cert"] and host.registry["ssl-cert"][port.number] ) then - stdnse.print_debug(2, "sslcert: Returning cached SSL certificate") + stdnse.debug2("sslcert: Returning cached SSL certificate") mutex "done" return true, host.registry["ssl-cert"][port.number] end diff --git a/nselib/stun.lua b/nselib/stun.lua index cff953f35..8c813a449 100644 --- a/nselib/stun.lua +++ b/nselib/stun.lua @@ -143,7 +143,7 @@ Attribute = { ( attr.type == Attribute.SOURCE_ADDRESS ) or ( attr.type == Attribute.CHANGED_ADDRESS ) ) then if ( attr.length ~= 8 ) then - stdnse.print_debug(2, "Incorrect attribute length") + stdnse.debug2("Incorrect attribute length") end attr.addr = parseAddress(data, pos) elseif( attr.type == Attribute.SERVER ) then diff --git a/nselib/target.lua b/nselib/target.lua index de98358cf..4c10654ed 100644 --- a/nselib/target.lua +++ b/nselib/target.lua @@ -82,7 +82,7 @@ add = function (...) -- Force the check here, but it would be better if scripts -- check ALLOW_NEW_TARGETS before calling target.add() if not ALLOW_NEW_TARGETS then - stdnse.print_debug(1, + stdnse.debug1( "ERROR: to add targets run with --script-args 'newtargets'") return false, "to add targets run with --script-args 'newtargets'" end @@ -97,7 +97,7 @@ add = function (...) new_targets.count = calc_max_targets(new_targets.count) if new_targets.count == 0 then - stdnse.print_debug(3, + stdnse.debug3( "Warning: Maximum new targets reached, no more new targets.") return false, "Maximum new targets reached, no more new targets." end @@ -105,7 +105,7 @@ add = function (...) local hosts, err = nmap.add_targets(table.unpack(new_targets,1,new_targets.count)) if hosts == 0 then - stdnse.print_debug(3, "%s", err) + stdnse.debug3("%s", err) return false, err end diff --git a/nselib/tftp.lua b/nselib/tftp.lua index 2050c74d7..9a8822f4e 100644 --- a/nselib/tftp.lua +++ b/nselib/tftp.lua @@ -158,7 +158,7 @@ local function dispatcher() end state = "STOPPED" s_condvar "broadcast" - stdnse.print_debug("Exiting _dispatcher") + stdnse.debug1("Exiting _dispatcher") end -- Processes a new incoming file transfer @@ -179,7 +179,7 @@ local function processConnection( host, port, data ) -- If we get anything else than a write request, abort the connection if ( OpCode.WRQ ~= op ) then - stdnse.print_debug("Unsupported opcode") + stdnse.debug1("Unsupported opcode") socket:send( tostring(Packet.ERROR:new(0, "TFTP server has write-only support"))) end @@ -203,7 +203,7 @@ local function processConnection( host, port, data ) lastread = os.time() pos, op = bin.unpack(">S", pdata) if ( OpCode.DATA ~= op ) then - stdnse.print_debug("Expected a data packet, terminating TFTP transfer") + stdnse.debug1("Expected a data packet, terminating TFTP transfer") end local block, data @@ -251,7 +251,7 @@ local function processConnection( host, port, data ) end filecontent = filecontent .. blocks[i] end - stdnse.print_debug("Finished receiving file \"%s\"", filename) + stdnse.debug1("Finished receiving file \"%s\"", filename) -- Add anew file to the global infiles table table.insert( infiles, File:new(filename, filecontent, host) ) diff --git a/nselib/tls.lua b/nselib/tls.lua index d16f25701..1120ad347 100644 --- a/nselib/tls.lua +++ b/nselib/tls.lua @@ -618,13 +618,13 @@ function record_read(buffer, i) local j, typ, proto = bin.unpack(">CS", buffer, i) local name = find_key(TLS_CONTENTTYPE_REGISTRY, typ) if name == nil then - stdnse.print_debug("Unknown TLS ContentType: %d", typ) + stdnse.debug1("Unknown TLS ContentType: %d", typ) return j, nil end h["type"] = name name = find_key(PROTOCOLS, proto) if name == nil then - stdnse.print_debug("Unknown TLS Protocol: 0x%x", typ) + stdnse.debug1("Unknown TLS Protocol: 0x%x", typ) return j, nil end h["protocol"] = name @@ -698,14 +698,14 @@ function record_read(buffer, i) b["compressor"] = find_key(COMPRESSORS, b["compressor"]) else -- TODO: implement other handshake message types - stdnse.print_debug(2, "Unknown handshake message type: %s", b["type"]) + stdnse.debug2("Unknown handshake message type: %s", b["type"]) j = msg_end end elseif h["type"] == "heartbeat" then j, b["type"], b["payload_length"] = bin.unpack("C>S", buffer, j) j, b["payload"], b["padding"] = bin.unpack("PP", buffer, j) else - stdnse.print_debug("Unknown message type: %s", h["type"]) + stdnse.debug1("Unknown message type: %s", h["type"]) end end diff --git a/nselib/tns.lua b/nselib/tns.lua index 21daabb2d..09d16a868 100644 --- a/nselib/tns.lua +++ b/nselib/tns.lua @@ -1137,7 +1137,7 @@ Packet.QueryResponseAck = { pos, marker = bin.unpack("C", data, pos) end if ( marker ~= 0x07 ) then - stdnse.print_debug(2, "Encountered unknown marker: %d", marker) + stdnse.debug2("Encountered unknown marker: %d", marker) break end @@ -1624,7 +1624,7 @@ Helper = { end if ( not(status) ) then - stdnse.print_debug(2, "ERROR: Version %s is not yet supported", self.os) + stdnse.debug2("ERROR: Version %s is not yet supported", self.os) return false, ("ERROR: Connect to version %s is not yet supported"):format(self.os) end @@ -1781,7 +1781,7 @@ Helper = { end if ( not(status) ) then - stdnse.print_debug(2, "ERROR: Version %s is not yet supported", self.os) + stdnse.debug2("ERROR: Version %s is not yet supported", self.os) return false, ("ERROR: Querying version %s is not yet supported"):format(self.os) end diff --git a/nselib/unittest.lua b/nselib/unittest.lua index 58abca44d..033470313 100644 --- a/nselib/unittest.lua +++ b/nselib/unittest.lua @@ -158,7 +158,7 @@ run_tests = function(to_test) end local fails = stdnse.output_table() for _,lib in ipairs(to_test) do - stdnse.print_debug(1, "Testing %s", lib) + stdnse.debug1("Testing %s", lib) local thelib = require(lib) local failed = 0 if rawget(thelib,"test_suite") ~= nil then @@ -216,7 +216,7 @@ TestSuite = { local passes = 0 self:setup() for _,test in ipairs(self.tests) do - stdnse.print_debug(2, "| Test: %s...", test[2]) + stdnse.debug2("| Test: %s...", test[2]) local status, note = test[1](self) local result local lvl = 2 @@ -227,7 +227,7 @@ TestSuite = { result = "Fail" lvl = 1 if nmap.debugging() < 2 then - stdnse.print_debug(1, "| Test: %s...", test[2]) + stdnse.debug1("| Test: %s...", test[2]) end failures = failures + 1 end @@ -237,7 +237,7 @@ TestSuite = { stdnse.print_debug(lvl, "| \\_result: %s", result) end end - stdnse.print_debug(1, "|_%d of %d tests passed", passes, #self.tests) + stdnse.debug1("|_%d of %d tests passed", passes, #self.tests) self:teardown() return failures, #self.tests end, diff --git a/nselib/upnp.lua b/nselib/upnp.lua index 174ce149c..d5ffedc0d 100644 --- a/nselib/upnp.lua +++ b/nselib/upnp.lua @@ -233,7 +233,7 @@ Comm = { -- check to see if the IP address returned matches the IP address we scanned if xhost ~= self.host.ip then - stdnse.print_debug("IP addresses did not match! Found %s, using %s instead.", xhost, self.host.ip) + stdnse.debug1("IP addresses did not match! Found %s, using %s instead.", xhost, self.host.ip) xhost = self.host.ip end diff --git a/nselib/vnc.lua b/nselib/vnc.lua index 005d98cd6..2efc7f39b 100644 --- a/nselib/vnc.lua +++ b/nselib/vnc.lua @@ -127,13 +127,13 @@ VNC = { self.protover = VNC.versions[data] if ( not(self.protover) ) then - stdnse.print_debug("ERROR: VNC:handshake unsupported version (%s)", data:sub(1,11)) + stdnse.debug1("ERROR: VNC:handshake unsupported version (%s)", data:sub(1,11)) return false, ("Unsupported version (%s)"):format(data:sub(1,11)) end status = self.socket:send( self.cli_version ) if ( not(status) ) then - stdnse.print_debug("ERROR: VNC:handshake failed to send client version") + stdnse.debug1("ERROR: VNC:handshake failed to send client version") return false, "ERROR: VNC:handshake failed" end @@ -167,7 +167,7 @@ VNC = { else local status, tmp = self.socket:receive_buf(match.numbytes(1), true) if ( not(status) ) then - stdnse.print_debug("ERROR: VNC:handshake failed to receive security data") + stdnse.debug1("ERROR: VNC:handshake failed to receive security data") return false, "ERROR: VNC:handshake failed to receive security data" end @@ -178,7 +178,7 @@ VNC = { status, tmp = self.socket:receive_buf(match.numbytes(vncsec.count), true) if ( not(status) ) then - stdnse.print_debug("ERROR: VNC:handshake failed to receive security data") + stdnse.debug1("ERROR: VNC:handshake failed to receive security data") return false, "ERROR: VNC:handshake failed to receive security data" end diff --git a/nselib/vulns.lua b/nselib/vulns.lua index 6e1341348..909c92e7b 100644 --- a/nselib/vulns.lua +++ b/nselib/vulns.lua @@ -1371,7 +1371,7 @@ local l_make_output = function(fid_table, entries, filter) end if next(hosts) then - stdnse.print_debug(3, + stdnse.debug3( "vulns.lua: sorting vulnerability entries for %d host", #hosts) sort(hosts, sort_hosts) diff --git a/nselib/vuzedht.lua b/nselib/vuzedht.lua index bee10700d..ffc01ea06 100644 --- a/nselib/vuzedht.lua +++ b/nselib/vuzedht.lua @@ -167,7 +167,7 @@ Response = { self.length = 16 + 2 + 1 pos, self.ip = bin.unpack("H16", self.data, pos) else - stdnse.print_debug("Unknown address type (length: %d)", addr_len) + stdnse.debug1("Unknown address type (length: %d)", addr_len) return false, "Unknown address type" end pos, self.port = bin.unpack(">S", self.data, pos) @@ -306,7 +306,7 @@ Response = { fromString = function(data) local find = Response.FIND_NODE:new(data) if ( find.header.proto_version < 13 ) then - stdnse.print_debug("ERROR: Unsupported version %d", find.header.proto_version) + stdnse.debug1("ERROR: Unsupported version %d", find.header.proto_version) return false end @@ -390,7 +390,7 @@ Response = { return Response.ERROR.fromString(data) end - stdnse.print_debug("ERROR: Unknown response received from server") + stdnse.debug1("ERROR: Unknown response received from server") return false, "Failed to parse response" end, diff --git a/nselib/wsdd.lua b/nselib/wsdd.lua index 0f6ac978c..8a313e434 100644 --- a/nselib/wsdd.lua +++ b/nselib/wsdd.lua @@ -255,7 +255,7 @@ Comm = { local _, ip status, _, _, ip, _ = self.socket:get_info() if( not(status) ) then - stdnse.print_debug( 3, "wsdd.recvProbeMatches: ERROR: Failed to get socket info" ) + stdnse.debug3("wsdd.recvProbeMatches: ERROR: Failed to get socket info" ) return false, "ERROR: Failed to get socket info" end