diff --git a/scripts/afp-brute.nse b/scripts/afp-brute.nse index c032b480e..9be8364ee 100644 --- a/scripts/afp-brute.nse +++ b/scripts/afp-brute.nse @@ -70,19 +70,19 @@ action = function( host, port ) status, response = helper:OpenSession( host, port ) if ( not(status) ) then - stdnse.print_debug("OpenSession failed") + stdnse.debug1("OpenSession failed") return end - stdnse.print_debug("Trying %s/%s ...", username, password) + stdnse.debug1("Trying %s/%s ...", username, password) status, response = helper:Login( username, password ) -- if the response is "Parameter error." we're dealing with Netatalk -- This basically means that the user account does not exist -- In this case, why bother continuing? Simply abort and thank Netatalk for the fish if response:match("Parameter error.") then - stdnse.print_debug("Netatalk told us the user does not exist! Thanks.") + stdnse.debug1("Netatalk told us the user does not exist! Thanks.") -- mark it as "found" to skip it found_users[username] = true end diff --git a/scripts/backorifice-brute.nse b/scripts/backorifice-brute.nse index 1e3ac8d30..7565cf028 100644 --- a/scripts/backorifice-brute.nse +++ b/scripts/backorifice-brute.nse @@ -51,7 +51,7 @@ categories = {"intrusive", "brute"} -- which is specified by the ports script argument portrule = function(host, port) if not stdnse.get_script_args(SCRIPT_NAME .. ".ports") then - stdnse.print_debug(3,"Skipping '%s' %s, 'ports' argument is missing.",SCRIPT_NAME, SCRIPT_TYPE) + stdnse.debug3("Skipping '%s' %s, 'ports' argument is missing.",SCRIPT_NAME, SCRIPT_TYPE) return false end @@ -59,7 +59,7 @@ portrule = function(host, port) --print out a debug message if port 31337/udp is open if port.number==31337 and port.protocol == "udp" and not(ports) then - stdnse.print_debug("Port 31337/udp is open. Possibility of version detection and password bruteforcing using the backorifice-brute script") + stdnse.debug1("Port 31337/udp is open. Possibility of version detection and password bruteforcing using the backorifice-brute script") return false end diff --git a/scripts/bacnet-info.nse b/scripts/bacnet-info.nse index ac87eba28..322c27ab3 100644 --- a/scripts/bacnet-info.nse +++ b/scripts/bacnet-info.nse @@ -894,13 +894,13 @@ function standard_query(socket, type) --try to pull the information local status, result = socket:send(query) if(status == false) then - stdnse.print_debug(1, "Socket error sending query: %s", result) + stdnse.debug1("Socket error sending query: %s", result) return nil end -- receive packet from response local rcvstatus, response = socket:receive() if(rcvstatus == false) then - stdnse.print_debug(1, "Socket error receiving: %s", response) + stdnse.debug1("Socket error receiving: %s", response) return nil end -- validate valid BACNet Packet @@ -913,12 +913,12 @@ function standard_query(socket, type) return field_size(response) -- if it was an error packet, set the string to error for later purposes else - stdnse.print_debug(1, "Error receiving: BACNet Error") + stdnse.debug1("Error receiving: BACNet Error") return nil end -- else ERROR else - stdnse.print_debug(1, "Error receiving Vendor ID: Invalid BACNet packet") + stdnse.debug1("Error receiving Vendor ID: Invalid BACNet packet") return nil end @@ -938,13 +938,13 @@ function vendornum_query(socket) --send the vendor information local status, result = socket:send(vendor_query) if(status == false) then - stdnse.print_debug(1, "Socket error sending vendor query: %s", result) + stdnse.debug1("Socket error sending vendor query: %s", result) return nil end -- receive vendor information packet local rcvstatus, response = socket:receive() if(rcvstatus == false) then - stdnse.print_debug(1, "Socket error receiving vendor query: %s", response) + stdnse.debug1("Socket error receiving vendor query: %s", response) return nil end -- validate valid BACNet Packet @@ -956,7 +956,7 @@ function vendornum_query(socket) -- this value determines if vendor number is 1 or 2 bytes pos, value = bin.unpack("C", response, 18) else - stdnse.print_debug(1, "Error receiving Vendor ID: BACNet Error") + stdnse.debug1("Error receiving Vendor ID: BACNet Error") return nil end -- if value is 21 (byte 18) @@ -974,7 +974,7 @@ function vendornum_query(socket) return vendor_lookup(vendornum) else -- set return value to an Error if byte 18 was not 21/22 - stdnse.print_debug(1, "Error receiving Vendor ID: Invalid BACNet packet") + stdnse.debug1("Error receiving Vendor ID: Invalid BACNet packet") return nil end end @@ -1024,7 +1024,7 @@ action = function(host, port) -- receive response local rcvstatus, response = sock:receive() if(rcvstatus == false) then - stdnse.print_debug(1, "Receive error: %s", response) + stdnse.debug1("Receive error: %s", response) return nil end diff --git a/scripts/broadcast-avahi-dos.nse b/scripts/broadcast-avahi-dos.nse index b9e4c1def..acddc6e4d 100644 --- a/scripts/broadcast-avahi-dos.nse +++ b/scripts/broadcast-avahi-dos.nse @@ -76,7 +76,7 @@ action = function() table.insert(output, "After NULL UDP avahi packet DoS (CVE-2011-1002).") - stdnse.print_debug(3, "sleeping for %d seconds", wtime) + stdnse.debug3("sleeping for %d seconds", wtime) stdnse.sleep(wtime) -- try to re-discover hosts status, result = helper:queryServices() diff --git a/scripts/broadcast-dropbox-listener.nse b/scripts/broadcast-dropbox-listener.nse index 730edb21a..391d51f16 100644 --- a/scripts/broadcast-dropbox-listener.nse +++ b/scripts/broadcast-dropbox-listener.nse @@ -50,7 +50,7 @@ action = function() sock:set_timeout(2 * DROPBOX_BROADCAST_PERIOD * 1000) local status, result = sock:bind(nil, DROPBOX_PORT) if not status then - stdnse.print_debug(1, "Could not bind on port %d: %s", DROPBOX_PORT, result) + stdnse.debug1("Could not bind on port %d: %s", DROPBOX_PORT, result) sock:close() return end @@ -78,10 +78,10 @@ action = function() -- Get IP address of broadcasting host. local status, _, _, ip, _ = sock:get_info() if not status then - stdnse.print_debug(1, "Failed to get socket info.") + stdnse.debug1("Failed to get socket info.") break end - stdnse.print_debug(1, "Received broadcast from host %s (%s).", info.displayname, ip) + stdnse.debug1("Received broadcast from host %s (%s).", info.displayname, ip) -- Check if we've already seen this ID. if ids[info.host_int] then @@ -114,7 +114,7 @@ action = function() stdnse.strjoin(", ", info.namespaces) ) - stdnse.print_debug(1, "Added host %s.", info.displayname) + stdnse.debug1("Added host %s.", info.displayname) end status, result = sock:receive() diff --git a/scripts/broadcast-eigrp-discovery.nse b/scripts/broadcast-eigrp-discovery.nse index a343b5c9e..2b09af30d 100644 --- a/scripts/broadcast-eigrp-discovery.nse +++ b/scripts/broadcast-eigrp-discovery.nse @@ -261,7 +261,7 @@ action = function() until next(lthreads) == nil; if #astab > 0 then - stdnse.print_debug("Will use %s A.S value.", astab[1]) + stdnse.debug1("Will use %s A.S value.", astab[1]) as = astab[1] else return "\n ERROR: Couldn't get an A.S value." diff --git a/scripts/broadcast-igmp-discovery.nse b/scripts/broadcast-igmp-discovery.nse index 6bc1d9c7a..8d88d0f01 100644 --- a/scripts/broadcast-igmp-discovery.nse +++ b/scripts/broadcast-igmp-discovery.nse @@ -209,7 +209,7 @@ end local igmpRaw = function(interface, version) -- Only 1, 2 and 3 are valid IGMP versions if version ~= 1 and version ~= 2 and version ~= 3 then - stdnse.print_debug("IGMP version %s doesn't exist.", version) + stdnse.debug1("IGMP version %s doesn't exist.", version) return end diff --git a/scripts/broadcast-listener.nse b/scripts/broadcast-listener.nse index 7d814f8f4..21b66ca0b 100644 --- a/scripts/broadcast-listener.nse +++ b/scripts/broadcast-listener.nse @@ -161,7 +161,7 @@ sniffInterface = function(iface, Decoders, decodertab) -- The packet was decoded successfully but we don't have a valid decoder -- Report this elseif ( p and p.udp_dport ) then - stdnse.print_debug(2, "No decoder for dst port %d", p.udp_dport) + stdnse.debug2("No decoder for dst port %d", p.udp_dport) -- we don't have a packet, so this is most likely something layer2 based -- in that case, check the ether Decoder table for pattern matches else @@ -184,7 +184,7 @@ sniffInterface = function(iface, Decoders, decodertab) end -- no decoder was found for this layer2 packet if ( not(decoded) and #data > 10 ) then - stdnse.print_debug(1, "No decoder for packet hex: %s", select(2, bin.unpack("H10", data) ) ) + stdnse.debug1("No decoder for packet hex: %s", select(2, bin.unpack("H10", data) ) ) end end end diff --git a/scripts/broadcast-netbios-master-browser.nse b/scripts/broadcast-netbios-master-browser.nse index b7768229d..c61c3f77f 100644 --- a/scripts/broadcast-netbios-master-browser.nse +++ b/scripts/broadcast-netbios-master-browser.nse @@ -60,7 +60,7 @@ action = function() if ( srv_name and domain_name ) then tab.addrow(outtab, v.peer, srv_name, domain_name) else - stdnse.print_debug(3, "No server name or domain name was found") + stdnse.debug3("No server name or domain name was found") end end end diff --git a/scripts/broadcast-ping.nse b/scripts/broadcast-ping.nse index a62530a6e..37a82f1ea 100644 --- a/scripts/broadcast-ping.nse +++ b/scripts/broadcast-ping.nse @@ -197,7 +197,7 @@ local broadcast_if = function(if_table,icmp_responders) icmp_responders[icmpreply.ip_src] = mac_pretty end else - stdnse.print_debug("Erroneous ICMP packet received; Cannot parse IP header.") + stdnse.debug1("Erroneous ICMP packet received; Cannot parse IP header.") end end @@ -221,7 +221,7 @@ action = function() local interface = interface_opt or interface_arg local if_table = nmap.get_interface_info(interface) if not if_table or not if_table.address or not if_table.link=="ethernet" then - stdnse.print_debug("Interface not supported or not properly configured.") + stdnse.debug1("Interface not supported or not properly configured.") return false end table.insert(interfaces, if_table) @@ -237,7 +237,7 @@ action = function() end if #interfaces == 0 then - stdnse.print_debug("No interfaces found.") + stdnse.debug1("No interfaces found.") return end diff --git a/scripts/broadcast-ripng-discover.nse b/scripts/broadcast-ripng-discover.nse index 3de48e91c..d172db653 100644 --- a/scripts/broadcast-ripng-discover.nse +++ b/scripts/broadcast-ripng-discover.nse @@ -209,7 +209,7 @@ action = function() local result = {} for ip, resp in pairs(responses) do - stdnse.print_debug(ip, resp) + stdnse.debug1(ip, resp) table.insert(result, { name = ip, parse_response(resp) } ) end return stdnse.format_output(true, result) diff --git a/scripts/broadcast-sybase-asa-discover.nse b/scripts/broadcast-sybase-asa-discover.nse index d2300ecc0..899a9f1cb 100644 --- a/scripts/broadcast-sybase-asa-discover.nse +++ b/scripts/broadcast-sybase-asa-discover.nse @@ -73,14 +73,14 @@ Ping = { len = bit.band(len, 0x0000FFFF) if ( len ~= #self.data ) then - stdnse.print_debug(2, "The packet length was reported as %d, expected %d", len, #self.data) + stdnse.debug2("The packet length was reported as %d, expected %d", len, #self.data) return end local connectionless_tds pos, connectionless_tds = bin.unpack("p", self.data, 9) if ( connectionless_tds ~= "CONNECTIONLESS_TDS" ) then - stdnse.print_debug(2, "Did not find the expected CONNECTIONLESS_TDS header") + stdnse.debug2("Did not find the expected CONNECTIONLESS_TDS header") return end diff --git a/scripts/broadcast-tellstick-discover.nse b/scripts/broadcast-tellstick-discover.nse index 3ccfed57b..05b37e47b 100644 --- a/scripts/broadcast-tellstick-discover.nse +++ b/scripts/broadcast-tellstick-discover.nse @@ -48,7 +48,7 @@ action = function() local status, _, _, ip = socket:get_info() if ( not(status) ) then - stdnse.print_debug(2, "Failed to get socket information") + stdnse.debug2("Failed to get socket information") break end diff --git a/scripts/cassandra-brute.nse b/scripts/cassandra-brute.nse index 51554021d..9eaf9a8af 100644 --- a/scripts/cassandra-brute.nse +++ b/scripts/cassandra-brute.nse @@ -79,19 +79,19 @@ Driver = { magic = string.sub(response,18,22) if (magic == cassandra.LOGINSUCC) then - stdnse.print_debug(3, "Account SUCCESS: "..combo) + stdnse.debug3("Account SUCCESS: "..combo) return true, brute.Account:new(username, password, creds.State.VALID) elseif (magic == cassandra.LOGINFAIL) then - stdnse.print_debug(3,"Account FAIL: "..combo) + stdnse.debug3("Account FAIL: "..combo) return false, brute.Error:new( "Incorrect password" ) elseif (magic == cassandra.LOGINACC) then - stdnse.print_debug(3, "Account VALID, but wrong password: "..combo) + stdnse.debug3("Account VALID, but wrong password: "..combo) return false, brute.Error:new( "Good user, bad password" ) else - stdnse.print_debug(3, "Unrecognized 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("Unrecognized 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) ) local err = brute.Error:new( response ) err:setRetry( true ) return false, err diff --git a/scripts/citrix-brute-xml.nse b/scripts/citrix-brute-xml.nse index dd2534b04..11218cf97 100644 --- a/scripts/citrix-brute-xml.nse +++ b/scripts/citrix-brute-xml.nse @@ -78,7 +78,7 @@ function verify_password( host, port, username, password, domain ) account.valid = false account.message = "Unspecified" else - stdnse.print_debug("UNKNOWN response: " .. response) + stdnse.debug1("UNKNOWN response: " .. response) account.valid = false account.message = "failed" end @@ -146,12 +146,12 @@ action = function(host, port) table.insert(valid_accounts, account) if account.valid then - stdnse.print_debug(1, "Trying %s/%s => Login Correct, Info: %s", username, password, account.message) + stdnse.debug1("Trying %s/%s => Login Correct, Info: %s", username, password, account.message) else - stdnse.print_debug(1, "Trying %s/%s => Login Correct", username, password) + stdnse.debug1("Trying %s/%s => Login Correct", username, password) end else - stdnse.print_debug(1, "Trying %s/%s => Login Failed, Reason: %s", username, password, account.message) + stdnse.debug1("Trying %s/%s => Login Failed, Reason: %s", username, password, account.message) end password = nextPass() end diff --git a/scripts/daap-get-library.nse b/scripts/daap-get-library.nse index 3aa8a9958..dc2efe4e8 100644 --- a/scripts/daap-get-library.nse +++ b/scripts/daap-get-library.nse @@ -93,7 +93,7 @@ local function getAttributeAsInt( data, name ) pos, len = bin.unpack( ">I", data, pos ) if ( len ~= 4 ) then - stdnse.print_debug("Unexpected length returned: %d", len ) + stdnse.debug1("Unexpected length returned: %d", len ) return end @@ -199,7 +199,7 @@ parseItem = function( data, len ) if itemFetcher[name] then pos, item[name] = itemFetcher[name](data, pos ) else - stdnse.print_debug("No itemfetcher for: %s", name) + stdnse.debug1("No itemfetcher for: %s", name) break end diff --git a/scripts/dns-brute.nse b/scripts/dns-brute.nse index f931df08c..e0f5f1c95 100644 --- a/scripts/dns-brute.nse +++ b/scripts/dns-brute.nse @@ -115,10 +115,10 @@ local function thread_main(domainname, results, name_iter) for _,addr in ipairs(res) do local hostn = name..'.'..domainname if target.ALLOW_NEW_TARGETS then - stdnse.print_debug("Added target: "..hostn) + stdnse.debug1("Added target: "..hostn) local status,err = target.add(hostn) end - stdnse.print_debug("Hostname: "..hostn.." IP: "..addr) + stdnse.debug1("Hostname: "..hostn.." IP: "..addr) local record = { hostname=hostn, address=addr } setmetatable(record, { __tostring = function(t) @@ -146,10 +146,10 @@ local function srv_main(domainname, srvresults, srv_iter) if(srvres) then for srvhost,srvip in ipairs(srvres) do if target.ALLOW_NEW_TARGETS then - stdnse.print_debug("Added target: "..srvip) + stdnse.debug1("Added target: "..srvip) local status,err = target.add(srvip) end - stdnse.print_debug("Hostname: "..hostn.." IP: "..srvip) + stdnse.debug1("Hostname: "..hostn.." IP: "..srvip) local record = { hostname=hostn, address=srvip } setmetatable(record, { __tostring = function(t) @@ -180,15 +180,15 @@ action = function(host) end if nmap.registry.bruteddomains[domainname] then - stdnse.print_debug("Skipping already-bruted domain %s", domainname) + stdnse.debug1("Skipping already-bruted domain %s", domainname) return nil end nmap.registry.bruteddomains[domainname] = true - stdnse.print_debug("Starting dns-brute at: "..domainname) + stdnse.debug1("Starting dns-brute at: "..domainname) local max_threads = stdnse.get_script_args('dns-brute.threads') and tonumber( stdnse.get_script_args('dns-brute.threads') ) or 5 local dosrv = stdnse.get_script_args("dns-brute.srv") or false - stdnse.print_debug("THREADS: "..max_threads) + stdnse.debug1("THREADS: "..max_threads) -- First look for dns-brute.hostlist local fileName = stdnse.get_script_args('dns-brute.hostlist') -- Check fetchfile locations, then relative paths @@ -211,7 +211,7 @@ action = function(host) local condvar = nmap.condvar( results ) local i = 1 local howmany = math.floor(#hostlist/max_threads)+1 - stdnse.print_debug("Hosts per thread: "..howmany) + stdnse.debug1("Hosts per thread: "..howmany) repeat local j = math.min(i+howmany, #hostlist) local name_iter = array_iter(hostlist, i, j) @@ -249,7 +249,7 @@ action = function(host) threads = {} howmany = math.floor(#srvlist/max_threads)+1 condvar = nmap.condvar( srvresults ) - stdnse.print_debug("SRV's per thread: "..howmany) + stdnse.debug1("SRV's per thread: "..howmany) repeat local j = math.min(i+howmany, #srvlist) local name_iter = array_iter(srvlist, i, j) diff --git a/scripts/dns-nsec-enum.nse b/scripts/dns-nsec-enum.nse index 7a73b608c..ad094dd96 100644 --- a/scripts/dns-nsec-enum.nse +++ b/scripts/dns-nsec-enum.nse @@ -307,7 +307,7 @@ local function enum(host, port, domain) while subdomain do local result = {} local status, result, nsec - stdnse.print_debug("Trying %q.%q", subdomain, domain) + stdnse.debug1("Trying %q.%q", subdomain, domain) status, result = dns.query(join({subdomain, domain}), {host = host.ip, port=port.number, proto=port.protocol, dtype='A', retAll=true, retPkt=true, dnssec=true}) nsec = status and get_next_nsec(result, join({subdomain, domain})) or nil if nsec then @@ -316,18 +316,18 @@ local function enum(host, port, domain) first, remainder = remove_suffix(nsec.dname, domain) if #remainder > 0 then - stdnse.print_debug("Result name %q doesn't end in %q.", nsec.dname, domain) + stdnse.debug1("Result name %q doesn't end in %q.", nsec.dname, domain) subdomain = nil break end last, remainder = remove_suffix(nsec.next_dname, domain) if #remainder > 0 then - stdnse.print_debug("Result name %q doesn't end in %q.", nsec.next_dname, domain) + stdnse.debug1("Result name %q doesn't end in %q.", nsec.next_dname, domain) subdomain = nil break end if #last == 0 then - stdnse.print_debug("Wrapped") + stdnse.debug1("Wrapped") subdomain = nil break end @@ -345,7 +345,7 @@ local function enum(host, port, domain) all_results[index] = excise(all_results, index, -1) end else - stdnse.print_debug("adding %s", last) + stdnse.debug1("adding %s", last) subdomain = next_domain(last) table.insert(all_results, join({last, domain})) seen[last] = #all_results diff --git a/scripts/dns-nsec3-enum.nse b/scripts/dns-nsec3-enum.nse index 7d4ac9442..f0cc4257a 100644 --- a/scripts/dns-nsec3-enum.nse +++ b/scripts/dns-nsec3-enum.nse @@ -220,12 +220,12 @@ local function query_for_hashes(host,subdomain,domain) local h2 = string.lower(nsec3.hash.base32) if not stdnse.contains(all_results,"nexthash " .. h1 .. " " .. h2) then table.insert(all_results, "nexthash " .. h1 .. " " .. h2) - stdnse.print_debug("nexthash " .. h1 .. " " .. h2) + stdnse.debug1("nexthash " .. h1 .. " " .. h2) end ranges[h1] = h2 end else - stdnse.print_debug(1, "DNS error: %s", result) + stdnse.debug1("DNS error: %s", result) end return ranges end @@ -258,11 +258,11 @@ local function enum(host, port, domain) local h2 = string.lower(nsec3.hash.base32) if table_size(todo) == 0 then table.insert(all_results, "domain " .. domain) - stdnse.print_debug("domain " .. domain) + stdnse.debug1("domain " .. domain) table.insert(all_results, "salt " .. salt) - stdnse.print_debug("salt " .. salt) + stdnse.debug1("salt " .. salt) table.insert(all_results, "iterations " .. iter) - stdnse.print_debug("iterations " .. iter) + stdnse.debug1("iterations " .. iter) if h1 < h2 then todo[h2] = h1 else @@ -299,7 +299,7 @@ local function enum(host, port, domain) end -- for end -- else table.insert(all_results, "nexthash " .. h1 .. " " .. h2) - stdnse.print_debug("nexthash " .. h1 .. " " .. h2) + stdnse.debug1("nexthash " .. h1 .. " " .. h2) end end @@ -342,7 +342,7 @@ local function enum(host, port, domain) end end --if changed then - -- stdnse.print_debug("break[]") + -- stdnse.debug1("break[]") --break -- end end diff --git a/scripts/dns-update.nse b/scripts/dns-update.nse index f39995ee2..483f92fde 100644 --- a/scripts/dns-update.nse +++ b/scripts/dns-update.nse @@ -53,26 +53,26 @@ portrule = shortport.port_or_service( 53, "dns", "udp", {"open", "open|filtered" local function test(host, port) local status, err = dns.update( "www.cqure.net", { host=host, port=port, dtype="A", data="10.10.10.10" } ) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end status, err = dns.update( "www2", { zone="cqure.net", host=host, port=port, dtype="A", data="10.10.10.10" } ) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end status, err = dns.update( "alias.cqure.net", { host=host, port=port, dtype="CNAME", data="www.cqure.net" } ) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end status, err = dns.update( "cqure.net", { host=host, port=port, dtype="MX", data={ pref=10, mx="mail.cqure.net"} }) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end status, err = dns.update( "_ldap._tcp.cqure.net", { host=host, port=port, dtype="SRV", data={ prio=0, weight=100, port=389, target="ldap.cqure.net" } } ) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end status, err = dns.update( "www.cqure.net", { host=host, port=port, dtype="A", data="", ttl=0 } ) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end status, err = dns.update( "www2.cqure.net", { host=host, port=port, dtype="A", data="", ttl=0 } ) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end status, err = dns.update( "alias.cqure.net", { host=host, port=port, dtype="CNAME", data="", ttl=0 } ) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end status, err = dns.update( "cqure.net", { host=host, port=port, dtype="MX", data="", ttl=0 } ) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end status, err = dns.update( "_ldap._tcp.cqure.net", { host=host, port=port, dtype="SRV", data="", ttl=0 } ) - if ( status ) then stdnse.print_debug("SUCCESS") else stdnse.print_debug("FAIL: " .. (err or "")) end + if ( status ) then stdnse.debug1("SUCCESS") else stdnse.debug1("FAIL: " .. (err or "")) end end diff --git a/scripts/dns-zone-transfer.nse b/scripts/dns-zone-transfer.nse index 987f29f66..8cb12c4e1 100644 --- a/scripts/dns-zone-transfer.nse +++ b/scripts/dns-zone-transfer.nse @@ -368,7 +368,7 @@ local RD = { local version, siz, hp, vp, lat, lon, alt version = string.byte(data, offset) if version ~= 0 then - stdnse.print_debug(2, "Unknown LOC RR version: %d", version) + stdnse.debug2("Unknown LOC RR version: %d", version) return offset, '' end siz = string.byte(data, offset+1) @@ -616,7 +616,7 @@ function add_zone_info(response) for rdata in pairs(RR['Node Names']) do status, ret = target.add(rdata) if not status then - stdnse.print_debug(3, "Error: failed to add all Node Names.") + stdnse.debug3("Error: failed to add all Node Names.") break end newhosts_count = newhosts_count + ret diff --git a/scripts/drda-brute.nse b/scripts/drda-brute.nse index 8982b0f53..db72ebc75 100644 --- a/scripts/drda-brute.nse +++ b/scripts/drda-brute.nse @@ -74,7 +74,7 @@ doLogin = function( host, port, database, creds, valid_accounts ) if ( nmap.registry.db2users == nil or nmap.registry.db2users[username] == nil ) then helper = drda.Helper:new() helper:connect( host, port ) - stdnse.print_debug( "Trying %s/%s against %s...", username, password, host.ip ) + stdnse.debug1( "Trying %s/%s against %s...", username, password, host.ip ) status, response = helper:login( database, username, password ) helper:close() @@ -156,7 +156,7 @@ action = function( host, port ) creds = new_usrpwd_iterator( usernames, passwords ) - stdnse.print_debug("Starting brute force with %d threads", max_threads ) + stdnse.debug1("Starting brute force with %d threads", max_threads ) for i=1,max_threads do local co = stdnse.new_thread( doLogin, host, port, database, creds, valid_accounts ) diff --git a/scripts/eap-info.nse b/scripts/eap-info.nse index 3fd03ffa6..27237687b 100644 --- a/scripts/eap-info.nse +++ b/scripts/eap-info.nse @@ -73,11 +73,11 @@ action = function() if not iface then return "please specify an interface with -e" end - stdnse.print_debug(1, "iface: %s", iface.device) + stdnse.debug1("iface: %s", iface.device) local timeout = (arg_timeout or 10) * 1000 - stdnse.print_debug(2, "timeout: %s", timeout) + stdnse.debug2("timeout: %s", timeout) local pcap = nmap.new_socket() pcap:pcap_open(iface.device, 512, true, "ether proto 0x888e") @@ -100,7 +100,7 @@ action = function() for i,v in ipairs(scan) do v = tonumber(v) if v ~= nil and v < 256 and v > 3 then - stdnse.print_debug(1, "selected: %s", eap.eap_str[v] or "unassigned" ) + stdnse.debug1("selected: %s", eap.eap_str[v] or "unassigned" ) identity.auth[v] = UNKNOWN valid = true end @@ -118,26 +118,26 @@ action = function() while(nmap.clock_ms() - start_time < timeout) and not tried_all do local status, plen, l2_data, l3_data, time = pcap:pcap_receive() if (status) then - stdnse.print_debug(2, "packet size: 0x%x", plen ) + stdnse.debug2("packet size: 0x%x", plen ) local packet = eap.parse(l2_data .. l3_data) if packet then - stdnse.print_debug(2, "packet valid") + stdnse.debug2("packet valid") -- respond to identity requests, using the same session id if packet.eap.type == eap.eap_t.IDENTITY and packet.eap.code == eap.code_t.REQUEST then - stdnse.print_debug(1, "server identity: %s",packet.eap.body.identity) + stdnse.debug1("server identity: %s",packet.eap.body.identity) eap.send_identity_response(iface, packet.eap.id, identity.name) end -- respond with NAK to every auth request to enumerate them until we get a failure if packet.eap.type ~= eap.eap_t.IDENTITY and packet.eap.code == eap.code_t.REQUEST then - stdnse.print_debug(1, "auth request: %s",eap.eap_str[packet.eap.type]) + stdnse.debug1("auth request: %s",eap.eap_str[packet.eap.type]) identity.auth[packet.eap.type] = true identity.probe = -1 for i,v in pairs(identity.auth) do - stdnse.print_debug(1, "identity.auth: %d %s",i,tostring(v)) + stdnse.debug1("identity.auth: %d %s",i,tostring(v)) if v == UNKNOWN then identity.probe = i eap.send_nak_response(iface, packet.eap.id, i) @@ -149,7 +149,7 @@ action = function() -- retry on failure if packet.eap.code == eap.code_t.FAILURE then - stdnse.print_debug(1, "auth failure") + stdnse.debug1("auth failure") identity.auth[identity.probe] = false -- don't give up at the first failure! @@ -171,7 +171,7 @@ action = function() end else - stdnse.print_debug(1, "packet invalid! wrong filter?") + stdnse.debug1("packet invalid! wrong filter?") end end end @@ -186,7 +186,7 @@ action = function() end for i,v in ipairs(results) do - stdnse.print_debug(1, "%s", tostring(v)) + stdnse.debug1("%s", tostring(v)) end return stdnse.format_output(true, results) diff --git a/scripts/firewalk.nse b/scripts/firewalk.nse index e0e0ac199..981432f96 100644 --- a/scripts/firewalk.nse +++ b/scripts/firewalk.nse @@ -193,7 +193,7 @@ local tcp_funcs_v4 = { if port and scanner.ports.tcp[port] then - stdnse.print_debug("Marking port %d/tcp v4 as forwarded (reply from %s)", ip2.tcp_dport, ip.ip_src) + stdnse.debug1("Marking port %d/tcp v4 as forwarded (reply from %s)", ip2.tcp_dport, ip.ip_src) -- mark the gateway as forwarding the packet scanner.ports.tcp[port].final_ttl = gateway_ttl(scanner.target.traceroute, ip.ip_src) @@ -207,7 +207,7 @@ local tcp_funcs_v4 = { end else - stdnse.print_debug("Invalid reply to port %d/tcp", ip2.tcp_dport) + stdnse.debug1("Invalid reply to port %d/tcp", ip2.tcp_dport) end end, @@ -257,7 +257,7 @@ local udp_funcs_v4 = { if port and scanner.ports.udp[port] then - stdnse.print_debug("Marking port %d/udp v4 as forwarded", ip2.udp_dport) + stdnse.debug1("Marking port %d/udp v4 as forwarded", ip2.udp_dport) -- mark the gateway as forwarding the packet scanner.ports.udp[port].final_ttl = gateway_ttl(scanner.target.traceroute, ip.ip_src) @@ -270,7 +270,7 @@ local udp_funcs_v4 = { end else - stdnse.print_debug("Invalid reply to port %d/udp", ip2.udp_dport) + stdnse.debug1("Invalid reply to port %d/udp", ip2.udp_dport) end end, @@ -320,7 +320,7 @@ local tcp_funcs_v6 = { if port and scanner.ports.tcp[port] then - stdnse.print_debug("Marking port %d/tcp v6 as forwarded (reply from %s)", ip2.tcp_dport, ip.ip_src) + stdnse.debug1("Marking port %d/tcp v6 as forwarded (reply from %s)", ip2.tcp_dport, ip.ip_src) -- mark the gateway as forwarding the packet scanner.ports.tcp[port].final_ttl = gateway_ttl(scanner.target.traceroute, ip.ip_src) @@ -334,7 +334,7 @@ local tcp_funcs_v6 = { end else - stdnse.print_debug("Invalid reply to port %d/tcp", ip2.tcp_dport) + stdnse.debug1("Invalid reply to port %d/tcp", ip2.tcp_dport) end end, @@ -382,7 +382,7 @@ local udp_funcs_v6 = { if port and scanner.ports.udp[port] then - stdnse.print_debug("Marking port %d/udp v6 as forwarded (reply from %s)", ip2.udp_dport, ip2.ip_src) + stdnse.debug1("Marking port %d/udp v6 as forwarded (reply from %s)", ip2.udp_dport, ip2.ip_src) -- mark the gateway as forwarding the packet scanner.ports.udp[port].final_ttl = gateway_ttl(scanner.target.traceroute, ip.ip_src) @@ -395,7 +395,7 @@ local udp_funcs_v6 = { end else - stdnse.print_debug("Invalid reply to port %d/udp", ip2.udp_dport) + stdnse.debug1("Invalid reply to port %d/udp", ip2.udp_dport) end end, @@ -497,7 +497,7 @@ local Firewalk_v4 = { -- mark port as forwarded and discard any related pending probes proto_func.update_scan(scanner, ip, ip2) else - stdnse.print_debug("Invalid protocol for reply (%d)", ip2.ip_p) + stdnse.debug1("Invalid protocol for reply (%d)", ip2.ip_p) end end end, @@ -563,7 +563,7 @@ local Firewalk_v6 = { -- mark port as forwarded and discard any related pending probes proto_func.update_scan(scanner, ip, ip2) else - stdnse.print_debug("Invalid protocol for reply (%d)", ip2.ip_p) + stdnse.debug1("Invalid protocol for reply (%d)", ip2.ip_p) end end end, @@ -654,7 +654,7 @@ local function getopts() RecvTimeout = parse_timespec_ms(timespec) if not RecvTimeout then - stdnse.print_debug("Invalid time specification for option: firewalk.recv-timeout (%s)", timespec) + stdnse.debug1("Invalid time specification for option: firewalk.recv-timeout (%s)", timespec) return false end @@ -671,7 +671,7 @@ local function getopts() ProbeTimeout = parse_timespec_ms(timespec) if not ProbeTimeout then - stdnse.print_debug("Invalid time specification for option: firewalk.probe-timeout (%s)", timespec) + stdnse.debug1("Invalid time specification for option: firewalk.probe-timeout (%s)", timespec) return false end @@ -735,7 +735,7 @@ local function initial_ttl(host) return nil end - stdnse.print_debug("Using ttl %d", #host.traceroute) + stdnse.debug1("Using ttl %d", #host.traceroute) return #host.traceroute end @@ -911,7 +911,7 @@ local function send_probe(scanner, probe) local try = nmap.new_try(function() scanner.sock:ip_close() end) - stdnse.print_debug("Sending new probe (%d/%s ttl=%d)", probe.portno, probe.proto, probe.ttl) + stdnse.debug1("Sending new probe (%d/%s ttl=%d)", probe.portno, probe.proto, probe.ttl) -- craft the raw packet local pkt = proto_vtable[probe.proto].getprobe(scanner.target, probe.portno, probe.ttl) diff --git a/scripts/ftp-brute.nse b/scripts/ftp-brute.nse index 9d5b53aa5..977c7ff33 100644 --- a/scripts/ftp-brute.nse +++ b/scripts/ftp-brute.nse @@ -82,7 +82,7 @@ Driver = { -- Loop over the lines while(line)do - stdnse.print_debug("Received: %s", line) + stdnse.debug1("Received: %s", line) if(string.match(line, "^230")) then stdnse.debug1("Successful login: %s/%s", user, pass) return true, brute.Account:new( user, pass, creds.State.VALID) diff --git a/scripts/ftp-proftpd-backdoor.nse b/scripts/ftp-proftpd-backdoor.nse index 11defbf02..07f10d42a 100644 --- a/scripts/ftp-proftpd-backdoor.nse +++ b/scripts/ftp-proftpd-backdoor.nse @@ -62,7 +62,7 @@ action = function(host, port) sock:set_timeout(5000) status, err = sock:connect(host, port, "tcp") if not status then - stdnse.print_debug(1, "Can't connect: %s", err) + stdnse.debug1("Can't connect: %s", err) sock:close() return end @@ -71,21 +71,21 @@ action = function(host, port) local buffer = stdnse.make_buffer(sock, "\r?\n") local code, message = ftp.read_reply(buffer) if not code then - stdnse.print_debug(1, "Can't read banner: %s", message) + stdnse.debug1("Can't read banner: %s", message) sock:close() return end -- Check version. if not message:match("ProFTPD 1.3.3c") then - stdnse.print_debug(1, "This version is not known to be backdoored.") + stdnse.debug1("This version is not known to be backdoored.") return end -- Send command to escalate privilege. status, err = sock:send(CMD_FTP .. "\r\n") if not status then - stdnse.print_debug(1, "Failed to send privilege escalation command: %s", err) + stdnse.debug1("Failed to send privilege escalation command: %s", err) sock:close() return end @@ -93,7 +93,7 @@ action = function(host, port) -- Check if escalation worked. code, message = ftp.read_reply(buffer) if code and code == 502 then - stdnse.print_debug(1, "Privilege escalation failed: %s", message) + stdnse.debug1("Privilege escalation failed: %s", message) sock:close() return end @@ -101,7 +101,7 @@ action = function(host, port) -- Send command(s) to shell. status, err = sock:send(cmd .. ";\r\n") if not status then - stdnse.print_debug(1, "Failed to send shell command(s): %s", err) + stdnse.debug1("Failed to send shell command(s): %s", err) sock:close() return end @@ -109,7 +109,7 @@ action = function(host, port) -- Check for an error from command. status, resp = sock:receive() if not status then - stdnse.print_debug(1, "Can't read command response: %s", resp) + stdnse.debug1("Can't read command response: %s", resp) sock:close() return end diff --git a/scripts/gkrellm-info.nse b/scripts/gkrellm-info.nse index 83e542506..288133d17 100644 --- a/scripts/gkrellm-info.nse +++ b/scripts/gkrellm-info.nse @@ -182,7 +182,7 @@ action = function(host, port) break end if ( not(tag:match("^<.*>$")) ) then - stdnse.print_debug(2, "Expected tag, got: %s", tag) + stdnse.debug2("Expected tag, got: %s", tag) break else tag = tag:match("^<(.*)>$") diff --git a/scripts/hostmap-bfk.nse b/scripts/hostmap-bfk.nse index 19dc62e79..f22ac84e6 100644 --- a/scripts/hostmap-bfk.nse +++ b/scripts/hostmap-bfk.nse @@ -79,7 +79,7 @@ action = function(host) local output_tab = stdnse.output_table() response = http.get(HOSTMAP_SERVER, 80, query) if not response.status then - stdnse.print_debug(1, "Error: could not GET http://%s%s", HOSTMAP_SERVER, query) + stdnse.debug1("Error: could not GET http://%s%s", HOSTMAP_SERVER, query) return nil end local hostnames = {} @@ -96,7 +96,7 @@ action = function(host) if #hosts_log == 0 then if not string.find(response.body, "

