OXIESEC PANEL
- Current Dir:
/
/
usr
/
share
/
nmap
/
nselib
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2020 12:36:00 PM
rwxr-xr-x
📄
afp.lua
71.92 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ajp.lua
16.69 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
amqp.lua
10.5 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
anyconnect.lua
4.45 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
asn1.lua
14.57 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
base32.lua
7.33 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
base64.lua
5.67 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bin.lua
12.89 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bit.lua
2.43 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bitcoin.lua
16.99 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bits.lua
1.82 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bittorrent.lua
40.77 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bjnp.lua
9.45 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
brute.lua
50.04 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
cassandra.lua
5.78 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
citrixxml.lua
16 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
coap.lua
76.24 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
comm.lua
10.75 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
creds.lua
18.22 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
cvs.lua
3.13 KB
04/16/2018 01:11:39 AM
rw-r--r--
📁
data
-
08/07/2020 12:36:00 PM
rwxr-xr-x
📄
datafiles.lua
11.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
datetime.lua
1.16 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dhcp.lua
29.17 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dhcp6.lua
19.87 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dns.lua
51.44 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dnsbl.lua
19.02 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dnssd.lua
12.57 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
drda.lua
24.2 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
eap.lua
7.64 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
eigrp.lua
14.47 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
formulas.lua
5.35 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ftp.lua
9.03 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
geoip.lua
1.71 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
giop.lua
18.44 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
gps.lua
3.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
http.lua
105.81 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
httpspider.lua
36.15 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
iax2.lua
9.6 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ike.lua
15.02 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
imap.lua
9.59 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
informix.lua
39.76 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ipOps.lua
26.92 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ipmi.lua
10.02 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ipp.lua
12.54 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
irc.lua
757 bytes
04/16/2018 01:11:39 AM
rw-r--r--
📄
iscsi.lua
21.45 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
isns.lua
15.34 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
jdwp.lua
43.57 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
json.lua
11.65 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ldap.lua
31.86 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
lfs.luadoc
1.68 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
libssh2-utility.lua
4.39 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
libssh2.luadoc
4.75 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
listop.lua
4.66 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
lpeg-utility.lua
5.64 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
lpeg.luadoc
351 bytes
04/16/2018 01:11:39 AM
rw-r--r--
📄
ls.lua
10.96 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
match.lua
2.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
membase.lua
9.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mobileme.lua
8.46 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mongodb.lua
21.29 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mqtt.lua
28.95 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
msrpc.lua
179.93 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
msrpcperformance.lua
29.72 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
msrpctypes.lua
167.61 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mssql.lua
110.87 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
multicast.lua
6.1 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mysql.lua
17.09 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
natpmp.lua
5.04 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ncp.lua
36 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ndmp.lua
11.58 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
netbios.lua
13.9 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
nmap.luadoc
40.34 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
nrpc.lua
4.42 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
nsedebug.lua
3.49 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
omp2.lua
4.77 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
openssl.luadoc
7.08 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ospf.lua
15.29 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
packet.lua
36.65 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pcre.luadoc
6.79 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pgsql.lua
20.61 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pop3.lua
5.7 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pppoe.lua
29.95 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
proxy.lua
12.04 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rdp.lua
11.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
re.lua
8.22 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
redis.lua
3.59 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rmi.lua
47.89 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rpc.lua
106.22 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rpcap.lua
11.19 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rsync.lua
5.19 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rtsp.lua
8.67 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sasl.lua
16.38 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
shortport.lua
8.01 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sip.lua
30.56 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
slaxml.lua
17.9 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smb.lua
175.85 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smb2.lua
16.32 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smbauth.lua
37.53 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smtp.lua
19.81 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
snmp.lua
15.99 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
socks.lua
8.26 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
srvloc.lua
12.25 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ssh1.lua
8.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ssh2.lua
11.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sslcert.lua
33.34 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sslv2.lua
9.63 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
stdnse.lua
45.93 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
strbuf.lua
4.52 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
strict.lua
2.53 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
stun.lua
11.51 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tab.lua
3.35 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
target.lua
3.93 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tftp.lua
9.38 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tls.lua
56.16 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tn3270.lua
43.75 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tns.lua
64.17 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
unicode.lua
14.32 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
unittest.lua
12.33 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
unpwdb.lua
10.08 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
upnp.lua
11.18 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
url.lua
12.09 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
versant.lua
8.6 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
vnc.lua
23.3 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
vulns.lua
76.29 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
vuzedht.lua
16.62 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
wsdd.lua
12.03 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
xdmcp.lua
11.9 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
xmpp.lua
15.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
Editing: datafiles.lua
Close
--- -- Read and parse some of Nmap's data files: <code>nmap-protocols</code>, -- <code>nmap-rpc</code>, <code>nmap-services</code>, and -- <code>nmap-mac-prefixes</code>. -- -- The functions in this module return values appropriate for use with exception -- handling via <code>nmap.new_try</code>. On success, they return true and -- the function result. On failure, they return false and an error message. -- @author Kris Katterjohn 03/2008 -- @author jah 08/2008 -- @copyright Same as Nmap--See https://nmap.org/book/man-legal.html local io = require "io" local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" local table = require "table" _ENV = stdnse.module("datafiles", stdnse.seeall) --- -- Capture patterns for common data files, indexed by filename. -- @class table -- @name common_files -- @see parse_file local common_files = { ["nmap-rpc"] = { [function(ln) return tonumber( ln:match( "^%s*[^%s#]+%s+(%d+)" ) ) end] = "^%s*([^%s#]+)%s+%d+" }, ["nmap-protocols"] = { [function(ln) return tonumber( ln:match( "^%s*[^%s#]+%s+(%d+)" ) ) end] = "^%s*([^%s#]+)%s+%d+" }, ["nmap-services"] = { ["tcp"] = { [function(ln) return tonumber( ln:match( "^%s*[^%s#]+%s+(%d+)/tcp" ) ) end] = "^%s*([^%s#]+)%s+%d+/tcp" }, ["udp"] = { [function(ln) return tonumber( ln:match( "^%s*[^%s#]+%s+(%d+)/udp" ) ) end] = "^%s*([^%s#]+)%s+%d+/udp" } }, ["nmap-mac-prefixes"] = { [ "^%s*(%w+)%s+[^#]+" ] = "^%s*%w+%s+([^#]+)" } } -- Helper for parse_* functions local parse_and_cache = function(filename) nmap.registry.datafiles = nmap.registry.datafiles or {} if not nmap.registry.datafiles[filename] then local status status, nmap.registry.datafiles[filename] = parse_file(filename) if not status then return false, string.format("Error parsing %s", filename) end end return true, nmap.registry.datafiles[filename] end --- -- Read and parse <code>nmap-protocols</code>. -- -- On success, return true and a table mapping protocol numbers to protocol -- names. -- @return Status (true or false). -- @return Table (if status is true) or error string (if status is false). -- @see parse_file parse_protocols = function() return parse_and_cache("nmap-protocols") end --- -- Read and parse <code>nmap-rpc</code>. -- -- On success, return true and a table mapping RPC numbers to RPC names. -- @return Status (true or false). -- @return Table (if status is true) or error string (if status is false). -- @see parse_file parse_rpc = function() return parse_and_cache("nmap-rpc") end --- -- Read and parse <code>nmap-services</code>. -- -- On success, return true and a table containing two subtables, indexed by the -- keys "tcp" and "udp". The <code>tcp</code> subtable maps TCP port numbers to -- service names, and the <code>udp</code> subtable is the same for UDP. You can -- pass "tcp" or "udp" as an argument to <code>parse_services</code> to get -- only one of the results tables. -- @param protocol The protocol table to return (<code>"tcp"</code> or -- <code>"udp"</code>). -- @return Status (true or false). -- @return Table (if status is true) or error string (if status is false). -- @see parse_file parse_services = function(protocol) if protocol and protocol ~= "tcp" and protocol ~= "udp" then return false, "Bad protocol for nmap-services: use tcp or udp" end local services_table nmap.registry.datafiles = nmap.registry.datafiles or {} nmap.registry.datafiles.services = nmap.registry.datafiles.services or {} if protocol then if not nmap.registry.datafiles.services[protocol] then local status status, nmap.registry.datafiles.services[protocol] = parse_file("nmap-services", protocol) if not status then return false, "Error parsing nmap-services" end end services_table = nmap.registry.datafiles.services[protocol] else local status status, nmap.registry.datafiles.services = parse_file("nmap-services") if not status then return false, "Error parsing nmap-services" end services_table = nmap.registry.datafiles.services end return true, services_table end --- -- Read and parse <code>nmap-mac-prefixes</code>. -- -- On success, return true and a table mapping 3 byte MAC prefixes to manufacturer names. -- @return Status (true or false). -- @return Table (if status is true) or error string (if status is false). -- @see parse_file parse_mac_prefixes = function() return parse_and_cache("nmap-mac-prefixes") end --- -- Read and parse a generic data file. The other parse functions are -- defined in terms of this one. -- -- If filename is a key in <code>common_files</code>, use the corresponding -- capture pattern. Otherwise the second argument must be a table of the kind -- taken by <code>parse_lines</code>. -- @param filename Name of the file to parse. -- @param ... A table of capture patterns. -- @return Boolean status, false on failure -- @return A table whose structure mirrors that of the capture table, -- filled in with captured values. function parse_file(filename, ...) local data_struct -- must have a filename if type( filename ) ~= "string" or filename == "" then return false, "Error in datafiles.parse_file: No file to parse." end -- is filename a member of common_files? is second parameter a key in common_files or is it a table? if common_files[filename] and type( (...) ) == "string" and common_files[filename][(...)] then data_struct = { common_files[filename][(...)] } elseif common_files[filename] and select("#", ...) == 0 then data_struct = { common_files[filename] } elseif type( (...) ) == "table" then data_struct = {...} elseif type( (...) ) ~= "table" then return false, "Error in datafiles.parse_file: Expected second parameter as table." end if type( data_struct ) == "table" then for i, struc in ipairs( data_struct ) do -- check that all varargs are tables if type( struc ) ~= "table" then return false, "Error in datafiles.parse_file: Bad Parameter." end -- allow empty table as sugar for ^(.+)$ capture the whole line if not next( struc ) and #struc == 0 then data_struct[i] = { "^(.+)$" } end end if #data_struct == 0 then return false, "Error in datafiles.parse_file: I've no idea how you want your data." end end -- get a table of lines local status, lines = read_from_file( filename ) if not status then return false, ( "Error in datafiles.parse_file: %s could not be read: %s." ):format( filename, lines ) end -- do the actual parsing local ret = {} for _, ds in ipairs( data_struct ) do status, ret[#ret+1] = parse_lines( lines, ds ) -- hmmm should we fail all if there are any failures? yes? ok if not status then return false, ret[#ret] end end return true, table.unpack( ret ) end --- -- Generic parsing of an array of strings. -- @param lines An array of strings to operate on. -- @param data_struct A table containing capture patterns to be applied -- to each string in the array. A capture will be applied to each string -- using <code>string.match</code> and may also be enclosed within a table or -- a function. If a function, it must accept a string as its parameter and -- should return one value derived from that string. -- @return A table whose structure mirrors that of the capture table, -- filled in with captured values. function parse_lines(lines, data_struct) if type( lines ) ~= "table" or #lines < 1 then return false, "Error in datafiles.parse_lines: No lines to parse." end if type( data_struct ) ~= "table" or not next( data_struct ) then return false, "Error in datafiles.parse_lines: Expected second parameter as a non-empty table." end local ret = {} -- traverse data_struct and enforce sensible index-value pairs. Call functions to process the members of lines. for index, value in pairs( data_struct ) do if type(index) == nil then return false, "Error in datafiles.parse_lines: Invalid index." end if type(index) == "number" or type(value) == "table" then if type(value) == "number" then return false, "Error in datafiles.parse_lines: No patterns for data capture." elseif type(value) == "string" or type(value) == "function" then ret = get_array( lines, value ) elseif type(value) == "table" then local _ _, ret[index] = parse_lines( lines, value ) else -- TEMP stdnse.debug1("Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value)) end elseif type(index) == "string" or type(index) == "function" then if type( value ) == "string" or type( value ) == "function" then ret = get_assoc_array( lines, index, value ) else return false, ( "Error in datafiles.parse_lines: Invalid value for index %s." ):format( index ) end else -- TEMP stdnse.debug1("Error in datafiles.parse_lines: Index with type %s has unexpected value %s", type(index), type(value)) end end return true, ret end --- -- Read a file, line by line, into a table. -- @param file String with the name of the file to read. -- @return Status (true or false). -- @return Array of lines read from the file (if status is true) or error -- message (if status is false). function read_from_file( file ) -- get path to file local filepath = nmap.fetchfile( file ) if not filepath then return false, ( "Error in nmap.fetchfile: Could not find file %s." ):format( file ) end local f, err, _ = io.open( filepath, "r" ) if not f then return false, ( "Error in datafiles.read_from_file: Cannot open %s for reading: %s" ):format( filepath, err ) end local ret = {} for line in f:lines() do ret[#ret+1] = line end f:close() return true, ret end --- -- Return an array-like table of values captured from each line. -- @param lines Table of strings containing the lines to process. -- @param v_pattern Pattern to use on the lines to produce the value for the -- array. get_array = function(lines, v_pattern) local ret = {} for _, line in ipairs( lines ) do assert( type( line ) == "string" ) local captured if type( v_pattern ) == "function" then captured = v_pattern( line ) else captured = line:match( v_pattern ) end table.insert( ret, captured ) end return ret end --- -- Return a table of index-value pairs captured from each line. -- @param lines Table of strings containing the lines to process. -- @param i_pattern Pattern to use on the lines to produce the key for the -- associative array. -- @param v_pattern Pattern to use on the lines to produce the value for the -- associative array. get_assoc_array = function(lines, i_pattern, v_pattern) local ret = {} for _, line in ipairs(lines) do assert( type( line ) == "string" ) local index if type(i_pattern) == "function" then index = i_pattern(line) else index = line:match(i_pattern) end if index and type(v_pattern) == "function" then local m = v_pattern(line) if m then ret[index] = m end elseif index then local m = line:match(v_pattern) if m then ret[index] = m end end end return ret end return _ENV;