PATH:
usr
/
share
/
nmap
/
nselib
--- -- Debugging functions for Nmap scripts. -- -- This module contains various handy functions for debugging. These should -- never be used for actual results, only during testing. -- -- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html local coroutine = require "coroutine" local debug = require "debug" local io = require "io" local math = require "math" local stdnse = require "stdnse" local string = require "string" _ENV = stdnse.module("nsedebug", stdnse.seeall) local EMPTY = {}; -- Empty constant table --- -- Converts an arbitrary data type into a string. Will recursively convert -- tables. This can be very useful for debugging. -- --@param data The data to convert. --@param indent (optional) The number of times to indent the line. Default -- is 0. --@return A string representation of a data, will be one or more full lines. function tostr(data, indent) local str = "" if(indent == nil) then indent = 0 end -- Check the type if(type(data) == "nil") then str = str .. (" "):rep(indent) .. "nil\n" elseif(type(data) == "string") then str = str .. (" "):rep(indent) .. string.format("%q", data) .. "\n" elseif(type(data) == "number") then str = str .. (" "):rep(indent) .. data .. "\n" elseif(type(data) == "boolean") then if(data == true) then str = str .. "true\n" else str = str .. "false\n" end elseif(type(data) == "table") then local i, v for i, v in pairs(data) do -- Check for a table in a table if(type(v) == "table") then str = str .. (" "):rep(indent) .. tostring(i) .. ":\n" str = str .. tostr(v, indent + 2) else str = str .. (" "):rep(indent) .. tostring(i) .. ": " .. tostr(v, 0) end end else stdnse.print_debug(1, "Error: unknown data type: %s", type(data)) end return str end --- Print out a string in hex, for debugging. -- --@param str The data to print in hex. function print_hex(str) -- Prints out the full lines for line=1, #str/16, 1 do io.write(string.format("%08x ", (line - 1) * 16)) -- Loop through the string, printing the hex for char=1, 16, 1 do local ch = string.byte(str, ((line - 1) * 16) + char) io.write(string.format("%02x ", ch)) end io.write(" ") -- Loop through the string again, this time the ascii for char=1, 16, 1 do local ch = string.byte(str, ((line - 1) * 16) + char) if ch < 0x20 or ch > 0x7f then ch = string.byte(".", 1) end io.write(string.format("%c", ch)) end io.write("\n") end -- Prints out the final, partial line if (#str % 16 ~= 0) then local line = math.floor((#str/16)) + 1 io.write(string.format("%08x ", (line - 1) * 16)) for char=1, #str % 16, 1 do local ch = string.byte(str, ((line - 1) * 16) + char) io.write(string.format("%02x ", ch)) end io.write(string.rep(" ", 16 - (#str % 16))); io.write(" ") for char=1, #str % 16, 1 do local ch = string.byte(str, ((line - 1) * 16) + char) if ch < 0x20 or ch > 0x7f then ch = string.byte(".", 1) end io.write(string.format("%c", ch)) end io.write("\n") end -- Print out the length io.write(string.format(" Length: %d [0x%x]\n", #str, #str)) end ---Print out a stacktrace. The stacktrace will naturally include this function call. function print_stack() local thread = coroutine.running() local trace = debug.traceback(thread); if trace ~= "stack traceback:" then print(thread, "\n", trace, "\n"); end end return _ENV;
[-] iscsi.lua
[edit]
[-] httpspider.lua
[edit]
[-] rmi.lua
[edit]
[-] socks.lua
[edit]
[-] dhcp6.lua
[edit]
[-] sasl.lua
[edit]
[-] drda.lua
[edit]
[+]
data
[-] dhcp.lua
[edit]
[-] omp2.lua
[edit]
[-] ospf.lua
[edit]
[-] ipp.lua
[edit]
[-] pop3.lua
[edit]
[-] netbios.lua
[edit]
[-] pgsql.lua
[edit]
[-] packet.lua
[edit]
[-] rpc.lua
[edit]
[-] xdmcp.lua
[edit]
[-] msrpc.lua
[edit]
[+]
..
[-] eigrp.lua
[edit]
[-] giop.lua
[edit]
[-] afp.lua
[edit]
[-] bjnp.lua
[edit]
[-] match.lua
[edit]
[-] iax2.lua
[edit]
[-] smtp.lua
[edit]
[-] msrpctypes.lua
[edit]
[-] cvs.lua
[edit]
[-] natpmp.lua
[edit]
[-] bitcoin.lua
[edit]
[-] snmp.lua
[edit]
[-] rsync.lua
[edit]
[-] mssql.lua
[edit]
[-] base64.lua
[edit]
[-] ncp.lua
[edit]
[-] base32.lua
[edit]
[-] sip.lua
[edit]
[-] http.lua
[edit]
[-] asn1.lua
[edit]
[-] stun.lua
[edit]
[-] citrixxml.lua
[edit]
[-] nrpc.lua
[edit]
[-] proxy.lua
[edit]
[-] pppoe.lua
[edit]
[-] amqp.lua
[edit]
[-] dns.lua
[edit]
[-] informix.lua
[edit]
[-] tftp.lua
[edit]
[-] sslcert.lua
[edit]
[-] strbuf.lua
[edit]
[-] unpwdb.lua
[edit]
[-] strict.lua
[edit]
[-] vulns.lua
[edit]
[-] jdwp.lua
[edit]
[-] stdnse.lua
[edit]
[-] dnssd.lua
[edit]
[-] mysql.lua
[edit]
[-] rdp.lua
[edit]
[-] mongodb.lua
[edit]
[-] ndmp.lua
[edit]
[-] isns.lua
[edit]
[-] ldap.lua
[edit]
[-] creds.lua
[edit]
[-] tab.lua
[edit]
[-] ftp.lua
[edit]
[-] brute.lua
[edit]
[-] comm.lua
[edit]
[-] ipOps.lua
[edit]
[-] mobileme.lua
[edit]
[-] target.lua
[edit]
[-] rpcap.lua
[edit]
[-] eap.lua
[edit]
[-] cassandra.lua
[edit]
[-] ssh1.lua
[edit]
[-] url.lua
[edit]
[-] datafiles.lua
[edit]
[-] ajp.lua
[edit]
[-] vuzedht.lua
[edit]
[-] nsedebug.lua
[edit]
[-] rtsp.lua
[edit]
[-] shortport.lua
[edit]
[-] bittorrent.lua
[edit]
[-] ssh2.lua
[edit]
[-] msrpcperformance.lua
[edit]
[-] listop.lua
[edit]
[-] dnsbl.lua
[edit]
[-] json.lua
[edit]
[-] redis.lua
[edit]
[-] wsdd.lua
[edit]
[-] tns.lua
[edit]
[-] ike.lua
[edit]
[-] gps.lua
[edit]
[-] versant.lua
[edit]
[-] imap.lua
[edit]
[-] smb.lua
[edit]
[-] smbauth.lua
[edit]
[-] xmpp.lua
[edit]
[-] upnp.lua
[edit]
[-] membase.lua
[edit]
[-] vnc.lua
[edit]
[-] srvloc.lua
[edit]