The server returned no hits.

") then - stdnse.print_debug(1,"Error: found no hostnames but not the marker for \"no hostnames found\" (pattern error?)") + stdnse.debug1("Error: found no hostnames but not the marker for \"no hostnames found\" (pattern error?)") end return nil end @@ -110,7 +110,7 @@ action = function(host) if status then output_tab.filename = filename else - stdnse.print_debug(1,"Error saving to %s: %s\n", filename, err) + stdnse.debug1("Error saving to %s: %s\n", filename, err) end end diff --git a/scripts/hostmap-ip2hosts.nse b/scripts/hostmap-ip2hosts.nse index 9c495f136..a870aa01c 100644 --- a/scripts/hostmap-ip2hosts.nse +++ b/scripts/hostmap-ip2hosts.nse @@ -94,7 +94,7 @@ action = function(host) local hostnames = {} local hostnames_str, output_str local output_tab = stdnse.output_table() - stdnse.print_debug(1, "Using database: %s", HOSTMAP_BING_SERVER) + stdnse.debug1("Using database: %s", HOSTMAP_BING_SERVER) hostnames = query_bing(host.ip) output_tab.hosts = hostnames @@ -106,7 +106,7 @@ action = function(host) if status then output_tab.filename = filename else - stdnse.print_debug(1, "There was an error saving the file %s:%s", filename, err) + stdnse.debug1("There was an error saving the file %s:%s", filename, err) end end diff --git a/scripts/http-affiliate-id.nse b/scripts/http-affiliate-id.nse index d08b01d6d..99dc89d68 100644 --- a/scripts/http-affiliate-id.nse +++ b/scripts/http-affiliate-id.nse @@ -95,9 +95,9 @@ portaction = function(host, port) for shortener, pattern in pairs(URL_SHORTENERS) do for i, shortened in ipairs(pattern:match(body)) do - stdnse.print_debug("Found shortened Url: " .. shortened) + stdnse.debug1("Found shortened Url: " .. shortened) local response = http.get(shortener, 80, shortened) - stdnse.print_debug("status code: %d", response.status) + stdnse.debug1("status code: %d", response.status) if (response.status == 301 or response.status == 302) and response.header['location'] then followed[#followed + 1] = response.header['location'] end @@ -111,7 +111,7 @@ portaction = function(host, port) for i, id in ipairs(pattern:match(body..followed)) do if not ids[id] then result[#result + 1] = name .. ": " .. id - stdnse.print_debug("found id:" .. result[#result]) + stdnse.debug1("found id:" .. result[#result]) add_key_to_registry(host, port, url_path, result[#result]) ids[id] = true end diff --git a/scripts/http-config-backup.nse b/scripts/http-config-backup.nse index 50015653a..04cdae5b0 100644 --- a/scripts/http-config-backup.nse +++ b/scripts/http-config-backup.nse @@ -215,9 +215,9 @@ action = function (host, port) if save then local status, err = write_file(save .. filename, response.body); if status then - stdnse.print_debug(1, "%s saved", filename); + stdnse.debug1("%s saved", filename); else - stdnse.print_debug(1, "error saving %s", err); + stdnse.debug1("error saving %s", err); end end diff --git a/scripts/http-domino-enum-passwords.nse b/scripts/http-domino-enum-passwords.nse index 1f03b780e..b3f38fe7a 100644 --- a/scripts/http-domino-enum-passwords.nse +++ b/scripts/http-domino-enum-passwords.nse @@ -290,7 +290,7 @@ action = function(host, port) end for _, link in ipairs(links) do - stdnse.print_debug(2, "Fetching link: %s", link) + stdnse.debug2("Fetching link: %s", link) http_response = http.get( vhost or host, port, link, { auth = { username = user, password = pass }, no_cache = true }) local u_details = getUserDetails( http_response.body ) @@ -299,7 +299,7 @@ action = function(host, port) end if ( u_details.fullname and u_details.passwd and #u_details.passwd > 0 ) then - stdnse.print_debug(2, "Found Internet hash for: %s:%s", u_details.fullname, u_details.passwd) + stdnse.debug2("Found Internet hash for: %s:%s", u_details.fullname, u_details.passwd) -- Old type are 32 bytes, new are 20 if #u_details.passwd == 32 then table.insert( legacyHashes, ("%s:%s"):format(u_details.fullname, u_details.passwd)) @@ -309,9 +309,9 @@ action = function(host, port) end if ( u_details.idfile ) then - stdnse.print_debug(2, "Found ID file for user: %s", u_details.fullname) + stdnse.debug2("Found ID file for user: %s", u_details.fullname) if ( download_path ) then - stdnse.print_debug(2, "Downloading ID file for user: %s", u_details.full_name) + stdnse.debug2("Downloading ID file for user: %s", u_details.full_name) http_response = http.get( vhost or host, port, u_details.idfile, { auth = { username = user, password = pass }, no_cache = true }) if ( http_response.status == 200 ) then diff --git a/scripts/http-drupal-modules.nse b/scripts/http-drupal-modules.nse index 05a7837c8..6694fa6dc 100644 --- a/scripts/http-drupal-modules.nse +++ b/scripts/http-drupal-modules.nse @@ -120,7 +120,7 @@ action = function(host, port) -- send requests local pipeline_responses = http.pipeline_go(host, port, all) if not pipeline_responses then - stdnse.print_debug(1, "No answers from pipelined requests", SCRIPT_NAME) + stdnse.debug1("No answers from pipelined requests", SCRIPT_NAME) return nil end diff --git a/scripts/http-enum.nse b/scripts/http-enum.nse index 2b23c5247..2151c9abd 100644 --- a/scripts/http-enum.nse +++ b/scripts/http-enum.nse @@ -475,7 +475,7 @@ action = function(host, port) output = output .. " (" .. http.get_status_string(result) .. ")" end - stdnse.print_debug(1, "Found a valid page! %s", output) + stdnse.debug1("Found a valid page! %s", output) table.insert(response, output) end diff --git a/scripts/http-exif-spider.nse b/scripts/http-exif-spider.nse index efdb55198..56c56bcbc 100644 --- a/scripts/http-exif-spider.nse +++ b/scripts/http-exif-spider.nse @@ -521,10 +521,10 @@ function action(host, port) -- Check if we got a response, and the response is a .jpg file if r.response and r.response.body and r.response.status==200 and (string.match(r.url.path, ".jpg") or string.match(r.url.path, ".jpeg")) then local status, result - stdnse.print_debug(1, "Attempting to read exif data from %s", r.url.raw) + stdnse.debug1("Attempting to read exif data from %s", r.url.raw) status, result = parse_jpeg(r.response.body) if(not(status)) then - stdnse.print_debug(1, "Couldn't read exif from %s: %s", r.url.raw, result) + stdnse.debug1("Couldn't read exif from %s: %s", r.url.raw, result) else -- If there are any exif results, add them to the result if(result and #result > 0) then diff --git a/scripts/http-favicon.nse b/scripts/http-favicon.nse index 88864cf48..f6bcee252 100644 --- a/scripts/http-favicon.nse +++ b/scripts/http-favicon.nse @@ -56,7 +56,7 @@ action = function(host, port) status, favicondb = datafiles.parse_file( favicondbfile, {["^%s*([^%s#:]+)[%s:]+"] = "^%s*[^%s#:]+[%s:]+(.*)"}) if not status then - stdnse.print_debug( 1, "Could not open file: %s", favicondbfile ) + stdnse.debug1("Could not open file: %s", favicondbfile ) return end @@ -67,7 +67,7 @@ action = function(host, port) if(favicon_uri) then -- If we got a script arg URI, always use that. answer = http.get( host, port, root .. "/" .. favicon_uri) - stdnse.print_debug( 4, "Using URI %s", favicon_uri) + stdnse.debug4("Using URI %s", favicon_uri) else -- Otherwise, first try parsing the home page. index = http.get( host, port, root .. "/" ) @@ -77,7 +77,7 @@ action = function(host, port) -- if we find a pattern if icon then local hostname = host.targetname or (host.name ~= "" and host.name) or host.ip - stdnse.print_debug(1, "Got icon URL %s.", icon) + stdnse.debug1("Got icon URL %s.", icon) local icon_host, icon_port, icon_path = parse_url_relative(icon, hostname, port.number, root) if (icon_host == host.ip or icon_host == host.targetname or @@ -96,7 +96,7 @@ action = function(host, port) -- If that didn't work, try /favicon.ico. if not answer or answer.status ~= 200 then answer = http.get( host, port, root .. "/favicon.ico" ) - stdnse.print_debug( 4, "Using default URI.") + stdnse.debug4("Using default URI.") end end @@ -112,7 +112,7 @@ action = function(host, port) end end else - stdnse.print_debug( 1, "No favicon found.") + stdnse.debug1("No favicon found.") return end --- status == 200 return result diff --git a/scripts/http-fileupload-exploiter.nse b/scripts/http-fileupload-exploiter.nse index 56c47b190..bc9ecd16c 100644 --- a/scripts/http-fileupload-exploiter.nse +++ b/scripts/http-fileupload-exploiter.nse @@ -111,7 +111,7 @@ local function UploadRequest(host, port, submission, partofrequest, name, filena options['header']['Content-Type'] = "multipart/form-data; boundary=AaB03x" options['content'] = self.partofrequest .. '--AaB03x\nContent-Disposition: form-data; name="' .. self.name .. '"; filename="' .. self.filename .. '"\nContent-Type: ' .. self.mime .. '\n\n' .. self.payload .. '\n--AaB03x--' - stdnse.print_debug(2, "Making a request: Header: " .. options['header']['Content-Type'] .. "\nContent: " .. escape(options['content'])) + stdnse.debug2("Making a request: Header: " .. options['header']['Content-Type'] .. "\nContent: " .. escape(options['content'])) local response = http.post(self.host, self.port, self.submission, options, { no_cache = true }) diff --git a/scripts/http-frontpage-login.nse b/scripts/http-frontpage-login.nse index c89ce3362..81cac37af 100644 --- a/scripts/http-frontpage-login.nse +++ b/scripts/http-frontpage-login.nse @@ -70,19 +70,19 @@ Default installations of older versions of frontpage extensions allow anonymous data = http.post(host,port,path .. "/_vti_bin/_vti_aut/author.dll",nil,nil,postdata) if data and data.status then if data.status == 200 then - stdnse.print_debug("Frontpage returned 200 OK, server vulnerable.") + stdnse.debug1("Frontpage returned 200 OK, server vulnerable.") frontpage_vuln.state = vulns.STATE.VULN; return report:make_output(frontpage_vuln); elseif data.status == 401 then - stdnse.print_debug("Frontpage returned 401, password protected.") + stdnse.debug1("Frontpage returned 401, password protected.") return false else - stdnse.print_debug("Frontpage returned unknown response.") + stdnse.debug1("Frontpage returned unknown response.") return false end end end end - stdnse.print_debug("Frontpage probably not installed.") + stdnse.debug1("Frontpage probably not installed.") return false end diff --git a/scripts/http-google-malware.nse b/scripts/http-google-malware.nse index d0c2bcc39..be613b4e6 100644 --- a/scripts/http-google-malware.nse +++ b/scripts/http-google-malware.nse @@ -75,7 +75,7 @@ action = function(host, port) stdnse.debug1("Checking host %s", target_url) local qry = build_qry(apikey, target_url) local req = http.get_url(qry) - stdnse.print_debug(2, "%s", qry) + stdnse.debug2("%s", qry) if ( req.status > 400 ) then return "[ERROR] Request failed (invalid API key?)" diff --git a/scripts/http-iis-short-name-brute.nse b/scripts/http-iis-short-name-brute.nse index c58fad9f5..775caa192 100644 --- a/scripts/http-iis-short-name-brute.nse +++ b/scripts/http-iis-short-name-brute.nse @@ -95,7 +95,7 @@ local function findExtension(host, port, path, ext) if charInExtension(host, port, path, ext) then -- currently only support for ext of length 3 if ext:len() == 3 then - stdnse.print_debug(1, "Added file: %s", path .. ext) + stdnse.debug1("Added file: %s", path .. ext) table.insert(files, path .. ext) else for c in chars:gmatch(".") do @@ -117,7 +117,7 @@ local function findName(host, port, path, number) stdnse.debug1("False positive detected. Exiting.") errors_max=true else - stdnse.print_debug(1, "Added folder: %s", path .. "~" .. number) + stdnse.debug1("Added folder: %s", path .. "~" .. number) table.insert(folders, path .. "~" .. number) -- increase the number ('~1' to '~2') @@ -139,7 +139,7 @@ local function findName(host, port, path, number) -- recurse if the path is valid and the length of path is not 6 if not (path:len() == 6) and cont and not(errors_max) then - stdnse.print_debug(1, "Testing: %s", path .. "~" .. number) + stdnse.debug1("Testing: %s", path .. "~" .. number) for c in chars:gmatch(".") do findName(host, port, path .. c, number) end end end diff --git a/scripts/http-joomla-brute.nse b/scripts/http-joomla-brute.nse index e2c0e0721..6bcf2ede0 100644 --- a/scripts/http-joomla-brute.nse +++ b/scripts/http-joomla-brute.nse @@ -88,13 +88,13 @@ Driver = { end, login = function( self, username, password ) - stdnse.print_debug(2, "HTTP POST %s%s with security token %s\n", self.host, self.uri, security_token) + stdnse.debug2("HTTP POST %s%s with security token %s\n", self.host, self.uri, security_token) local response = http.post( self.host, self.port, self.uri, { cookies = session_cookie_str, no_cache = true, no_cache_body = true }, nil, { [self.options.uservar] = username, [self.options.passvar] = password, [security_token] = 1, lang = "", option = "com_login", task = "login" } ) if response.body and not( response.body:match('name=[\'"]*'..self.options.passvar ) ) then - stdnse.print_debug(2, "Response:\n%s", response.body) + stdnse.debug2("Response:\n%s", response.body) local c = creds.Credentials:new(SCRIPT_NAME, self.host, self.port ) c:add(username, password, creds.State.VALID ) return true, brute.Account:new( username, password, "OPEN") @@ -108,25 +108,25 @@ Driver = { check = function( self ) local response = http.get( self.host, self.port, self.uri ) - stdnse.print_debug(1, "HTTP GET %s%s", stdnse.get_hostname(self.host),self.uri) + stdnse.debug1("HTTP GET %s%s", stdnse.get_hostname(self.host),self.uri) -- Check if password field is there if ( response.status == 200 and response.body:match('type=[\'"]password[\'"]')) then - stdnse.print_debug(1, "Initial check passed. Launching brute force attack") + stdnse.debug1("Initial check passed. Launching brute force attack") session_cookie_str = response.cookies[1]["name"].."="..response.cookies[1]["value"]; if response.body then local _ _, _, security_token = string.find(response.body, '') end if security_token then - stdnse.print_debug(2, "Security Token found:%s", security_token) + stdnse.debug2("Security Token found:%s", security_token) else - stdnse.print_debug(2, "The security token was not found.") + stdnse.debug2("The security token was not found.") return false end return true else - stdnse.print_debug(1, "Initial check failed. Password field wasn't found") + stdnse.debug1("Initial check failed. Password field wasn't found") end return false end diff --git a/scripts/http-majordomo2-dir-traversal.nse b/scripts/http-majordomo2-dir-traversal.nse index aca6f64ee..534b7aefb 100644 --- a/scripts/http-majordomo2-dir-traversal.nse +++ b/scripts/http-majordomo2-dir-traversal.nse @@ -72,7 +72,7 @@ action = function(host, port) rfile = stdnse.get_script_args("http-majordomo2-dir-traversal.rfile") or DEFAULT_REMOTE_FILE evil_uri = uri..MAJORDOMO2_EXPLOIT_QRY..rfile - stdnse.print_debug(1, "HTTP GET %s%s", stdnse.get_hostname(host), evil_uri) + stdnse.debug1("HTTP GET %s%s", stdnse.get_hostname(host), evil_uri) response = http.get(host, port, evil_uri) if response.body and response.status==200 then if response.body:match("unknowntopic") then diff --git a/scripts/http-open-proxy.nse b/scripts/http-open-proxy.nse index ebf3f3394..0c265bb29 100644 --- a/scripts/http-open-proxy.nse +++ b/scripts/http-open-proxy.nse @@ -60,7 +60,7 @@ function custom_test(host, port, test_url, pattern) -- strip hostname if not string.match(test_url, "^http://.*") then test_url = "http://" .. test_url - stdnse.print_debug("URL missing scheme. URL concatenated to http://") + stdnse.debug1("URL missing scheme. URL concatenated to http://") end local url_table = url.parse(test_url) local hostname = url_table.host @@ -136,7 +136,7 @@ function default_test(host, port) -- if we do not receive any valid status code, -- there is no reason to keep testing... the proxy is probably not open if not (get_cstatus or head_cstatus or conn_status) then return false, nil end - stdnse.print_debug("Test 1 - Google Web Server\nReceived valid status codes, but pattern does not match") + stdnse.debug1("Test 1 - Google Web Server\nReceived valid status codes, but pattern does not match") test_url = "http://www.wikipedia.org" hostname = "www.wikipedia.org" @@ -156,7 +156,7 @@ function default_test(host, port) -- same valid code checking as above if not (get_cstatus or head_cstatus or conn_status) then return false, nil end - stdnse.print_debug("Test 2 - Wikipedia.org\nReceived valid status codes, but pattern does not match") + stdnse.debug1("Test 2 - Wikipedia.org\nReceived valid status codes, but pattern does not match") test_url = "http://www.computerhistory.org" hostname = "www.computerhistory.org" @@ -172,7 +172,7 @@ function default_test(host, port) if fstatus then return fstatus, "Methods supported:" .. response end if not get_cstatus then - stdnse.print_debug("Test 3 - Computer History\nReceived valid status codes, but pattern does not match") + stdnse.debug1("Test 3 - Computer History\nReceived valid status codes, but pattern does not match") end -- Check if GET is being redirected diff --git a/scripts/http-phpself-xss.nse b/scripts/http-phpself-xss.nse index c9d68b4e8..59c4fe7e9 100644 --- a/scripts/http-phpself-xss.nse +++ b/scripts/http-phpself-xss.nse @@ -62,7 +62,7 @@ local probes = {} --@param response Response table --@return True if attack vector is found in response's body local function check_probe_response(response) - stdnse.print_debug(3, "Probe response:\n%s", response.body) + stdnse.debug3("Probe response:\n%s", response.body) if string.find(response.body, "'\"/>", 1, true) ~= nil then return true end diff --git a/scripts/http-slowloris-check.nse b/scripts/http-slowloris-check.nse index 2c0efcfda..f45d37314 100644 --- a/scripts/http-slowloris-check.nse +++ b/scripts/http-slowloris-check.nse @@ -93,7 +93,7 @@ local function slowThread2(host,port) local catch = function() -- note the time the socket timedout TimeWith = nmap.clock() - stdnse.print_debug("2 try") + stdnse.debug1("2 try") end local try = nmap.new_try(catch) socket = nmap.new_socket() @@ -147,12 +147,12 @@ so, it starves the http server's resources causing Denial Of Service. return end local diff = TimeWith - TimeWithout - stdnse.print_debug("Time difference is: %d",diff) + stdnse.debug1("Time difference is: %d",diff) -- if second connection died 10 or more seconds after the first -- it means that sending additional data prolonged the connection's time -- and the server is vulnerable to slowloris attack if diff >= 10 then - stdnse.print_debug("Difference is greater or equal to 10 seconds.") + stdnse.debug1("Difference is greater or equal to 10 seconds.") slowloris.state = vulns.STATE.VULN end return report:make_output(slowloris) diff --git a/scripts/http-stored-xss.nse b/scripts/http-stored-xss.nse index 777eae538..c4b98ec07 100644 --- a/scripts/http-stored-xss.nse +++ b/scripts/http-stored-xss.nse @@ -101,9 +101,9 @@ local makeRequests = function(host, port, submission, fields, fieldvalues) end end - stdnse.print_debug(2, "Making a POST request to " .. submission .. ": ") + stdnse.debug2("Making a POST request to " .. submission .. ": ") for i, content in pairs(postdata) do - stdnse.print_debug(2, i .. ": " .. content) + stdnse.debug2(i .. ": " .. content) end local response = http.post(host, port, submission, { no_cache = true }, nil, postdata) end diff --git a/scripts/http-tplink-dir-traversal.nse b/scripts/http-tplink-dir-traversal.nse index 77940a1ec..c202af980 100644 --- a/scripts/http-tplink-dir-traversal.nse +++ b/scripts/http-tplink-dir-traversal.nse @@ -132,7 +132,7 @@ Possibly vulnerable (Based on the same firmware): WR743ND,WR842ND,WA-901ND,WR941 vuln.state = vulns.STATE.EXPLOIT response = http.get(host, port, TRAVERSAL_QRY..rfile) if response.body and response.status==200 then - stdnse.print_debug(2, "%s", response.body) + stdnse.debug2("%s", response.body) if response.body:match("Error") then stdnse.debug1("[Error] File not found:%s", rfile) vuln.extra_info = string.format("%s not found.\n", rfile) diff --git a/scripts/http-useragent-tester.nse b/scripts/http-useragent-tester.nse index 005024cfe..e9a313d1e 100644 --- a/scripts/http-useragent-tester.nse +++ b/scripts/http-useragent-tester.nse @@ -69,7 +69,7 @@ getLastLoc = function(host, port, useragent) options['header']['User-Agent'] = useragent - stdnse.print_debug(2, "Making a request with User-Agent: " .. useragent) + stdnse.debug2("Making a request with User-Agent: " .. useragent) local response = http.get(host, port, '/', options) diff --git a/scripts/http-vhosts.nse b/scripts/http-vhosts.nse index 925cb32f9..81d040ffa 100644 --- a/scripts/http-vhosts.nse +++ b/scripts/http-vhosts.nse @@ -162,7 +162,7 @@ action = function(host, port) else status, hostnames = datafiles.parse_file("nselib/data/vhosts-default.lst" , {}) if not status then - stdnse.print_debug(1, "Can not open file with vhosts file names list") + stdnse.debug1("Can not open file with vhosts file names list") return end end diff --git a/scripts/http-vuln-cve2006-3392.nse b/scripts/http-vuln-cve2006-3392.nse index f6e7b56a0..fb7abb15b 100644 --- a/scripts/http-vuln-cve2006-3392.nse +++ b/scripts/http-vuln-cve2006-3392.nse @@ -67,14 +67,14 @@ to bypass the removal of "../" directory traversal sequences. local vuln_report = vulns.Report:new(SCRIPT_NAME, host, port) local url = "/unauthenticated/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01/..%01" .. file_var - stdnse.print_debug(1, "Getting " .. file_var) + stdnse.debug1("Getting " .. file_var) local detection_session = http.get(host, port, url) - stdnse.print_debug(1, "Status code:"..detection_session.status) + stdnse.debug1("Status code:"..detection_session.status) if detection_session and detection_session.status == 200 then vuln.state = vulns.STATE.EXPLOIT - stdnse.print_debug(1, detection_session.body) + stdnse.debug1(detection_session.body) return vuln_report:make_output(detection_session.body) end end \ No newline at end of file diff --git a/scripts/http-vuln-cve2012-1823.nse b/scripts/http-vuln-cve2012-1823.nse index 3a540a0bd..f6e064549 100644 --- a/scripts/http-vuln-cve2012-1823.nse +++ b/scripts/http-vuln-cve2012-1823.nse @@ -82,20 +82,20 @@ code execution.]], } local vuln_report = vulns.Report:new(SCRIPT_NAME, host, port) - stdnse.print_debug(2, "Trying detection using echo command") + stdnse.debug2("Trying detection using echo command") local detection_session = http.post(host, port, uri.."?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input", { no_cache = true }, nil, "") if detection_session and detection_session.status == 200 then if string.match(detection_session.body, "NmapCVEIdentification") then - stdnse.print_debug(1, "The website seems vulnerable to CVE-2012-1823.") + stdnse.debug1("The website seems vulnerable to CVE-2012-1823.") else return end end - stdnse.print_debug(2, "Trying Command... " .. cmd) + stdnse.debug2("Trying Command... " .. cmd) local exploitation_session = http.post(host, port, uri.."?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input", { no_cache = true }, nil, "") if exploitation_session and exploitation_session.status == 200 then - stdnse.print_debug(1, "Ouput of the command " .. cmd .. " : \n"..exploitation_session.body) + stdnse.debug1("Ouput of the command " .. cmd .. " : \n"..exploitation_session.body) vuln.state = vulns.STATE.EXPLOIT return vuln_report:make_output(exploitation_session.body) end diff --git a/scripts/http-vuln-cve2013-7091.nse b/scripts/http-vuln-cve2013-7091.nse index e65349ae5..ae6eb8445 100644 --- a/scripts/http-vuln-cve2013-7091.nse +++ b/scripts/http-vuln-cve2013-7091.nse @@ -91,9 +91,9 @@ This issue was patched in Zimbra 7.2.6. local url_short = "/res/I18nMsg,AjxMsg,ZMsg,ZmMsg,AjxKeys,ZmKeys,ZdMsg,Ajx%20TemplateMsg.js.zgz?v=091214175450&skin=" .. file_short .. "%00" local url_long = "/res/I18nMsg,AjxMsg,ZMsg,ZmMsg,AjxKeys,ZmKeys,ZdMsg,Ajx%20TemplateMsg.js.zgz?v=091214175450&skin=" .. file_long .. "%00" - stdnse.print_debug(1, "Trying to detect if the server is vulnerable") - stdnse.print_debug(1, "GET " .. uri .. escape(url_short)) - stdnse.print_debug(1, "GET " .. uri .. escape(url_long)) + stdnse.debug1("Trying to detect if the server is vulnerable") + stdnse.debug1("GET " .. uri .. escape(url_short)) + stdnse.debug1("GET " .. uri .. escape(url_long)) local session_short = http.get(host, port, uri..url_short) local session_long = http.get(host, port, uri..url_long) @@ -102,20 +102,20 @@ This issue was patched in Zimbra 7.2.6. if session_short.header['content-type'] == "application/x-javascript" then -- Because .gz format is somewhat odd, giving a bit of a margin of error here if (string.len(session_long.body) - string.len(session_short.body)) > 100 then - stdnse.print_debug(1, "The website appears to be vulnerable a local file inclusion vulnerability in Zimbra") + stdnse.debug1("The website appears to be vulnerable a local file inclusion vulnerability in Zimbra") vuln.state = vulns.STATE.EXPLOIT return vuln_report:make_output(vuln) else - stdnse.print_debug(1, "The host does not appear to be vulnerable") + stdnse.debug1("The host does not appear to be vulnerable") vuln.state = vulns.STATE.NOT_VULN return vuln_report:make_output(vuln) end else - stdnse.print_debug(1, "Bad content-type for the resource : " .. session_short.header['content-type']) + stdnse.debug1("Bad content-type for the resource : " .. session_short.header['content-type']) return end else - stdnse.print_debug(1, "The website seems to be not vulnerable to this attack.") + stdnse.debug1("The website seems to be not vulnerable to this attack.") return end end diff --git a/scripts/http-waf-detect.nse b/scripts/http-waf-detect.nse index 799f62d31..382611f05 100644 --- a/scripts/http-waf-detect.nse +++ b/scripts/http-waf-detect.nse @@ -74,7 +74,7 @@ action = function(host, port) orig_req = http.get(host, port, path) orig_req.body = http.clean_404(orig_req.body) if orig_req.status and orig_req.body then - stdnse.print_debug(3, "Normal HTTP response -> Status:%d Body:\n%s", orig_req.status, orig_req.body) + stdnse.debug3("Normal HTTP response -> Status:%d Body:\n%s", orig_req.status, orig_req.body) else return "[ERROR] Initial HTTP request failed" end @@ -88,7 +88,7 @@ action = function(host, port) --perform the "3v1l" requests to try to trigger the IDS/IPS/WAF tests = nil for _, vector in pairs(attack_vectors_n1) do - stdnse.print_debug(2, "Probing with payload:%s",vector) + stdnse.debug2("Probing with payload:%s",vector) tests = http.pipeline_add(path..vector, nil, tests) end local test_results = http.pipeline_go(host, port, tests) @@ -110,9 +110,9 @@ action = function(host, port) if payload_example and ( string.len(payload_example) > string.len(attack_vectors_n1[i]) ) then payload_example = attack_vectors_n1[i] end - stdnse.print_debug(2, "Payload:%s triggered the IDS/IPS/WAF", attack_vectors_n1[i]) + stdnse.debug2("Payload:%s triggered the IDS/IPS/WAF", attack_vectors_n1[i]) if res.status and res.body then - stdnse.print_debug(3, "Status:%s Body:%s\n", res.status, res.body) + stdnse.debug3("Status:%s Body:%s\n", res.status, res.body) end waf_bool = true end diff --git a/scripts/http-wordpress-brute.nse b/scripts/http-wordpress-brute.nse index 52b48ed88..b25c4f936 100644 --- a/scripts/http-wordpress-brute.nse +++ b/scripts/http-wordpress-brute.nse @@ -87,7 +87,7 @@ Driver = { login = function( self, username, password ) -- Note the no_cache directive - stdnse.print_debug(2, "HTTP POST %s%s\n", self.host, self.uri) + stdnse.debug2("HTTP POST %s%s\n", self.host, self.uri) local response = http.post( self.host, self.port, self.uri, { no_cache = true }, nil, { [self.options.uservar] = username, [self.options.passvar] = password } ) -- This redirect is taking us to /wp-admin if response.status == 302 then @@ -105,13 +105,13 @@ Driver = { check = function( self ) local response = http.get( self.host, self.port, self.uri ) - stdnse.print_debug(1, "HTTP GET %s%s", stdnse.get_hostname(self.host),self.uri) + stdnse.debug1("HTTP GET %s%s", stdnse.get_hostname(self.host),self.uri) -- Check if password field is there if ( response.status == 200 and response.body:match('type=[\'"]password[\'"]')) then - stdnse.print_debug(1, "Initial check passed. Launching brute force attack") + stdnse.debug1("Initial check passed. Launching brute force attack") return true else - stdnse.print_debug(1, "Initial check failed. Password field wasn't found") + stdnse.debug1("Initial check failed. Password field wasn't found") end return false diff --git a/scripts/icap-info.nse b/scripts/icap-info.nse index 1aa55be7d..f62d83975 100644 --- a/scripts/icap-info.nse +++ b/scripts/icap-info.nse @@ -51,7 +51,7 @@ local function parseResponse(resp) local resp_tbl = stdnse.strsplit("\r?\n", resp) if ( not(resp_tbl) or #resp_tbl == 0 ) then - stdnse.print_debug(2, "Received an invalid response from server") + stdnse.debug2("Received an invalid response from server") return end @@ -61,7 +61,7 @@ local function parseResponse(resp) for i=2, #resp_tbl do local key, val = resp_tbl[i]:match("^([^:]*):%s*(.*)$") if ( not(key) or not(val) ) then - stdnse.print_debug(2, "Failed to parse header: %s", resp_tbl[i]) + stdnse.debug2("Failed to parse header: %s", resp_tbl[i]) else resp_p.header[key:lower()] = val end diff --git a/scripts/ike-version.nse b/scripts/ike-version.nse index cb44463bd..3df084563 100644 --- a/scripts/ike-version.nse +++ b/scripts/ike-version.nse @@ -56,45 +56,45 @@ local function get_version(host, port) -- try aggressive mode (diffie hellman group 2) local diffie = 2 - stdnse.print_debug(1, "Sending Aggressive mode packet ...") + stdnse.debug1("Sending Aggressive mode packet ...") packet = ike.request(port.number, port.protocol, 'Aggressive', t, diffie, 'vpngroup') version = ike.send_request(host, port, packet) if version.success then return version end - stdnse.print_debug(1, "Aggressive mode (dh 2) failed") + stdnse.debug1("Aggressive mode (dh 2) failed") -- try aggressive mode (diffie hellman group 1) diffie = 1 - stdnse.print_debug(1, "Sending Aggressive mode packet ...") + stdnse.debug1("Sending Aggressive mode packet ...") packet = ike.request(port.number, port.protocol, 'Aggressive', t, diffie, 'vpngroup') version = ike.send_request(host, port, packet) if version.success then return version end - stdnse.print_debug(1, "Aggressive mode (dh 1) failed") + stdnse.debug1("Aggressive mode (dh 1) failed") -- try aggressive mode (diffie hellman group 2, no id) -- some checkpoint devices respond to this local diffie = 2 - stdnse.print_debug(1, "Sending Aggressive mode packet ...") + stdnse.debug1("Sending Aggressive mode packet ...") packet = ike.request(port.number, port.protocol, 'Aggressive', t, diffie, '') version = ike.send_request(host, port, packet) if version.success then return version end - stdnse.print_debug(1, "Aggressive mode (dh 2, no id) failed") + stdnse.debug1("Aggressive mode (dh 2, no id) failed") -- try main mode - stdnse.print_debug(1, "Sending Main mode packet ...") + stdnse.debug1("Sending Main mode packet ...") packet = ike.request(port.number, port.protocol, 'Main', t, '') version = ike.send_request(host, port, packet) if version.success then return version end - stdnse.print_debug(1, "Main mode failed") + stdnse.debug1("Main mode failed") - stdnse.print_debug(1, "Version detection not possible") + stdnse.debug1("Version detection not possible") return false end @@ -120,7 +120,7 @@ action = function( host, port ) nmap.set_port_state(host, port, "open") end end - stdnse.print_debug(1, "Version: %s", port.version.product ) + stdnse.debug1("Version: %s", port.version.product ) return end diff --git a/scripts/ip-geolocation-ipinfodb.nse b/scripts/ip-geolocation-ipinfodb.nse index 2037afeea..2a12a7f64 100644 --- a/scripts/ip-geolocation-ipinfodb.nse +++ b/scripts/ip-geolocation-ipinfodb.nse @@ -58,11 +58,11 @@ local ipinfodb = function(ip) local response = http.get("api.ipinfodb.com", 80, "/v3/ip-city/?key="..api_key.."&format=json".."&ip="..ip, nil) local stat, loc = json.parse(response.body) if not stat then - stdnse.print_debug("No response, possibly a network problem.") + stdnse.debug1("No response, possibly a network problem.") return nil end if loc.statusMessage and loc.statusMessage == "Invalid API key." then - stdnse.print_debug(loc.statusMessage) + stdnse.debug1(loc.statusMessage) return nil end diff --git a/scripts/ip-geolocation-maxmind.nse b/scripts/ip-geolocation-maxmind.nse index 75b135d2d..2e255f605 100644 --- a/scripts/ip-geolocation-maxmind.nse +++ b/scripts/ip-geolocation-maxmind.nse @@ -579,7 +579,7 @@ local GeoIP = { offset = x[0] end end - stdnse.print_debug('Error traversing database - perhaps it is corrupt?') + stdnse.debug1('Error traversing database - perhaps it is corrupt?') return nil end, } diff --git a/scripts/ipv6-node-info.nse b/scripts/ipv6-node-info.nse index 5609ea124..d9cc619bf 100644 --- a/scripts/ipv6-node-info.nse +++ b/scripts/ipv6-node-info.nse @@ -253,7 +253,7 @@ local function handle_received_packet(buf) if not STRINGIFY[qtype] then -- This is a not a qtype we sent or know about. - stdnse.print_debug(1, "Got NI reply with unknown qtype %d from %s", qtype, p.ip6_src) + stdnse.debug1("Got NI reply with unknown qtype %d from %s", qtype, p.ip6_src) return end diff --git a/scripts/ipv6-ra-flood.nse b/scripts/ipv6-ra-flood.nse index 87c902b0b..e15ab9b22 100644 --- a/scripts/ipv6-ra-flood.nse +++ b/scripts/ipv6-ra-flood.nse @@ -49,12 +49,12 @@ prerule = function() end if not nmap.is_privileged() then - stdnse.print_debug("Running %s needs root privileges.", SCRIPT_NAME) + stdnse.debug1("Running %s needs root privileges.", SCRIPT_NAME) return false end if not stdnse.get_script_args(SCRIPT_NAME .. ".interface") and not nmap.get_interface() then - stdnse.print_debug("No interface was selected, aborting...", SCRIPT_NAME) + stdnse.debug1("No interface was selected, aborting...", SCRIPT_NAME) return false end @@ -69,7 +69,7 @@ local function get_interface() if if_table and packet.ip6tobin(if_table.address) and if_table.link == "ethernet" then return if_table.device else - stdnse.print_debug("Interface %s not supported or not properly configured, exiting...", arg_interface) + stdnse.debug1("Interface %s not supported or not properly configured, exiting...", arg_interface) end end diff --git a/scripts/irc-botnet-channels.nse b/scripts/irc-botnet-channels.nse index 7f9709958..4c03a44aa 100644 --- a/scripts/irc-botnet-channels.nse +++ b/scripts/irc-botnet-channels.nse @@ -305,7 +305,7 @@ function action(host, port) if #params >= 2 then channels[#channels + 1] = params[2] else - stdnse.print_debug("Got short " .. RPL_LIST .. "response.") + stdnse.debug1("Got short " .. RPL_LIST .. "response.") end elseif code == RPL_LISTEND then break diff --git a/scripts/irc-info.nse b/scripts/irc-info.nse index 684e10add..e68194f14 100644 --- a/scripts/irc-info.nse +++ b/scripts/irc-info.nse @@ -72,7 +72,7 @@ function action (host, port) local buf = stdnse.make_buffer(sd, "\r?\n") while line do - stdnse.print_debug(2, "%s", line) + stdnse.debug2("%s", line) -- This one lets us know we've connected, pre-PONGed, and got a NICK -- Start of MOTD, we'll take the server name from here diff --git a/scripts/irc-unrealircd-backdoor.nse b/scripts/irc-unrealircd-backdoor.nse index f09e3f396..f5c963465 100644 --- a/scripts/irc-unrealircd-backdoor.nse +++ b/scripts/irc-unrealircd-backdoor.nse @@ -194,7 +194,7 @@ action = function(host, port) local kill_command = string.format("%s||%s||%s", trigger, linux_kill, windows_kill) -- Kill the process - stdnse.print_debug(1, "Running kill command: %s", kill_command) + stdnse.debug1("Running kill command: %s", kill_command) socket:send(kill_command .. "\n") end diff --git a/scripts/jdwp-exec.nse b/scripts/jdwp-exec.nse index 99f34db23..dec208bfe 100644 --- a/scripts/jdwp-exec.nse +++ b/scripts/jdwp-exec.nse @@ -48,7 +48,7 @@ action = function(host, port) stdnse.sleep(5) -- let the remote socket recover from connect() scan local status,socket = jdwp.connect(host,port) -- initialize the connection if not status then - stdnse.print_debug("error, %s",socket) + stdnse.debug1("error, %s",socket) return nil end diff --git a/scripts/jdwp-info.nse b/scripts/jdwp-info.nse index 0778542b1..fd509cd9e 100644 --- a/scripts/jdwp-info.nse +++ b/scripts/jdwp-info.nse @@ -55,7 +55,7 @@ action = function(host, port) stdnse.sleep(5) -- let the remote socket recover from connect() scan local status,socket = jdwp.connect(host,port) -- initialize the connection if not status then - stdnse.print_debug("error, %s",socket) + stdnse.debug1("error, %s",socket) return nil end diff --git a/scripts/jdwp-inject.nse b/scripts/jdwp-inject.nse index 2bb8f2bdb..8fc171bf3 100644 --- a/scripts/jdwp-inject.nse +++ b/scripts/jdwp-inject.nse @@ -42,7 +42,7 @@ action = function(host, port) stdnse.sleep(5) -- let the remote socket recover from connect() scan local status,socket = jdwp.connect(host,port) -- initialize the connection if not status then - stdnse.print_debug("error, %s",socket) + stdnse.debug1("error, %s",socket) return nil end diff --git a/scripts/ldap-brute.nse b/scripts/ldap-brute.nse index c6c198671..73815dbad 100644 --- a/scripts/ldap-brute.nse +++ b/scripts/ldap-brute.nse @@ -172,7 +172,7 @@ action = function( host, port ) context = get_naming_context(socket) if not context then - stdnse.print_debug("Failed to retrieve namingContext") + stdnse.debug1("Failed to retrieve namingContext") socket:close() return end @@ -207,12 +207,12 @@ action = function( host, port ) password = username end - stdnse.print_debug( "Trying %s/%s ...", fq_username, password ) + stdnse.debug1( "Trying %s/%s ...", fq_username, password ) status, response = ldap.bindRequest( socket, { version=3, ['username']=fq_username, ['password']=password} ) -- if the DN (username) does not exist, break loop if not status and response:match("invalid DN") then - stdnse.print_debug( "%s returned: \"Invalid DN\"", fq_username ) + stdnse.debug1( "%s returned: \"Invalid DN\"", fq_username ) invalid_account_cnt = invalid_account_cnt + 1 break end @@ -291,7 +291,7 @@ action = function( host, port ) passwords("reset") end - stdnse.print_debug( "Finished brute against LDAP, total tries: %d, tps: %d", tot_tries, ( tot_tries / ( ( nmap.clock_ms() - clock_start ) / 1000 ) ) ) + stdnse.debug1( "Finished brute against LDAP, total tries: %d, tps: %d", tot_tries, ( tot_tries / ( ( nmap.clock_ms() - clock_start ) / 1000 ) ) ) if ( invalid_account_cnt == user_cnt and base_dn ~= nil ) then return "WARNING: All usernames were invalid. Invalid LDAP base?" diff --git a/scripts/ldap-search.nse b/scripts/ldap-search.nse index 6e54db0c7..633e776a7 100644 --- a/scripts/ldap-search.nse +++ b/scripts/ldap-search.nse @@ -164,7 +164,7 @@ function action(host,port) end if ( not(contexts) or #contexts == 0 ) then - stdnse.print_debug( "Failed to retrieve namingContexts" ) + stdnse.debug1( "Failed to retrieve namingContexts" ) contexts = {""} end @@ -174,7 +174,7 @@ function action(host,port) local status, errmsg = ldap.bindRequest( socket, bindParam ) if not status then - stdnse.print_debug("ldap-search failed to bind: %s", errmsg) + stdnse.debug1("ldap-search failed to bind: %s", errmsg) return " \n ERROR: Authentication failed" end -- or if ldap-brute found us something @@ -240,7 +240,7 @@ function action(host,port) if ( searchResEntries:match("DSID[-]0C090627") and not(username) ) then return "ERROR: Failed to bind as the anonymous user" else - stdnse.print_debug("ldap.searchRequest returned: %s", searchResEntries) + stdnse.debug1("ldap.searchRequest returned: %s", searchResEntries) return end end diff --git a/scripts/lltd-discovery.nse b/scripts/lltd-discovery.nse index 196fb1673..774f57bd3 100644 --- a/scripts/lltd-discovery.nse +++ b/scripts/lltd-discovery.nse @@ -269,7 +269,7 @@ action = function() local interface = interface_opt or interface_arg local if_table = nmap.get_interface_info(interface) if not if_table or not if_table.address or not if_table.link=="ethernet" then - stdnse.print_debug("Interface not supported or not properly configured.") + stdnse.debug1("Interface not supported or not properly configured.") return false end table.insert(interfaces, if_table) @@ -286,7 +286,7 @@ action = function() end if #interfaces == 0 then - stdnse.print_debug("No interfaces found.") + stdnse.debug1("No interfaces found.") return end diff --git a/scripts/maxdb-info.nse b/scripts/maxdb-info.nse index 77cdbfb64..f6eeeaeb5 100644 --- a/scripts/maxdb-info.nse +++ b/scripts/maxdb-info.nse @@ -45,14 +45,14 @@ portrule = shortport.version_port_or_service(7210, "maxdb", "tcp") local function exchPacket(socket, packet) local status, err = socket:send(packet) if ( not(status) ) then - stdnse.print_debug(2, "Failed to send packet to server") + stdnse.debug2("Failed to send packet to server") return false, "Failed to send packet to server" end local data status, data= socket:receive() if ( not(status) ) then - stdnse.print_debug(2, "Failed to read packet from server") + stdnse.debug2("Failed to read packet from server") return false, "Failed to read packet from server" end local pos, len = bin.unpack(" 0) then - stdnse.print_debug("Test len: %d", #output) + stdnse.debug1("Test len: %d", #output) nmap.set_port_state(host, port, "open") if nmap.verbosity() < 1 then local mt = getmetatable(output) diff --git a/scripts/openlookup-info.nse b/scripts/openlookup-info.nse index 7194906fb..58a802164 100644 --- a/scripts/openlookup-info.nse +++ b/scripts/openlookup-info.nse @@ -203,7 +203,7 @@ function formatoptions(header) end local rawmeth = msg["method"] if not rawmeth then - stdnse.print_debug(2, "header missing method field") + stdnse.debug2("header missing method field") return end local method = parsestring(rawmeth) @@ -211,7 +211,7 @@ function formatoptions(header) return end if method ~= "hello" then - stdnse.print_debug(1, "expecting hello, got " .. method .. " instead") + stdnse.debug1("expecting hello, got " .. method .. " instead") return end local rawopts = msg["options"] diff --git a/scripts/oracle-brute.nse b/scripts/oracle-brute.nse index 9cae2550b..3ff78bc31 100644 --- a/scripts/oracle-brute.nse +++ b/scripts/oracle-brute.nse @@ -154,7 +154,7 @@ Driver = return true, brute.Account:new(username .. " as sysdba", password, creds.State.VALID) -- check for any other message elseif ( data:match("ORA[-]%d+")) then - stdnse.print_debug(3, "username: %s, password: %s, error: %s", username, password, data ) + stdnse.debug3("username: %s, password: %s, error: %s", username, password, data ) return false, brute.Error:new(data) -- any other errors are likely communication related, attempt to re-try else diff --git a/scripts/p2p-conficker.nse b/scripts/p2p-conficker.nse index 3b8cfb7bd..9bdb4a492 100644 --- a/scripts/p2p-conficker.nse +++ b/scripts/p2p-conficker.nse @@ -218,7 +218,7 @@ local function prng_generate_ports(ip, seed) local i local magic = 0x015A4E35 - stdnse.print_debug(1, "Conficker: Generating ports based on ip (0x%08x) and seed (%d)", ip, seed) + stdnse.debug1("Conficker: Generating ports based on ip (0x%08x) and seed (%d)", ip, seed) v1 = -(ip + 1) repeat @@ -274,7 +274,7 @@ local function p2p_checksum(data) local pos, i local hash = #data - stdnse.print_debug(2, "Conficker: Calculating checksum for %d-byte buffer", #data) + stdnse.debug2("Conficker: Calculating checksum for %d-byte buffer", #data) -- Get the first character pos, i = bin.unpack("") == nil then @@ -118,7 +118,7 @@ Driver = { local response local err local status - stdnse.print_debug( "Trying %s/%s ...", user, pass ) + stdnse.debug1( "Trying %s/%s ...", user, pass ) -- send username and password -- both are prefixed with 0x06, size and are encrypted status, err = self.socket:send(bin.pack("C",0x06) .. bin.pack("C",string.len(user)) .. encrypt(user) ) -- send username diff --git a/scripts/pgsql-brute.nse b/scripts/pgsql-brute.nse index f241f95fb..41330f3e2 100644 --- a/scripts/pgsql-brute.nse +++ b/scripts/pgsql-brute.nse @@ -105,7 +105,7 @@ action = function( host, port ) for username in usernames do ssl_enable = not(nossl) for password in passwords do - stdnse.print_debug("Trying %s/%s ...", username, password ) + stdnse.debug1("Trying %s/%s ...", username, password ) local socket = connectSocket( host, port, ssl_enable ) status, response = pg.sendStartup(socket, username, username) @@ -126,7 +126,7 @@ action = function( host, port ) status, response = pg.sendStartup(socket, username, username) if (not(status)) then if ( response:match("no pg_hba.conf entry for host") ) then - stdnse.print_debug("The host was denied access to db \"%s\" as user \"%s\", aborting ...", username, username ) + stdnse.debug1("The host was denied access to db \"%s\" as user \"%s\", aborting ...", username, username ) break else stdnse.debug1("sendStartup returned: %s", response ) diff --git a/scripts/quake3-info.nse b/scripts/quake3-info.nse index 077825fd8..ccf243348 100644 --- a/scripts/quake3-info.nse +++ b/scripts/quake3-info.nse @@ -83,7 +83,7 @@ local function parsefields(data) local parts = stdnse.strsplit("\\", data) local nullprefix = table.remove(parts, 1) if nullprefix ~= "" then - stdnse.print_debug(2, "unrecognized field format, skipping options") + stdnse.debug2("unrecognized field format, skipping options") return {} end for i = 1, #parts, 2 do @@ -112,11 +112,11 @@ end local function parseplayer(data) local parts = stdnse.strsplit(" ", data) if #parts < 3 then - stdnse.print_debug(2, "player info line is missing elements, skipping a player") + stdnse.debug2("player info line is missing elements, skipping a player") return nil end if #parts > 3 then - stdnse.print_debug(2, "player info line has unknown elements, skipping a player") + stdnse.debug2("player info line has unknown elements, skipping a player") return nil end local player = {} @@ -124,7 +124,7 @@ local function parseplayer(data) player.ping = parts[2] player.name = parsename(parts[3]) if player.name == nil then - stdnse.print_debug(2, "invalid player name serialization, skipping a player") + stdnse.debug2("invalid player name serialization, skipping a player") return nil end return player @@ -204,12 +204,12 @@ action = function(host, port) return end if #parts < 2 then - stdnse.print_debug(2, "incomplete status response, script abort") + stdnse.debug2("incomplete status response, script abort") return end local nullend = table.remove(parts) if nullend ~= "" then - stdnse.print_debug(2, "missing terminating endline, script abort") + stdnse.debug2("missing terminating endline, script abort") return end local field_data = table.remove(parts, 1) diff --git a/scripts/resolveall.nse b/scripts/resolveall.nse index d570f3b4b..f6ca493e8 100644 --- a/scripts/resolveall.nse +++ b/scripts/resolveall.nse @@ -52,7 +52,7 @@ local addtargets = function(list) if st then sum = sum + 1 else - stdnse.print_debug("Couldn't add target " .. t .. ": " .. err) + stdnse.debug1("Couldn't add target " .. t .. ": " .. err) end end diff --git a/scripts/rfc868-time.nse b/scripts/rfc868-time.nse index e025311b9..994e5f507 100644 --- a/scripts/rfc868-time.nse +++ b/scripts/rfc868-time.nse @@ -37,7 +37,7 @@ action = function(host, port) _, stamp = bin.unpack(">I", result) port.version.extrainfo = "64 bits" else - stdnse.print_debug(1, "Odd response: %s", stdnse.filename_escape(result)) + stdnse.debug1("Odd response: %s", stdnse.filename_escape(result)) return nil end @@ -49,7 +49,7 @@ action = function(host, port) local diff = os.difftime(stamp,os.time()) if diff < 0 then diff = -diff end -- confidence decreases by 1 for each year the time is off. - stdnse.print_debug(1, "Time difference: %d seconds (%0.2f years)", diff, diff / 31556926) + stdnse.debug1("Time difference: %d seconds (%0.2f years)", diff, diff / 31556926) local confidence = 10 - diff / 31556926 if confidence < 0 then confidence = 0 end port.version.name_confidence = confidence diff --git a/scripts/rlogin-brute.nse b/scripts/rlogin-brute.nse index 320fc6977..ab53172c0 100644 --- a/scripts/rlogin-brute.nse +++ b/scripts/rlogin-brute.nse @@ -76,7 +76,7 @@ Driver = { self.socket:close() end if ( not(status) ) then - stdnse.print_debug(3, "ERROR: failed to connect to server") + stdnse.debug3("ERROR: failed to connect to server") end return status end, @@ -92,7 +92,7 @@ Driver = { return false, err end if ( data ~= "\0" ) then - stdnse.print_debug(2, "ERROR: Expected null byte") + stdnse.debug2("ERROR: Expected null byte") local err = brute.Error:new( "Expected null byte" ) err:setRetry( true ) return false, err @@ -105,7 +105,7 @@ Driver = { return false, err end if ( data ~= "Password: " ) then - stdnse.print_debug(2, "ERROR: Expected password prompt") + stdnse.debug2("ERROR: Expected password prompt") local err = brute.Error:new( "Expected password prompt" ) err:setRetry( true ) return false, err diff --git a/scripts/rmi-dumpregistry.nse b/scripts/rmi-dumpregistry.nse index 1cd66b2d5..27dd8f0a5 100644 --- a/scripts/rmi-dumpregistry.nse +++ b/scripts/rmi-dumpregistry.nse @@ -155,11 +155,11 @@ portrule = shortport.port_or_service({1098, 1099, 1090, 8901, 8902, 8903}, {"jav -- Some lazy shortcuts local function dbg(str,...) - stdnse.print_debug(3,"RMI-DUMPREG:"..str, ...) + stdnse.debug3("RMI-DUMPREG:"..str, ...) end local function dbg_err(str, ... ) - stdnse.print_debug("RMI-DUMPREG-ERR:"..str, ...) + stdnse.debug1("RMI-DUMPREG-ERR:"..str, ...) end -- Function to split a string diff --git a/scripts/rpc-grind.nse b/scripts/rpc-grind.nse index beedf3241..2d8d00fe7 100644 --- a/scripts/rpc-grind.nse +++ b/scripts/rpc-grind.nse @@ -224,7 +224,7 @@ action = function(host, port) local result, lthreads = {}, {} if not isRPC(host, port) then - stdnse.print_debug("Target port %s is not a RPC port.", port.number) + stdnse.debug1("Target port %s is not a RPC port.", port.number) return end local threads = tonumber(stdnse.get_script_args(SCRIPT_NAME .. ".threads")) or 4 @@ -262,7 +262,7 @@ action = function(host, port) end nmap.set_port_version(host, port, "hardmatched") else - stdnse.print_debug("Couldn't determine the target RPC service. Running a service not in nmap-rpc ?") + stdnse.debug1("Couldn't determine the target RPC service. Running a service not in nmap-rpc ?") end return nil end diff --git a/scripts/rtsp-methods.nse b/scripts/rtsp-methods.nse index 4b2fc72f9..a371f0f66 100644 --- a/scripts/rtsp-methods.nse +++ b/scripts/rtsp-methods.nse @@ -36,7 +36,7 @@ action = function(host, port) local helper = rtsp.Helper:new(host, port) local status = helper:connect() if ( not(status) ) then - stdnse.print_debug(2, "ERROR: Failed to connect to RTSP server") + stdnse.debug2("ERROR: Failed to connect to RTSP server") return end diff --git a/scripts/rtsp-url-brute.nse b/scripts/rtsp-url-brute.nse index f44d360a9..37f1d8b8a 100644 --- a/scripts/rtsp-url-brute.nse +++ b/scripts/rtsp-url-brute.nse @@ -74,7 +74,7 @@ local function processURL(host, port, url_iter, result) local status = helper:connect() if ( not(status) ) then - stdnse.print_debug(2, "ERROR: Connecting to RTSP server url: %s", url) + stdnse.debug2("ERROR: Connecting to RTSP server url: %s", url) table.insert(result, { url = url, status = -1 } ) break end @@ -82,7 +82,7 @@ local function processURL(host, port, url_iter, result) local response status, response = helper:describe(url) if ( not(status) ) then - stdnse.print_debug(2, "ERROR: Sending DESCRIBE request to url: %s", url) + stdnse.debug2("ERROR: Sending DESCRIBE request to url: %s", url) table.insert(result, { url = url, status = -1 } ) break end diff --git a/scripts/s7-info.nse b/scripts/s7-info.nse index 2a401e57b..d44f0cf67 100644 --- a/scripts/s7-info.nse +++ b/scripts/s7-info.nse @@ -257,7 +257,7 @@ action = function(host, port) local pos, CC_connect_confirm = bin.unpack("C", response, 6) -- if PDU type is not 0xd0, then not a successful COTP connection if ( CC_connect_confirm ~= 0xd0) then - stdnse.print_debug(1, "Not a successful COTP Packet") + stdnse.debug1("Not a successful COTP Packet") return nil end -- send and receive the packets as before. @@ -266,7 +266,7 @@ action = function(host, port) local pos, protocol_id = bin.unpack("C", response, 8) -- if protocol ID is not 0x32 then return nil if ( protocol_id ~= 0x32) then - stdnse.print_debug(1, "Not a successful S7COMM Packet") + stdnse.debug1("Not a successful S7COMM Packet") return nil end response = send_receive(sock, Read_SZL) @@ -274,7 +274,7 @@ action = function(host, port) local pos, protocol_id = bin.unpack("C", response, 8) -- if protocol ID is not 0x32 then return nil if ( protocol_id ~= 0x32) then - stdnse.print_debug(1, "Not a successful S7COMM Packet") + stdnse.debug1("Not a successful S7COMM Packet") return nil end response = send_receive(sock, first_SZL_Request) diff --git a/scripts/samba-vuln-cve-2012-1182.nse b/scripts/samba-vuln-cve-2012-1182.nse index 6a96d4ad0..61bfc1ae5 100644 --- a/scripts/samba-vuln-cve-2012-1182.nse +++ b/scripts/samba-vuln-cve-2012-1182.nse @@ -119,7 +119,7 @@ from an anonymous connection. local marshaledHandle = string.rep("X",20) status, result = msrpc.samr_getaliasmembership(smbstate,marshaledHandle, data) - stdnse.print_debug(2, "msrpc.samr_getaliasmembership: %s, '%s'", status, result) + stdnse.debug2("msrpc.samr_getaliasmembership: %s, '%s'", status, result) if(status == false and string.find(result,"Failed to receive bytes after 5 attempts") ~= nil) then samba_cve.state = vulns.STATE.VULN -- connection dropped, server crashed end diff --git a/scripts/sip-brute.nse b/scripts/sip-brute.nse index aeb450e36..cee4630d2 100644 --- a/scripts/sip-brute.nse +++ b/scripts/sip-brute.nse @@ -81,7 +81,7 @@ local function checkBadUser(host, port) local pass = "badpass-" .. math.random(10000) local helper = sip.Helper:new(host, port, { expires = 0 }) - stdnse.print_debug(2, "Checking bad user: %s/%s", user, pass) + stdnse.debug2("Checking bad user: %s/%s", user, pass) local status, err = helper:connect() if ( not(status) ) then return false, "ERROR: Failed to connect" end diff --git a/scripts/smb-brute.nse b/scripts/smb-brute.nse index 8b6c9789f..d129022b7 100644 --- a/scripts/smb-brute.nse +++ b/scripts/smb-brute.nse @@ -513,7 +513,7 @@ local function find_password_case(hostinfo, username, password) end -- Print an error message - stdnse.print_debug(1, "ERROR: smb-brute: Was unable to determine case of %s's password", username) + stdnse.debug1("ERROR: smb-brute: Was unable to determine case of %s's password", username) -- If all else fails, just return the actual password (we probably shouldn't get here) return password diff --git a/scripts/smb-enum-sessions.nse b/scripts/smb-enum-sessions.nse index 99129578c..922e2cea9 100644 --- a/scripts/smb-enum-sessions.nse +++ b/scripts/smb-enum-sessions.nse @@ -211,7 +211,7 @@ local function winreg_enum_rids(host) -- Convert the SID to the name of the user local results = {} - stdnse.print_debug(3, "MSRPC: Found %d SIDs that might be logged in", #elements) + stdnse.debug3("MSRPC: Found %d SIDs that might be logged in", #elements) for i = 1, #elements, 1 do if(elements[i]['name'] ~= nil) then local sid = elements[i]['name'] @@ -223,7 +223,7 @@ local function winreg_enum_rids(host) if(status == false) then -- It may not succeed, if it doesn't that's ok - stdnse.print_debug(3, "MSRPC: Lookup failed") + stdnse.debug3("MSRPC: Lookup failed") else -- Create the result array local result = {} diff --git a/scripts/smb-enum-users.nse b/scripts/smb-enum-users.nse index cc6bbe8fd..7637b032c 100644 --- a/scripts/smb-enum-users.nse +++ b/scripts/smb-enum-users.nse @@ -170,7 +170,7 @@ action = function(host) if(samr_status) then -- Copy the returned array into the names[] table - stdnse.print_debug(2, "EnumUsers: Received %d names from SAMR", #samr_result) + stdnse.debug2("EnumUsers: Received %d names from SAMR", #samr_result) for i = 1, #samr_result, 1 do -- Insert the full info into the names list table.insert(names, samr_result[i]) @@ -185,7 +185,7 @@ action = function(host) lsa_status, lsa_result = msrpc.lsa_enum_users(host) if(lsa_status) then -- Copy the returned array into the names[] table - stdnse.print_debug(2, "EnumUsers: Received %d names from LSA", #lsa_result) + stdnse.debug2("EnumUsers: Received %d names from LSA", #lsa_result) for i = 1, #lsa_result, 1 do if(lsa_result[i]['name'] ~= nil) then -- Check if the name already exists diff --git a/scripts/smb-print-text.nse b/scripts/smb-print-text.nse index 011aeea27..346a7bbc5 100644 --- a/scripts/smb-print-text.nse +++ b/scripts/smb-print-text.nse @@ -45,7 +45,7 @@ action = function(host,port) local text = stdnse.get_script_args(SCRIPT_NAME .. '.text') local filename = stdnse.get_script_args(SCRIPT_NAME .. '.filename') if (not text) and (not filename) then - stdnse.print_debug("Script requires either text or filename script argument.") + stdnse.debug1("Script requires either text or filename script argument.") return false end local text_to_print @@ -58,7 +58,7 @@ action = function(host,port) end status, smbstate = msrpc.start_smb(host, msrpc.SPOOLSS_PATH,true) if(status == false) then - stdnse.print_debug("SMB: " .. smbstate) + stdnse.debug1("SMB: " .. smbstate) return false, smbstate end @@ -66,20 +66,20 @@ action = function(host,port) status, bind_result = msrpc.bind(smbstate,msrpc.SPOOLSS_UUID, msrpc.SPOOLSS_VERSION, nil) if(status == false) then msrpc.stop_smb(smbstate) - stdnse.print_debug("SMB: " .. bind_result) + stdnse.debug1("SMB: " .. bind_result) return false, bind_result end local printer = stdnse.get_script_args(SCRIPT_NAME .. '.printer') -- if printer not set find available printers if not printer then - stdnse.print_debug("No printer specified, trying to find one...") + stdnse.debug1("No printer specified, trying to find one...") local lanman_result local REMSmb_NetShareEnum_P = "WrLeh" local REMSmb_share_info_1 = "B13BWz" status, lanman_result = msrpc.call_lanmanapi(smbstate,0,REMSmb_NetShareEnum_P,REMSmb_share_info_1,bin.pack("ss",0x01,65406)) if status == false then - stdnse.print_debug("SMB: " .. lanman_result) - stdnse.print_debug("SMB: Looks like LANMAN API is not available. Try setting printer script arg.") + stdnse.debug1("SMB: " .. lanman_result) + stdnse.debug1("SMB: Looks like LANMAN API is not available. Try setting printer script arg.") return false end @@ -95,30 +95,30 @@ action = function(host,port) -- pos needs to be rounded to the next even multiple of 20 pos = pos + ( 20 - (#name % 20) ) - 1 if share_type == 1 then -- share is printer - stdnse.print_debug("Found printer share %s.", name) + stdnse.debug1("Found printer share %s.", name) printer = name end end end if not printer then - stdnse.print_debug("No printer found, system may be unpatched but it needs at least one printer shared to be vulnerable.") + stdnse.debug1("No printer found, system may be unpatched but it needs at least one printer shared to be vulnerable.") return false end - stdnse.print_debug("Using %s as printer.",printer) + stdnse.debug1("Using %s as printer.",printer) -- call RpcOpenPrinterEx - opnum 69 local status, result = msrpc.spoolss_open_printer(smbstate,"\\\\"..host.ip.."\\"..printer) if not status then return false end local printer_handle = string.sub(result.data,25,#result.data-4) - stdnse.print_debug("Printer handle %s",stdnse.tohex(printer_handle)) + stdnse.debug1("Printer handle %s",stdnse.tohex(printer_handle)) -- call RpcStartDocPrinter - opnum 17 status,result = msrpc.spoolss_start_doc_printer(smbstate,printer_handle,"nmap_print_test.txt") -- patched version will allow this if not status then return false end local print_job_id = string.sub(result.data,25,#result.data-4) - stdnse.print_debug("Start doc printer job id %s",stdnse.tohex(print_job_id)) + stdnse.debug1("Start doc printer job id %s",stdnse.tohex(print_job_id)) -- call RpcWritePrinter - 19 status, result = msrpc.spoolss_write_printer(smbstate,printer_handle,text_to_print) @@ -126,7 +126,7 @@ action = function(host,port) return false end local write_result = string.sub(result.data,25,#result.data-4) - stdnse.print_debug("Written %s bytes to a file.",stdnse.tohex(write_result)) + stdnse.debug1("Written %s bytes to a file.",stdnse.tohex(write_result)) status,result = msrpc.spoolss_end_doc_printer(smbstate,printer_handle) diff --git a/scripts/smb-psexec.nse b/scripts/smb-psexec.nse index 21aaf2a17..eedfea5a8 100644 --- a/scripts/smb-psexec.nse +++ b/scripts/smb-psexec.nse @@ -806,7 +806,7 @@ local function get_config(host, config) end -- Load the config file - local env = setmetatable({modules = {}; overrides = {}; module = function() stdnse.print_debug(1, "WARNING: Selected config file contains an unnecessary call to module()") end}, {__index = _G}) + local env = setmetatable({modules = {}; overrides = {}; module = function() stdnse.debug1("WARNING: Selected config file contains an unnecessary call to module()") end}, {__index = _G}) stdnse.debug1("Attempting to load config file: %s", filename) local file = loadfile(filename, "t", env) if(not(file)) then @@ -963,10 +963,10 @@ local function get_config(host, config) mod.filename = locate_file(mod.program, "exe") if(mod.filename == nil) then enabled = false - stdnse.print_debug(1, "Couldn't find uploadable module %s, disabling", mod.program) + stdnse.debug1("Couldn't find uploadable module %s, disabling", mod.program) mod.disabled_message = {string.format("Couldn't find uploadable module %s, disabling", mod.program)} if(mod.url) then - stdnse.print_debug(1, "You can try getting it from: %s", mod.url) + stdnse.debug1("You can try getting it from: %s", mod.url) table.insert(mod.disabled_message, string.format("You can try getting it from: %s", mod.url)) table.insert(mod.disabled_message, "And placing it in Nmap's nselib/data/psexec/ directory") end @@ -1124,7 +1124,7 @@ local function upload_everything(host, config) if is_xor_encoded == nil then return nil, msg elseif is_xor_encoded then - stdnse.print_debug(2, "%s is the XOR-encoded version from the 5.21 release.", config.local_service_file) + stdnse.debug2("%s is the XOR-encoded version from the 5.21 release.", config.local_service_file) end -- Upload the service file @@ -1407,8 +1407,8 @@ local function parse_output(config, data) -- Go to the next module, and make sure it exists mod = config.enabled_modules[module_num + 1] if(mod == nil) then - stdnse.print_debug(1, "Server's response wasn't formatted properly (mod %d); if you can reproduce, place report to dev@nmap.org", module_num) - stdnse.print_debug(1, "--\n" .. string.gsub("%%", "%%", data) .. "\n--") + stdnse.debug1("Server's response wasn't formatted properly (mod %d); if you can reproduce, place report to dev@nmap.org", module_num) + stdnse.debug1("--\n" .. string.gsub("%%", "%%", data) .. "\n--") return false, "Server's response wasn't formatted properly; if you can reproduce, place report to dev@nmap.org" end diff --git a/scripts/smb-vuln-ms10-054.nse b/scripts/smb-vuln-ms10-054.nse index 0df61cd52..917efbb71 100644 --- a/scripts/smb-vuln-ms10-054.nse +++ b/scripts/smb-vuln-ms10-054.nse @@ -88,7 +88,7 @@ local function send_transaction2(smbstate, sub_command, function_parameters) local data = "\0\0\0" .. (function_parameters 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.smb_send(smbstate, header, parameters, data, {}) if(result == false) then return false, err @@ -99,7 +99,7 @@ end action = function(host,port) if not stdnse.get_script_args(SCRIPT_NAME .. '.unsafe') then - stdnse.print_debug("You must specify unsafe script argument to run this script.") + stdnse.debug1("You must specify unsafe script argument to run this script.") return false end local ms10_054 = { @@ -138,7 +138,7 @@ to execute arbitrary code via a crafted SMB packet, aka "SMB Pool Overflow Vulne if not status then -- if not , it has crashed ms10_054.state = vulns.STATE.VULN else - stdnse.print_debug("Machine is not vulnerable") + stdnse.debug1("Machine is not vulnerable") end return report:make_output(ms10_054) end diff --git a/scripts/smb-vuln-ms10-061.nse b/scripts/smb-vuln-ms10-061.nse index f2f4cb8e7..af5fedd86 100644 --- a/scripts/smb-vuln-ms10-061.nse +++ b/scripts/smb-vuln-ms10-061.nse @@ -91,7 +91,7 @@ aka "Print Spooler Service Impersonation Vulnerability." local status, smbstate status, smbstate = msrpc.start_smb(host, msrpc.SPOOLSS_PATH,true) if(status == false) then - stdnse.print_debug("SMB: " .. smbstate) + stdnse.debug1("SMB: " .. smbstate) return false, smbstate end @@ -99,20 +99,20 @@ aka "Print Spooler Service Impersonation Vulnerability." status, bind_result = msrpc.bind(smbstate,msrpc.SPOOLSS_UUID, msrpc.SPOOLSS_VERSION, nil) if(status == false) then msrpc.stop_smb(smbstate) - stdnse.print_debug("SMB: " .. bind_result) + stdnse.debug1("SMB: " .. bind_result) return false, bind_result end local printer = stdnse.get_script_args(SCRIPT_NAME .. '.printer') -- if printer not set find available printers if not printer then - stdnse.print_debug("No printer specified, trying to find one...") + stdnse.debug1("No printer specified, trying to find one...") local lanman_result local REMSmb_NetShareEnum_P = "WrLeh" local REMSmb_share_info_1 = "B13BWz" status, lanman_result = msrpc.call_lanmanapi(smbstate,0,REMSmb_NetShareEnum_P,REMSmb_share_info_1,bin.pack("ss",0x01,65406)) if status == false then - stdnse.print_debug("SMB: " .. lanman_result) - stdnse.print_debug("SMB: Looks like LANMAN API is not available. Try setting printer script arg.") + stdnse.debug1("SMB: " .. lanman_result) + stdnse.debug1("SMB: Looks like LANMAN API is not available. Try setting printer script arg.") end local parameters = lanman_result.parameters @@ -127,30 +127,30 @@ aka "Print Spooler Service Impersonation Vulnerability." -- pos needs to be rounded to the next even multiple of 20 pos = pos + ( 20 - (#name % 20) ) - 1 if share_type == 1 then -- share is printer - stdnse.print_debug("Found printer share %s.", name) + stdnse.debug1("Found printer share %s.", name) printer = name end end end if not printer then - stdnse.print_debug("No printer found, system may be unpatched but it needs at least one printer shared to be vulnerable.") + stdnse.debug1("No printer found, system may be unpatched but it needs at least one printer shared to be vulnerable.") return false end - stdnse.print_debug("Using %s as printer.",printer) + stdnse.debug1("Using %s as printer.",printer) -- call RpcOpenPrinterEx - opnum 69 local status, result = msrpc.spoolss_open_printer(smbstate,"\\\\"..host.ip.."\\"..printer) if not status then return false end local printer_handle = string.sub(result.data,25,#result.data-4) - stdnse.print_debug("Printer handle %s",stdnse.tohex(printer_handle)) + stdnse.debug1("Printer handle %s",stdnse.tohex(printer_handle)) -- call RpcStartDocPrinter - opnum 17 status,result = msrpc.spoolss_start_doc_printer(smbstate,printer_handle,",") -- patched version will allow this if not status then return false end local print_job_id = string.sub(result.data,25,#result.data-4) - stdnse.print_debug("Start doc printer job id %s",stdnse.tohex(print_job_id)) + stdnse.debug1("Start doc printer job id %s",stdnse.tohex(print_job_id)) -- call RpcWritePrinter - 19 status, result = msrpc.spoolss_write_printer(smbstate,printer_handle,"aaaa") @@ -158,7 +158,7 @@ aka "Print Spooler Service Impersonation Vulnerability." return false end local write_result = string.sub(result.data,25,#result.data-4) - stdnse.print_debug("Written %s bytes to a file.",stdnse.tohex(write_result)) + stdnse.debug1("Written %s bytes to a file.",stdnse.tohex(write_result)) if stdnse.tohex(write_result) == "00000000" then -- patched version would report 4 bytes written ms10_061.state = vulns.STATE.VULN -- identified by diffing patched an unpatched version end diff --git a/scripts/snmp-brute.nse b/scripts/snmp-brute.nse index 1c71d4a8a..59562d86e 100644 --- a/scripts/snmp-brute.nse +++ b/scripts/snmp-brute.nse @@ -287,7 +287,7 @@ action = function(host, port) -- return output return tostring(c) else - stdnse.print_debug("An error occurred: "..result.msg) + stdnse.debug1("An error occurred: "..result.msg) end end diff --git a/scripts/snmp-interfaces.nse b/scripts/snmp-interfaces.nse index 2bb040baf..4081e67bc 100644 --- a/scripts/snmp-interfaces.nse +++ b/scripts/snmp-interfaces.nse @@ -433,7 +433,7 @@ action = function(host, port) return end - stdnse.print_debug("SNMP walk of IF-MIB returned %d lines", #interfaces) + stdnse.debug1("SNMP walk of IF-MIB returned %d lines", #interfaces) -- build a table of network interfaces from the IF-MIB table interfaces = process_interfaces( interfaces ) @@ -461,7 +461,7 @@ action = function(host, port) if st then sum = sum + 1 else - stdnse.print_debug("Couldn't add target " .. i .. ": " .. err) + stdnse.debug1("Couldn't add target " .. i .. ": " .. err) end end diff --git a/scripts/socks-open-proxy.nse b/scripts/socks-open-proxy.nse index 56218a204..067225a82 100644 --- a/scripts/socks-open-proxy.nse +++ b/scripts/socks-open-proxy.nse @@ -58,7 +58,7 @@ local function custom_test(host, port, test_url, pattern) -- strip hostname if not string.match(test_url, "^http://.*") then test_url = "http://" .. test_url - stdnse.print_debug("URL missing scheme. URL concatenated to http://") + stdnse.debug1("URL missing scheme. URL concatenated to http://") end local url_table = url.parse(test_url) local hostname = url_table.host @@ -118,7 +118,7 @@ local function default_test(host, port) -- if we do not receive any valid status code, -- there is no reason to keep testing... the proxy is probably not open if not (cstatus4 or cstatus5) then return false, nil end - stdnse.print_debug("Test 1 - Google Web Server: Received valid status codes, but pattern does not match") + stdnse.debug1("Test 1 - Google Web Server: Received valid status codes, but pattern does not match") test_url = "/" hostname = "www.wikipedia.org" @@ -131,7 +131,7 @@ local function default_test(host, port) if(fstatus) then return fstatus, response end if not (cstatus4 or cstatus5) then return false, nil end - stdnse.print_debug("Test 2 - Wikipedia.org: Received valid status codes, but pattern does not match") + stdnse.debug1("Test 2 - Wikipedia.org: Received valid status codes, but pattern does not match") local redir_check_get = get_r4 or get_r5 @@ -146,7 +146,7 @@ local function default_test(host, port) if(fstatus) then return fstatus, response end if not (cstatus4 or cstatus5) then return false, nil end - stdnse.print_debug("Test 3 - Computer History: Received valid status codes, but pattern does not match") + stdnse.debug1("Test 3 - Computer History: Received valid status codes, but pattern does not match") -- Check if GET is being redirected if proxy.redirectCheck(get_r4 or get_r5, redir_check_get) then diff --git a/scripts/ssh-hostkey.nse b/scripts/ssh-hostkey.nse index 6f3d8c9a6..81832381a 100644 --- a/scripts/ssh-hostkey.nse +++ b/scripts/ssh-hostkey.nse @@ -190,7 +190,7 @@ local function check_keys(host, keys, f) end else if stdnse.contains(possible_host_names, parts[1]) then - stdnse.print_debug(2, "Found an entry that matches: %s", parts[1]) + stdnse.debug2("Found an entry that matches: %s", parts[1]) table.insert(keys_from_file, ("%s %s"):format(parts[2], parts[3])) else -- Is the key the same but the clear text hostname isn't? diff --git a/scripts/ssl-ccs-injection.nse b/scripts/ssl-ccs-injection.nse index 21b5851b8..0d6715024 100644 --- a/scripts/ssl-ccs-injection.nse +++ b/scripts/ssl-ccs-injection.nse @@ -138,14 +138,14 @@ local function test_ccs_injection(host, port, version) if specialized then status, s = specialized(host, port) if not status then - stdnse.print_debug(3, "Connection to server failed") + stdnse.debug3("Connection to server failed") return end else s = nmap.new_socket() status = s:connect(host, port) if not status then - stdnse.print_debug(3, "Connection to server failed") + stdnse.debug3("Connection to server failed") return end end @@ -156,7 +156,7 @@ local function test_ccs_injection(host, port, version) -- Send Client Hello to the target server status, err = s:send(hello) if not status then - stdnse.print_debug(1, "Couldn't send Client Hello: %s", err) + stdnse.debug1("Couldn't send Client Hello: %s", err) s:close() return false end @@ -180,7 +180,7 @@ local function test_ccs_injection(host, port, version) s:close() return "NOT_VULNERABLE" elseif record.protocol ~= version then - stdnse.print_debug(1, "%s: Protocol version mismatch (%s)", + stdnse.debug1("%s: Protocol version mismatch (%s)", SCRIPT_NAME, version) s:close() return false, true @@ -189,7 +189,7 @@ local function test_ccs_injection(host, port, version) if record.type == "handshake" then for _, body in ipairs(record.body) do if body.type == "server_hello_done" then - stdnse.print_debug(1, "Handshake completed (%s)", version) + stdnse.debug1("Handshake completed (%s)", version) done = true end end @@ -207,7 +207,7 @@ local function test_ccs_injection(host, port, version) -- Send the first ccs message status, err = s:send(ccs) if not status then - stdnse.print_debug(1, "Couldn't send first ccs message: %s", err) + stdnse.debug1("Couldn't send first ccs message: %s", err) s:close() return false end @@ -215,7 +215,7 @@ local function test_ccs_injection(host, port, version) -- Send the second ccs message status, err = s:send(ccs) if not status then - stdnse.print_debug(1, "Couldn't send second ccs message: %s", err) + stdnse.debug1("Couldn't send second ccs message: %s", err) s:close() return false end diff --git a/scripts/ssl-enum-ciphers.nse b/scripts/ssl-enum-ciphers.nse index 2225bac2f..e84bc807d 100644 --- a/scripts/ssl-enum-ciphers.nse +++ b/scripts/ssl-enum-ciphers.nse @@ -146,7 +146,7 @@ local function try_params(host, port, t) local status status, sock = specialized(host, port) if not status then - stdnse.print_debug(1, "Can't connect: %s", err) + stdnse.debug1("Can't connect: %s", err) return nil end else @@ -154,7 +154,7 @@ local function try_params(host, port, t) sock:set_timeout(5000) local status = sock:connect(host, port) if not status then - stdnse.print_debug(1, "Can't connect: %s", err) + stdnse.debug1("Can't connect: %s", err) sock:close() return nil end @@ -166,7 +166,7 @@ local function try_params(host, port, t) req = tls.client_hello(t) status, err = sock:send(req) if not status then - stdnse.print_debug(1, "Can't send: %s", err) + stdnse.debug1("Can't send: %s", err) sock:close() return nil end @@ -178,13 +178,13 @@ local function try_params(host, port, t) local status status, buffer, err = tls.record_buffer(sock, buffer, 1) if not status then - stdnse.print_debug(1, "Couldn't read a TLS record: %s", err) + stdnse.debug1("Couldn't read a TLS record: %s", err) return nil end -- Parse response. i, record = tls.record_read(buffer, 1) if record and record.type == "alert" and record.body[1].level == "warning" then - stdnse.print_debug(1, "Ignoring warning: %s", record.body[1].description) + stdnse.debug1("Ignoring warning: %s", record.body[1].description) -- Try again. elseif record then sock:close() @@ -253,26 +253,26 @@ local function find_ciphers(host, port, protocol) if record == nil then if protocol_worked then - stdnse.print_debug(2, "%d ciphers rejected. (No handshake)", #group) + stdnse.debug2("%d ciphers rejected. (No handshake)", #group) else - stdnse.print_debug(1, "%d ciphers and/or protocol %s rejected. (No handshake)", #group, protocol) + stdnse.debug1("%d ciphers and/or protocol %s rejected. (No handshake)", #group, protocol) end break elseif record["protocol"] ~= protocol then - stdnse.print_debug(1, "Protocol %s rejected.", protocol) + stdnse.debug1("Protocol %s rejected.", protocol) protocol_worked = nil break elseif record["type"] == "alert" and record["body"][1]["description"] == "handshake_failure" then protocol_worked = true - stdnse.print_debug(2, "%d ciphers rejected.", #group) + stdnse.debug2("%d ciphers rejected.", #group) break elseif record["type"] ~= "handshake" or record["body"][1]["type"] ~= "server_hello" then - stdnse.print_debug(2, "Unexpected record received.") + stdnse.debug2("Unexpected record received.") break else protocol_worked = true name = record["body"][1]["cipher"] - stdnse.print_debug(2, "Cipher %s chosen.", name) + stdnse.debug2("Cipher %s chosen.", name) remove(group, name) -- Add cipher to the list of accepted ciphers. @@ -316,25 +316,25 @@ local function find_compressors(host, port, protocol, good_cipher) if record == nil then if protocol_worked then - stdnse.print_debug(2, "%d compressors rejected. (No handshake)", #compressors) + stdnse.debug2("%d compressors rejected. (No handshake)", #compressors) else - stdnse.print_debug(1, "%d compressors and/or protocol %s rejected. (No handshake)", #compressors, protocol) + stdnse.debug1("%d compressors and/or protocol %s rejected. (No handshake)", #compressors, protocol) end break elseif record["protocol"] ~= protocol then - stdnse.print_debug(1, "Protocol %s rejected.", protocol) + stdnse.debug1("Protocol %s rejected.", protocol) break elseif record["type"] == "alert" and record["body"][1]["description"] == "handshake_failure" then protocol_worked = true - stdnse.print_debug(2, "%d compressors rejected.", #compressors) + stdnse.debug2("%d compressors rejected.", #compressors) break elseif record["type"] ~= "handshake" or record["body"][1]["type"] ~= "server_hello" then - stdnse.print_debug(2, "Unexpected record received.") + stdnse.debug2("Unexpected record received.") break else protocol_worked = true name = record["body"][1]["compressor"] - stdnse.print_debug(2, "Compressor %s chosen.", name) + stdnse.debug2("Compressor %s chosen.", name) remove(compressors, name) -- Add compressor to the list of accepted compressors. @@ -381,9 +381,9 @@ local function try_protocol(host, port, protocol, upresults) else cipherstr="unknown strength" end - stdnse.print_debug(2, "Strength of %s rated %d.",cipherstr,cipherstrength[cipherstr]) + stdnse.debug2("Strength of %s rated %d.",cipherstr,cipherstrength[cipherstr]) if mincipherstrength>cipherstrength[cipherstr] then - stdnse.print_debug(2, "Downgrading min cipher strength to %d.",cipherstrength[cipherstr]) + stdnse.debug2("Downgrading min cipher strength to %d.",cipherstrength[cipherstr]) mincipherstrength=cipherstrength[cipherstr] end local outcipher = {name=name, strength=cipherstr} @@ -431,7 +431,7 @@ local filltable = function(filename,table) if cipherstrength[lsplit[2]] then table[lsplit[1]] = lsplit[2] else - stdnse.print_debug(1,"Strength not defined, ignoring: %s:%s",lsplit[1],lsplit[2]) + stdnse.debug1("Strength not defined, ignoring: %s:%s",lsplit[1],lsplit[2]) end end end @@ -474,7 +474,7 @@ action = function(host, port) filltable(rankedciphersfilename,rankedciphers) else rankedciphersfilename = nmap.fetchfile( "nselib/data/ssl-ciphers" ) - stdnse.print_debug(1, "Ranked ciphers filename: %s", rankedciphersfilename) + stdnse.debug1("Ranked ciphers filename: %s", rankedciphersfilename) filltable(rankedciphersfilename,rankedciphers) end @@ -484,7 +484,7 @@ action = function(host, port) local threads = {} for name, _ in pairs(tls.PROTOCOLS) do - stdnse.print_debug(1, "Trying protocol %s.", name) + stdnse.debug1("Trying protocol %s.", name) local co = stdnse.new_thread(try_protocol, host, port, name, results) threads[co] = true end diff --git a/scripts/ssl-heartbleed.nse b/scripts/ssl-heartbleed.nse index 51f8bfd9a..a2d6a3b5b 100644 --- a/scripts/ssl-heartbleed.nse +++ b/scripts/ssl-heartbleed.nse @@ -52,7 +52,7 @@ end local function recvhdr(s) local status, hdr = s:receive_buf(match.numbytes(5), true) if not status then - stdnse.print_debug(3, 'Unexpected EOF receiving record header - server closed connection') + stdnse.debug3('Unexpected EOF receiving record header - server closed connection') return end local pos, typ, ver, ln = bin.unpack('>CSS', hdr) @@ -62,7 +62,7 @@ end local function recvmsg(s, len) local status, pay = s:receive_buf(match.numbytes(len), true) if not status then - stdnse.print_debug(3, 'Unexpected EOF receiving record payload - server closed connection') + stdnse.debug3('Unexpected EOF receiving record payload - server closed connection') return end return true, pay @@ -109,14 +109,14 @@ local function testversion(host, port, version) local status status, s = specialized(host, port) if not status then - stdnse.print_debug(3, "Connection to server failed") + stdnse.debug3("Connection to server failed") return end else s = nmap.new_socket() local status = s:connect(host, port) if not status then - stdnse.print_debug(3, "Connection to server failed") + stdnse.debug3("Connection to server failed") return end end @@ -126,7 +126,7 @@ local function testversion(host, port, version) -- Send Client Hello to the target server local status, err = s:send(hello) if not status then - stdnse.print_debug("Couldn't send Client Hello: %s", err) + stdnse.debug1("Couldn't send Client Hello: %s", err) s:close() return nil end @@ -145,7 +145,7 @@ local function testversion(host, port, version) done = true break elseif not status then - stdnse.print_debug("Couldn't receive: %s", err) + stdnse.debug1("Couldn't receive: %s", err) s:close() return nil end @@ -169,7 +169,7 @@ local function testversion(host, port, version) supported = true end elseif body.type == "server_hello_done" then - stdnse.print_debug("we're done!") + stdnse.debug1("we're done!") done = true end end @@ -183,14 +183,14 @@ local function testversion(host, port, version) status, err = s:send(hb) if not status then - stdnse.print_debug("Couldn't send heartbeat request: %s", err) + stdnse.debug1("Couldn't send heartbeat request: %s", err) s:close() return nil end while(true) do local status, typ, ver, len = recvhdr(s) if not status then - stdnse.print_debug(1, 'No heartbeat response received, server likely not vulnerable') + stdnse.debug1('No heartbeat response received, server likely not vulnerable') break end if typ == 24 then @@ -200,11 +200,11 @@ local function testversion(host, port, version) if #pay > 3 then return true else - stdnse.print_debug(1, 'Server processed malformed heartbeat, but did not return any extra data.') + stdnse.debug1('Server processed malformed heartbeat, but did not return any extra data.') break end elseif typ == 21 then - stdnse.print_debug(1, 'Server returned error, likely not vulnerable') + stdnse.debug1('Server returned error, likely not vulnerable') break end end diff --git a/scripts/ssl-known-key.nse b/scripts/ssl-known-key.nse index 357bcbb9b..c36f3ad94 100644 --- a/scripts/ssl-known-key.nse +++ b/scripts/ssl-known-key.nse @@ -49,7 +49,7 @@ local FINGERPRINT_FILE = "ssl-fingerprints" local get_fingerprints = function(path) -- Check registry for cached fingerprints. if nmap.registry.ssl_fingerprints then - stdnse.print_debug(2, "Using cached SSL fingerprints.") + stdnse.debug2("Using cached SSL fingerprints.") return true, nmap.registry.ssl_fingerprints end @@ -58,7 +58,7 @@ local get_fingerprints = function(path) if not full_path then full_path = path end - stdnse.print_debug(2, "Loading SSL fingerprints from %s.", full_path) + stdnse.debug2("Loading SSL fingerprints from %s.", full_path) -- Open database. local file = io.open(full_path, "r") @@ -77,20 +77,20 @@ local get_fingerprints = function(path) if line:sub(1,1) == "[" then -- Start a new section. line = line:sub(2, #line - 1) - stdnse.print_debug(4, "Starting new section %s.", line) + stdnse.debug4("Starting new section %s.", line) section = line elseif section ~= nil then -- Add fingerprint to section. local fingerprint = bin.pack("H", line) if #fingerprint == 20 then fingerprints[fingerprint] = section - stdnse.print_debug(4, "Added key %s to database.", line) + stdnse.debug4("Added key %s to database.", line) else - stdnse.print_debug(0, "Cannot parse presumed fingerprint %q in section %q.", line, section) + stdnse.debug0("Cannot parse presumed fingerprint %q in section %q.", line, section) end else -- Key found outside of section. - stdnse.print_debug(1, "Key %s is not in a section.", line) + stdnse.debug1("Key %s is not in a section.", line) end end end @@ -119,7 +119,7 @@ action = function(host, port) -- Get SSL certificate. local status, cert = sslcert.getCertificate(host, port) if not status then - stdnse.print_debug(1, "sslcert.getCertificate error: %s", cert) + stdnse.debug1("sslcert.getCertificate error: %s", cert) return end local fingerprint = cert:digest("sha1") @@ -128,7 +128,7 @@ action = function(host, port) -- Check SSL fingerprint against database. local section = fingerprints[fingerprint] if not section then - stdnse.print_debug(2, "%s was not in the database.", fingerprint_fmt) + stdnse.debug2("%s was not in the database.", fingerprint_fmt) return end diff --git a/scripts/stuxnet-detect.nse b/scripts/stuxnet-detect.nse index 85ab30a74..0acfbd911 100644 --- a/scripts/stuxnet-detect.nse +++ b/scripts/stuxnet-detect.nse @@ -47,14 +47,14 @@ local function check_infected(host, path, save) -- Create an SMB session. status, session = msrpc.start_smb(host, path) if not status then - stdnse.print_debug(1, "Failed to establish session on %s.", path) + stdnse.debug1("Failed to establish session on %s.", path) return false, nil end -- Bind to the Stuxnet service. status, result = msrpc.bind(session, STUXNET_UUID, STUXNET_VERSION, nil) if not status or result["ack_result"] ~= 0 then - stdnse.print_debug(1, "Failed to bind to Stuxnet service.") + stdnse.debug1("Failed to bind to Stuxnet service.") msrpc.stop_smb(session) return false, nil end @@ -62,7 +62,7 @@ local function check_infected(host, path, save) -- Request version of Stuxnet infection. status, result = msrpc.call_function(session, RPC_GET_VERSION, "") if not status then - stdnse.print_debug(1, "Failed to retrieve Stuxnet version: %s", result) + stdnse.debug1("Failed to retrieve Stuxnet version: %s", result) msrpc.stop_smb(session) return false, nil end @@ -74,7 +74,7 @@ local function check_infected(host, path, save) status, result = msrpc.call_function(session, RPC_GET_EXECUTABLE, "") if not status then - stdnse.print_debug(1, "Failed to retrieve Stuxnet executable: %s", result) + stdnse.debug1("Failed to retrieve Stuxnet executable: %s", result) msrpc.stop_smb(session) return true, version end @@ -83,11 +83,11 @@ local function check_infected(host, path, save) fmt = fmt:gsub("%%v", version) file = io.open(stdnse.filename_escape(fmt), "w") if file then - stdnse.print_debug(1, "Wrote %d bytes to file %s.", #result.arguments, fmt) + stdnse.debug1("Wrote %d bytes to file %s.", #result.arguments, fmt) file:write(result.arguments) file:close() else - stdnse.print_debug(1, "Failed to open file: %s", fmt) + stdnse.debug1("Failed to open file: %s", fmt) end end diff --git a/scripts/targets-asn.nse b/scripts/targets-asn.nse index 020c71f60..8ff379b2a 100644 --- a/scripts/targets-asn.nse +++ b/scripts/targets-asn.nse @@ -85,7 +85,7 @@ action = function(host, port) if ( #prefix > 1 ) then table.insert(prefixes,prefix) if target.ALLOW_NEW_TARGETS then - stdnse.print_debug("Added targets: "..prefix) + stdnse.debug1("Added targets: "..prefix) local status,err = target.add(prefix) end end diff --git a/scripts/targets-ipv6-multicast-echo.nse b/scripts/targets-ipv6-multicast-echo.nse index caa65fece..6af0c8a69 100644 --- a/scripts/targets-ipv6-multicast-echo.nse +++ b/scripts/targets-ipv6-multicast-echo.nse @@ -46,7 +46,7 @@ local function get_interfaces() if if_table and packet.ip6tobin(if_table.address) and if_table.link == "ethernet" then interfaces[#interfaces + 1] = if_table else - stdnse.print_debug("Interface not supported or not properly configured.") + stdnse.debug1("Interface not supported or not properly configured.") end else for _, if_table in ipairs(nmap.list_interfaces()) do @@ -60,7 +60,7 @@ local function get_interfaces() end local function single_interface_broadcast(if_nfo, results) - stdnse.print_debug("Starting " .. SCRIPT_NAME .. " on " .. if_nfo.device) + stdnse.debug1("Starting " .. SCRIPT_NAME .. " on " .. if_nfo.device) local condvar = nmap.condvar(results) local src_mac = if_nfo.mac diff --git a/scripts/targets-ipv6-multicast-invalid-dst.nse b/scripts/targets-ipv6-multicast-invalid-dst.nse index 891083258..13127a3cd 100644 --- a/scripts/targets-ipv6-multicast-invalid-dst.nse +++ b/scripts/targets-ipv6-multicast-invalid-dst.nse @@ -65,7 +65,7 @@ local function get_interfaces() if if_table and packet.ip6tobin(if_table.address) and if_table.link == "ethernet" then interfaces[#interfaces + 1] = if_table else - stdnse.print_debug("Interface not supported or not properly configured.") + stdnse.debug1("Interface not supported or not properly configured.") end else for _, if_table in ipairs(nmap.list_interfaces()) do @@ -79,7 +79,7 @@ local function get_interfaces() end local function single_interface_broadcast(if_nfo, results) - stdnse.print_debug("Starting " .. SCRIPT_NAME .. " on " .. if_nfo.device) + stdnse.debug1("Starting " .. SCRIPT_NAME .. " on " .. if_nfo.device) local condvar = nmap.condvar(results) local src_mac = if_nfo.mac diff --git a/scripts/targets-ipv6-multicast-mld.nse b/scripts/targets-ipv6-multicast-mld.nse index d2e67aa77..d590be161 100644 --- a/scripts/targets-ipv6-multicast-mld.nse +++ b/scripts/targets-ipv6-multicast-mld.nse @@ -55,7 +55,7 @@ local function get_interfaces() if if_table and packet.ip6tobin(if_table.address) and if_table.link == "ethernet" then interfaces[#interfaces + 1] = if_table else - stdnse.print_debug("Interface not supported or not properly configured.") + stdnse.debug1("Interface not supported or not properly configured.") end else for _, if_table in ipairs(nmap.list_interfaces()) do @@ -69,7 +69,7 @@ local function get_interfaces() end local function single_interface_broadcast(if_nfo, results) - stdnse.print_debug(2, "Starting " .. SCRIPT_NAME .. " on " .. if_nfo.device) + stdnse.debug2("Starting " .. SCRIPT_NAME .. " on " .. if_nfo.device) local condvar = nmap.condvar(results) local src_mac = if_nfo.mac local src_ip6 = packet.ip6tobin(if_nfo.address) diff --git a/scripts/targets-ipv6-multicast-slaac.nse b/scripts/targets-ipv6-multicast-slaac.nse index 8fbb92e65..d5bc94f75 100644 --- a/scripts/targets-ipv6-multicast-slaac.nse +++ b/scripts/targets-ipv6-multicast-slaac.nse @@ -107,7 +107,7 @@ local function get_interfaces() if if_table and packet.ip6tobin(if_table.address) and if_table.link == "ethernet" then interfaces[#interfaces + 1] = if_table else - stdnse.print_debug("Interface not supported or not properly configured.") + stdnse.debug1("Interface not supported or not properly configured.") end else for _, if_table in ipairs(nmap.list_interfaces()) do @@ -121,7 +121,7 @@ local function get_interfaces() end local function single_interface_broadcast(if_nfo, results) - stdnse.print_debug("Starting " .. SCRIPT_NAME .. " on " .. if_nfo.device) + stdnse.debug1("Starting " .. SCRIPT_NAME .. " on " .. if_nfo.device) local condvar = nmap.condvar(results) local src_mac = if_nfo.mac diff --git a/scripts/targets-sniffer.nse b/scripts/targets-sniffer.nse index be4d0aa56..f16548f33 100644 --- a/scripts/targets-sniffer.nse +++ b/scripts/targets-sniffer.nse @@ -85,17 +85,17 @@ action = function() interface_info = nmap.get_interface_info(interface) if interface_info==nil then -- Check if we have the interface information - stdnse.print_debug(1,"Error: Unable to get interface info. Did you specify the correct interface using 'targets-sniffer.iface=' or '-e '?") + stdnse.debug1("Error: Unable to get interface info. Did you specify the correct interface using 'targets-sniffer.iface=' or '-e '?") return end if sock==nil then - stdnse.print_debug(1,"Error - unable to open socket using interface %s",interface) + stdnse.debug1("Error - unable to open socket using interface %s",interface) return else sock:pcap_open(interface, 104, true, "ip or ip6") - stdnse.print_debug(1, "Will sniff for %s seconds on interface %s.", (timeout/1000),interface) + stdnse.debug1("Will sniff for %s seconds on interface %s.", (timeout/1000),interface) repeat @@ -108,7 +108,7 @@ action = function() packet_counter=packet_counter+1 addresses = get_ip_addresses(layer3) - stdnse.print_debug(1, "Got IP addresses %s", stdnse.strjoin(" ", addresses)) + stdnse.debug1("Got IP addresses %s", stdnse.strjoin(" ", addresses)) for _, addr in ipairs(addresses) do if check_if_valid(addr) == true then @@ -143,11 +143,11 @@ action = function() end end else - stdnse.print_debug(1,"Not adding targets to newtargets. If you want to do that use the 'newtargets' script argument.") + stdnse.debug1("Not adding targets to newtargets. If you want to do that use the 'newtargets' script argument.") end if #all_addresses>0 then - stdnse.print_debug(1,"Added %s address(es) to newtargets", #all_addresses) + stdnse.debug1("Added %s address(es) to newtargets", #all_addresses) end return string.format("Sniffed %s address(es). \n", #all_addresses) .. stdnse.strjoin("\n",all_addresses) diff --git a/scripts/targets-traceroute.nse b/scripts/targets-traceroute.nse index e73641fab..db134a806 100644 --- a/scripts/targets-traceroute.nse +++ b/scripts/targets-traceroute.nse @@ -56,7 +56,7 @@ action = function(host) stdnse.print_debug(3, "TRACEROUTE Scan Hops: Added new target "..host.ip.." from traceroute results") else - stdnse.print_debug(3, "TRACEROUTE Scan Hops: " .. ret) + stdnse.debug3("TRACEROUTE Scan Hops: " .. ret) end end end diff --git a/scripts/tftp-enum.nse b/scripts/tftp-enum.nse index 4d5c9c984..ef483e350 100644 --- a/scripts/tftp-enum.nse +++ b/scripts/tftp-enum.nse @@ -83,7 +83,7 @@ local generate_filenames = function(host) local customlist = stdnse.get_script_args('tftp-enum.filelist') local status, default_filenames = datafiles.parse_file(customlist or "nselib/data/tftplist.txt" , {}) if not status then - stdnse.print_debug(1, "Can not open file with tftp file names list") + stdnse.debug1("Can not open file with tftp file names list") return {} end @@ -98,7 +98,7 @@ local create_tftp_file_request = function(filename) end local check_file_present = function(host, port, filename) - stdnse.print_debug(1, "checking file %s", filename) + stdnse.debug1("checking file %s", filename) local file_request = create_tftp_file_request(filename) @@ -109,14 +109,14 @@ local check_file_present = function(host, port, filename) if (not (status)) then - stdnse.print_debug(1, "error %s", lhost) + stdnse.debug1("error %s", lhost) socket:close() return REQUEST_ERROR end local bind_socket = nmap.new_socket("udp") - stdnse.print_debug(1, "local port = %d", lport) + stdnse.debug1("local port = %d", lport) socket:send(file_request) socket:close() @@ -124,10 +124,10 @@ local check_file_present = function(host, port, filename) local bindOK, error = bind_socket:bind(nil, lport) - stdnse.print_debug(1, "starting listener") + stdnse.debug1("starting listener") if (not (bindOK)) then - stdnse.print_debug(1, "Error in bind %s", error) + stdnse.debug1("Error in bind %s", error) bind_socket:close() return REQUEST_ERROR end @@ -136,7 +136,7 @@ local check_file_present = function(host, port, filename) local recvOK, data = bind_socket:receive() if (not (recvOK)) then - stdnse.print_debug(1, "Error in receive %s", data) + stdnse.debug1("Error in receive %s", data) bind_socket:close() return REQUEST_ERROR end @@ -199,11 +199,11 @@ end action = function(host, port) if (not (check_open_tftp(host, port))) then - stdnse.print_debug(1, "tftp seems not active") + stdnse.debug1("tftp seems not active") return end - stdnse.print_debug(1, "tftp detected") + stdnse.debug1("tftp detected") nmap.set_port_state(host, port, "open") diff --git a/scripts/tls-nextprotoneg.nse b/scripts/tls-nextprotoneg.nse index a6237a9f5..bb6a28e98 100644 --- a/scripts/tls-nextprotoneg.nse +++ b/scripts/tls-nextprotoneg.nse @@ -73,14 +73,14 @@ local client_hello = function(host, port) 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 end -- Send Client Hello to the target server status, err = sock:send(cli_h) if not status then - stdnse.print_debug("Couldn't send: %s", err) + stdnse.debug1("Couldn't send: %s", err) sock:close() return false end @@ -88,7 +88,7 @@ local client_hello = function(host, port) -- Read response status, response, err = tls.record_buffer(sock) if not status then - stdnse.print_debug("Couldn't receive: %s", err) + stdnse.debug1("Couldn't receive: %s", err) sock:close() return false end diff --git a/scripts/ventrilo-info.nse b/scripts/ventrilo-info.nse index e73f2c438..0b863498c 100644 --- a/scripts/ventrilo-info.nse +++ b/scripts/ventrilo-info.nse @@ -582,7 +582,7 @@ action = function(host, port) -- check for an invalid response if #response < 20 or pck >= totpck or len > 492 or curlen > totlen then - stdnse.print_debug("Invalid response. Aborting script.") + stdnse.debug1("Invalid response. Aborting script.") cleanup() return end @@ -615,7 +615,7 @@ action = function(host, port) -- receive another packet status, response = socket:receive() if not status then - stdnse.print_debug("Response packets stopped coming midway. Aborting script.") + stdnse.debug1("Response packets stopped coming midway. Aborting script.") cleanup() return end @@ -629,7 +629,7 @@ action = function(host, port) -- check for an invalid checksum on the response data sections (no headers) local fulldata_crc_sum = crc(fulldata_str) if fulldata_crc_sum ~= head_crc_sum then - stdnse.print_debug("Invalid CRC sum, received = %04X, calculated = %04X", head_crc_sum, fulldata_crc_sum) + stdnse.debug1("Invalid CRC sum, received = %04X, calculated = %04X", head_crc_sum, fulldata_crc_sum) cleanup() return end diff --git a/scripts/wdb-version.nse b/scripts/wdb-version.nse index 828a8b667..1e386344a 100644 --- a/scripts/wdb-version.nse +++ b/scripts/wdb-version.nse @@ -106,7 +106,7 @@ local function decode_reply(data, pos) pos, wdberr = rpc.Util.unmarshall_uint32(data, pos) info["error"] = bit.band(wdberr, 0xc0000000) if (info["error"] ~= 0x00000000 ) then - stdnse.print_debug(1,"Error from decode_reply: %x", info["error"]) + stdnse.debug1("Error from decode_reply: %x", info["error"]) return nil, info end pos, len = rpc.Util.unmarshall_uint32(data, pos) diff --git a/scripts/whois-domain.nse b/scripts/whois-domain.nse index 807791de6..bf884bdbd 100644 --- a/scripts/whois-domain.nse +++ b/scripts/whois-domain.nse @@ -127,7 +127,7 @@ action = function( host ) result = {} local socket = nmap.new_socket() local catch = function() - stdnse.print_debug( "fail") + stdnse.debug1( "fail") socket:close() end diff --git a/scripts/whois-ip.nse b/scripts/whois-ip.nse index 4dedfb56e..9509c20fc 100644 --- a/scripts/whois-ip.nse +++ b/scripts/whois-ip.nse @@ -1029,11 +1029,11 @@ function constrain_response( response, db, ip, meta ) local dbg = "%s %s %s smallest range is offset from %s to %s." -- isolate inetnum and associated objects if bound then - stdnse.print_debug(5, dbg, SCRIPT_NAME, ip, db, ptr, bound) + stdnse.debug5(dbg, SCRIPT_NAME, ip, db, ptr, bound) -- get from pointer to bound return response:sub(ptr,bound), ptr else - stdnse.print_debug(5, dbg, SCRIPT_NAME, ip, db, ptr, "the end") + stdnse.debug5(dbg, SCRIPT_NAME, ip, db, ptr, "the end") -- or get the whole thing from the pointer onwards return response:sub(ptr), ptr end diff --git a/scripts/xmpp-info.nse b/scripts/xmpp-info.nse index bdb7f6a6a..859f520f5 100644 --- a/scripts/xmpp-info.nse +++ b/scripts/xmpp-info.nse @@ -89,7 +89,7 @@ local known_features = { } local check_citadel = function(id1, id2) - stdnse.print_debug("CHECK") + stdnse.debug1("CHECK") local i1 = tonumber(id1, 16) local i2 = tonumber(id2, 16) return i2 - i1 < 20 and i2 > i1 @@ -255,14 +255,14 @@ local scan = function(host, port, server_name, tls) local t_xmpp = stdnse.output_table() local xmlns - stdnse.print_debug(port.version.name) + stdnse.debug1(port.version.name) if port.version.name == 'xmpp-client' then xmlns = "'jabber:client'" else xmlns = "'jabber:server'" end if tls then tls_text = ", tls" else tls_text = "" end - stdnse.print_debug("name '" .. server_name .. "', ns '" .. xmlns .. "'" .. tls_text) + stdnse.debug1("name '" .. server_name .. "', ns '" .. xmlns .. "'" .. tls_text) status, data = client:connect(host, port) if not status then @@ -306,7 +306,7 @@ local scan = function(host, port, server_name, tls) end if inside() and not known_features[tag.name] then - stdnse.print_debug(tag.name) + stdnse.debug1(tag.name) table.insert(unknown, tag.name) end @@ -335,7 +335,7 @@ local scan = function(host, port, server_name, tls) end if tag.name == "sm" and tag.start and inside() then - stdnse.print_debug("OK") + stdnse.debug1("OK") --http://xmpp.org/extensions/xep-0198.html --sample: el-tramo.be local version = string.match(tag.attrs.xmlns, "^urn:xmpp:sm:(%.)") @@ -460,9 +460,9 @@ local server_info = function(host, port, id1, id2) if ((not id1 and not v.regexp1) or (id1 and v.regexp1 and string.find(id1, v.regexp1))) and ((not id2 and not v.regexp2) or (id2 and v.regexp2 and string.find(id2, v.regexp2))) then if not v.check or v.check(id1, id2) then - stdnse.print_debug("MATCHED") + stdnse.debug1("MATCHED") port.version.product = v.name - stdnse.print_debug(" " .. v.name) + stdnse.debug1(" " .. v.name) port.version.name_confidence = 6 nmap.set_port_version(host, port) break