mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Move string utility functions to stringaux.lua
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
#Nmap Changelog ($Id$); -*-text-*-
|
#Nmap Changelog ($Id$); -*-text-*-
|
||||||
|
|
||||||
|
o [NSE] Collected utility functions for string processing into a new library,
|
||||||
|
stringaux.lua. [Daniel Miller]
|
||||||
|
|
||||||
o [NSE][GH#1359] Fix a false-positive in http-phpmyadmin-dir-traversal when the
|
o [NSE][GH#1359] Fix a false-positive in http-phpmyadmin-dir-traversal when the
|
||||||
server responds with 200 status to a POST request to any URI. [Francesco Soncina]
|
server responds with 200 status to a POST request to any URI. [Francesco Soncina]
|
||||||
|
|
||||||
|
|||||||
@@ -2357,7 +2357,7 @@ output.users[#output.users + 1] = "root"
|
|||||||
output.users[#output.users + 1] = "foo"
|
output.users[#output.users + 1] = "foo"
|
||||||
output.users[#output.users + 1] = "bar"
|
output.users[#output.users + 1] = "bar"
|
||||||
local output_str = string.format("hostname: %s\n", output.hostname)
|
local output_str = string.format("hostname: %s\n", output.hostname)
|
||||||
output_str = output_str .. "\n" .. stdnse.strjoin(", ", output.users)
|
output_str = output_str .. "\n" .. stringaux.strjoin(", ", output.users)
|
||||||
return output, output_str
|
return output, output_str
|
||||||
</programlisting>
|
</programlisting>
|
||||||
then the normal output would appear as follows:
|
then the normal output would appear as follows:
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ local nmap = require "nmap"
|
|||||||
local os = require "os"
|
local os = require "os"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
_ENV = stdnse.module("afp", stdnse.seeall);
|
_ENV = stdnse.module("afp", stdnse.seeall);
|
||||||
|
|
||||||
@@ -1404,7 +1405,7 @@ Helper = {
|
|||||||
-- @return item table containing node information <code>DirectoryId</code> and <code>DirectoryName</code>
|
-- @return item table containing node information <code>DirectoryId</code> and <code>DirectoryName</code>
|
||||||
WalkDirTree = function( self, str_path )
|
WalkDirTree = function( self, str_path )
|
||||||
local status, response, path
|
local status, response, path
|
||||||
local elements = stdnse.strsplit( "/", str_path )
|
local elements = stringaux.strsplit( "/", str_path )
|
||||||
local f_bm = FILE_BITMAP.NodeId + FILE_BITMAP.ParentDirId + FILE_BITMAP.LongName
|
local f_bm = FILE_BITMAP.NodeId + FILE_BITMAP.ParentDirId + FILE_BITMAP.LongName
|
||||||
local d_bm = DIR_BITMAP.NodeId + DIR_BITMAP.ParentDirId + DIR_BITMAP.LongName
|
local d_bm = DIR_BITMAP.NodeId + DIR_BITMAP.ParentDirId + DIR_BITMAP.LongName
|
||||||
local item = { DirectoryId = 2 }
|
local item = { DirectoryId = 2 }
|
||||||
@@ -1822,7 +1823,7 @@ Util =
|
|||||||
-- @param str_path string containing the path to split
|
-- @param str_path string containing the path to split
|
||||||
-- @return dir table containing <code>dir</code> and <code>file</code>
|
-- @return dir table containing <code>dir</code> and <code>file</code>
|
||||||
SplitPath = function( str_path )
|
SplitPath = function( str_path )
|
||||||
local elements = stdnse.strsplit("/", str_path)
|
local elements = stringaux.strsplit("/", str_path)
|
||||||
local dir, file = "", ""
|
local dir, file = "", ""
|
||||||
|
|
||||||
if #elements < 2 then
|
if #elements < 2 then
|
||||||
@@ -1832,7 +1833,7 @@ Util =
|
|||||||
file = elements[#elements]
|
file = elements[#elements]
|
||||||
|
|
||||||
table.remove( elements, #elements )
|
table.remove( elements, #elements )
|
||||||
dir = stdnse.strjoin( "/", elements )
|
dir = table.concat( elements, "/" )
|
||||||
|
|
||||||
return { ['dir']=dir, ['file']=file }
|
return { ['dir']=dir, ['file']=file }
|
||||||
|
|
||||||
@@ -1888,13 +1889,13 @@ Util =
|
|||||||
|
|
||||||
local acls_tbl = {}
|
local acls_tbl = {}
|
||||||
|
|
||||||
table.insert( acls_tbl, string.format( "Owner: %s", stdnse.strjoin(",", owner) ) )
|
table.insert( acls_tbl, string.format( "Owner: %s", table.concat(owner, ",") ) )
|
||||||
table.insert( acls_tbl, string.format( "Group: %s", stdnse.strjoin(",", group) ) )
|
table.insert( acls_tbl, string.format( "Group: %s", table.concat(group, ",") ) )
|
||||||
table.insert( acls_tbl, string.format( "Everyone: %s", stdnse.strjoin(",", everyone) ) )
|
table.insert( acls_tbl, string.format( "Everyone: %s", table.concat(everyone, ",") ) )
|
||||||
table.insert( acls_tbl, string.format( "User: %s", stdnse.strjoin(",", user) ) )
|
table.insert( acls_tbl, string.format( "User: %s", table.concat(user, ",") ) )
|
||||||
|
|
||||||
if #options > 0 then
|
if #options > 0 then
|
||||||
table.insert( acls_tbl, string.format( "Options: %s", stdnse.strjoin(",", options ) ) )
|
table.insert( acls_tbl, string.format( "Options: %s", table.concat(options, ",") ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
return acls_tbl
|
return acls_tbl
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ local os = require("os")
|
|||||||
local stdnse = require("stdnse")
|
local stdnse = require("stdnse")
|
||||||
local table = require("table")
|
local table = require("table")
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
|
|
||||||
_ENV = stdnse.module("bjnp", stdnse.seeall)
|
_ENV = stdnse.module("bjnp", stdnse.seeall)
|
||||||
|
|
||||||
@@ -325,7 +326,7 @@ Helper = {
|
|||||||
end
|
end
|
||||||
local attrs, kvps = {}, {}
|
local attrs, kvps = {}, {}
|
||||||
|
|
||||||
for k, v in ipairs(stdnse.strsplit(";", identity.data)) do
|
for k, v in ipairs(stringaux.strsplit(";", identity.data)) do
|
||||||
local nm, val = v:match("^([^:]*):(.*)$")
|
local nm, val = v:match("^([^:]*):(.*)$")
|
||||||
if ( nm ) then kvps[nm] = val end
|
if ( nm ) then kvps[nm] = val end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ local math = require "math"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local unittest = require "unittest"
|
local unittest = require "unittest"
|
||||||
|
|
||||||
@@ -2082,7 +2083,7 @@ Helper = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
assert(options.uri)
|
assert(options.uri)
|
||||||
local components = stdnse.strsplit("/", options.uri)
|
local components = stringaux.strsplit("/", options.uri)
|
||||||
for _, component in ipairs(components) do
|
for _, component in ipairs(components) do
|
||||||
if component ~= "" then
|
if component ~= "" then
|
||||||
table.insert(options.options, {["name"] = "uri_path", ["value"] = component})
|
table.insert(options.options, {["name"] = "uri_path", ["value"] = component})
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ local io = require "io"
|
|||||||
local ipOps = require "ipOps"
|
local ipOps = require "ipOps"
|
||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local tableaux = require "tableaux"
|
local tableaux = require "tableaux"
|
||||||
_ENV = stdnse.module("creds", stdnse.seeall)
|
_ENV = stdnse.module("creds", stdnse.seeall)
|
||||||
@@ -413,7 +414,7 @@ Credentials = {
|
|||||||
|
|
||||||
if ( not(creds_params) ) then return end
|
if ( not(creds_params) ) then return end
|
||||||
|
|
||||||
for _, cred in ipairs(stdnse.strsplit(",", creds_params)) do
|
for _, cred in ipairs(stringaux.strsplit(",", creds_params)) do
|
||||||
-- if the credential contains a ':' we have a user + pass pair
|
-- if the credential contains a ':' we have a user + pass pair
|
||||||
-- if not, we only have a user with an empty password
|
-- if not, we only have a user with an empty password
|
||||||
local user, pass
|
local user, pass
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ Helper = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
login = function(self, repo, user, pass )
|
login = function(self, repo, user, pass )
|
||||||
local auth_tab = {}
|
|
||||||
assert(repo, "No repository was specified")
|
assert(repo, "No repository was specified")
|
||||||
assert(user, "No user was specified")
|
assert(user, "No user was specified")
|
||||||
assert(pass, "No pass was specified")
|
assert(pass, "No pass was specified")
|
||||||
@@ -39,13 +38,15 @@ Helper = {
|
|||||||
-- Add a leading slash if it's missing
|
-- Add a leading slash if it's missing
|
||||||
if ( repo:sub(1,1) ~= "/" ) then repo = "/" .. repo end
|
if ( repo:sub(1,1) ~= "/" ) then repo = "/" .. repo end
|
||||||
|
|
||||||
table.insert(auth_tab, "BEGIN AUTH REQUEST")
|
local auth_tab = {
|
||||||
table.insert(auth_tab, repo)
|
"BEGIN AUTH REQUEST",
|
||||||
table.insert(auth_tab, user)
|
repo,
|
||||||
table.insert(auth_tab, Util.pwscramble(pass))
|
user,
|
||||||
table.insert(auth_tab, "END AUTH REQUEST")
|
Util.pwscramble(pass),
|
||||||
|
"END AUTH REQUEST\n",
|
||||||
|
}
|
||||||
|
|
||||||
local data = stdnse.strjoin("\n", auth_tab) .. "\n"
|
local data = table.concat(auth_tab, "\n")
|
||||||
local status = self.socket:send(data)
|
local status = self.socket:send(data)
|
||||||
if ( not(status) ) then return false, "Failed to send login request" end
|
if ( not(status) ) then return false, "Failed to send login request" end
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ end
|
|||||||
local function createINstmt(tab)
|
local function createINstmt(tab)
|
||||||
local tab2 = {}
|
local tab2 = {}
|
||||||
for i=1, #tab do tab2[i] = ("'%s'"):format(tab[i]) end
|
for i=1, #tab do tab2[i] = ("'%s'"):format(tab[i]) end
|
||||||
return stdnse.strjoin(",", tab2)
|
return table.concat(tab2, ",")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local ipOps = require "ipOps"
|
|||||||
local packet = require "packet"
|
local packet = require "packet"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local tab = require "tab"
|
local tab = require "tab"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local target = require "target"
|
local target = require "target"
|
||||||
@@ -356,7 +357,7 @@ udp = {
|
|||||||
for _, v in ipairs(options) do
|
for _, v in ipairs(options) do
|
||||||
if ( v.name == name ) then
|
if ( v.name == name ) then
|
||||||
if ( type(v.value) == "table" ) then
|
if ( type(v.value) == "table" ) then
|
||||||
return stdnse.strjoin(", ", v.value)
|
return table.concat(v.value, ", ")
|
||||||
else
|
else
|
||||||
return v.value
|
return v.value
|
||||||
end
|
end
|
||||||
@@ -597,7 +598,7 @@ udp = {
|
|||||||
local p = packet.Packet:new( layer3, #layer3 )
|
local p = packet.Packet:new( layer3, #layer3 )
|
||||||
local data = layer3:sub(p.udp_offset + 9)
|
local data = layer3:sub(p.udp_offset + 9)
|
||||||
|
|
||||||
local headers = stdnse.strsplit("\r\n", data)
|
local headers = stringaux.strsplit("\r\n", data)
|
||||||
for _, h in ipairs(headers) do
|
for _, h in ipairs(headers) do
|
||||||
local st = ""
|
local st = ""
|
||||||
if ( h:match("^ST:.*") ) then
|
if ( h:match("^ST:.*") ) then
|
||||||
@@ -713,9 +714,9 @@ udp = {
|
|||||||
info.displayname,
|
info.displayname,
|
||||||
p.ip_src,
|
p.ip_src,
|
||||||
info.port,
|
info.port,
|
||||||
stdnse.strjoin(".", info.version),
|
table.concat(info.version, "."),
|
||||||
info.host_int,
|
info.host_int,
|
||||||
stdnse.strjoin(", ", info.namespaces)
|
table.concat(info.namespaces, ", ")
|
||||||
)
|
)
|
||||||
self.dups[p.ip_src] = true
|
self.dups[p.ip_src] = true
|
||||||
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
|
if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ DHCP6.Option = {
|
|||||||
table.insert(domain, part)
|
table.insert(domain, part)
|
||||||
end
|
end
|
||||||
until( part == "" )
|
until( part == "" )
|
||||||
table.insert(opt.domains, stdnse.strjoin(".", domain))
|
table.insert(opt.domains, table.concat(domain, "."))
|
||||||
until( pos > #data )
|
until( pos > #data )
|
||||||
return opt
|
return opt
|
||||||
end,
|
end,
|
||||||
@@ -419,7 +419,7 @@ DHCP6.Option = {
|
|||||||
tmp, pos = string.unpack("s1", data, pos)
|
tmp, pos = string.unpack("s1", data, pos)
|
||||||
table.insert(pieces, tmp)
|
table.insert(pieces, tmp)
|
||||||
until(pos >= #data)
|
until(pos >= #data)
|
||||||
opt.fqdn = stdnse.strjoin(".", pieces)
|
opt.fqdn = table.concat(pieces, ".")
|
||||||
return opt
|
return opt
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -549,11 +549,11 @@ OptionToString = {
|
|||||||
local ipv6 = ipOps.str_to_ip(srv)
|
local ipv6 = ipOps.str_to_ip(srv)
|
||||||
table.insert(servers, ipv6)
|
table.insert(servers, ipv6)
|
||||||
end
|
end
|
||||||
return "DNS Servers", stdnse.strjoin(",", servers)
|
return "DNS Servers", table.concat(servers, ",")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
[DHCP6.OptionTypes.OPTION_DOMAIN_LIST] = function(opt)
|
[DHCP6.OptionTypes.OPTION_DOMAIN_LIST] = function(opt)
|
||||||
return "Domain Search", stdnse.strjoin(", ", opt.domains)
|
return "Domain Search", table.concat(opt.domains, ", ")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
[DHCP6.OptionTypes.OPTION_STATUS_CODE] = function(opt)
|
[DHCP6.OptionTypes.OPTION_STATUS_CODE] = function(opt)
|
||||||
@@ -561,7 +561,7 @@ OptionToString = {
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
[DHCP6.OptionTypes.OPTION_SNTP_SERVERS] = function(opt)
|
[DHCP6.OptionTypes.OPTION_SNTP_SERVERS] = function(opt)
|
||||||
return "NTP Servers", stdnse.strjoin(", ", opt.servers)
|
return "NTP Servers", table.concat(opt.servers, ", ")
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ local ipOps = require "ipOps"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local base32 = require "base32"
|
local base32 = require "base32"
|
||||||
local unittest = require "unittest"
|
local unittest = require "unittest"
|
||||||
@@ -413,7 +414,7 @@ function reverse(ip)
|
|||||||
delim = ":"
|
delim = ":"
|
||||||
arpa = ".ip6.arpa"
|
arpa = ".ip6.arpa"
|
||||||
end
|
end
|
||||||
local ipParts = stdnse.strsplit(delim, ip)
|
local ipParts = stringaux.strsplit(delim, ip)
|
||||||
if #ipParts == 8 then
|
if #ipParts == 8 then
|
||||||
-- padding
|
-- padding
|
||||||
local mask = "0000"
|
local mask = "0000"
|
||||||
@@ -590,7 +591,7 @@ answerFetcher[types.NSEC] = function(dec, retAll)
|
|||||||
return false, "No Answers"
|
return false, "No Answers"
|
||||||
end
|
end
|
||||||
for _, nsecrec in ipairs(nsec) do
|
for _, nsecrec in ipairs(nsec) do
|
||||||
table.insert( answers, ("%s:%s:%s"):format(nsecrec.name or "-", nsecrec.dname or "-", stdnse.strjoin(":", nsecrec.types) or "-"))
|
table.insert( answers, ("%s:%s:%s"):format(nsecrec.name or "-", nsecrec.dname or "-", table.concat(nsecrec.types, ":") or "-"))
|
||||||
end
|
end
|
||||||
if not retAll then return true, answers[1] end
|
if not retAll then return true, answers[1] end
|
||||||
return true, answers
|
return true, answers
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ local dns = require "dns"
|
|||||||
local ipOps = require "ipOps"
|
local ipOps = require "ipOps"
|
||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
_ENV = stdnse.module("dnsbl", stdnse.seeall)
|
_ENV = stdnse.module("dnsbl", stdnse.seeall)
|
||||||
|
|
||||||
@@ -504,7 +505,7 @@ Helper = {
|
|||||||
|
|
||||||
local all = SERVICES[self.category]
|
local all = SERVICES[self.category]
|
||||||
self.filter = {}
|
self.filter = {}
|
||||||
for _, f in pairs(stdnse.strsplit(",%s*", self.filterstr)) do
|
for _, f in pairs(stringaux.strsplit(",%s*", self.filterstr)) do
|
||||||
if ( not(SERVICES[self.category][f]) ) then
|
if ( not(SERVICES[self.category][f]) ) then
|
||||||
self.filter = nil
|
self.filter = nil
|
||||||
return false, ("Service does not exist '%s'"):format(f)
|
return false, ("Service does not exist '%s'"):format(f)
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ local ipOps = require "ipOps"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local target = require "target"
|
local target = require "target"
|
||||||
_ENV = stdnse.module("dnssd", stdnse.seeall)
|
_ENV = stdnse.module("dnssd", stdnse.seeall)
|
||||||
@@ -235,7 +236,7 @@ Comm = {
|
|||||||
|
|
||||||
status, srv = Comm.getRecordType( dns.types.SRV, response, false )
|
status, srv = Comm.getRecordType( dns.types.SRV, response, false )
|
||||||
if status then
|
if status then
|
||||||
local srvparams = stdnse.strsplit( ":", srv )
|
local srvparams = stringaux.strsplit( ":", srv )
|
||||||
|
|
||||||
if #srvparams > 3 then
|
if #srvparams > 3 then
|
||||||
port = srvparams[3]
|
port = srvparams[3]
|
||||||
@@ -251,7 +252,7 @@ Comm = {
|
|||||||
deviceinfo = service
|
deviceinfo = service
|
||||||
table.insert(result, deviceinfo)
|
table.insert(result, deviceinfo)
|
||||||
else
|
else
|
||||||
local serviceparams = stdnse.strsplit("[.]", record)
|
local serviceparams = stringaux.strsplit("[.]", record)
|
||||||
|
|
||||||
if #serviceparams > 2 then
|
if #serviceparams > 2 then
|
||||||
local servicename = serviceparams[1]:sub(2)
|
local servicename = serviceparams[1]:sub(2)
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ local shortport = require "shortport"
|
|||||||
local slaxml = require "slaxml"
|
local slaxml = require "slaxml"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local tableaux = require "tableaux"
|
local tableaux = require "tableaux"
|
||||||
local url = require "url"
|
local url = require "url"
|
||||||
@@ -689,7 +690,7 @@ local function parse_header(header, response)
|
|||||||
local s, e
|
local s, e
|
||||||
|
|
||||||
response.header = {}
|
response.header = {}
|
||||||
response.rawheader = stdnse.strsplit("\r?\n", header)
|
response.rawheader = stringaux.strsplit("\r?\n", header)
|
||||||
pos = 1
|
pos = 1
|
||||||
while pos <= #header do
|
while pos <= #header do
|
||||||
-- Get the field name.
|
-- Get the field name.
|
||||||
@@ -867,7 +868,7 @@ local function getPipelineMax(response)
|
|||||||
|
|
||||||
if response then
|
if response then
|
||||||
local hdr = response.header or {}
|
local hdr = response.header or {}
|
||||||
local opts = stdnse.strsplit("%s+", (hdr.connection or ""):lower())
|
local opts = stringaux.strsplit("%s+", (hdr.connection or ""):lower())
|
||||||
if tableaux.contains(opts, "close") then return 1 end
|
if tableaux.contains(opts, "close") then return 1 end
|
||||||
if response.version >= "1.1" or tableaux.contains(opts, "keep-alive") then
|
if response.version >= "1.1" or tableaux.contains(opts, "keep-alive") then
|
||||||
return tonumber((hdr["keep-alive"] or ""):match("max=(%d+)")) or 40
|
return tonumber((hdr["keep-alive"] or ""):match("max=(%d+)")) or 40
|
||||||
@@ -1167,7 +1168,7 @@ local function build_request(host, port, method, path, options)
|
|||||||
header[#header + 1] = name..": "..value
|
header[#header + 1] = name..": "..value
|
||||||
end
|
end
|
||||||
|
|
||||||
return request_line .. "\r\n" .. stdnse.strjoin("\r\n", header) .. "\r\n\r\n" .. (body or "")
|
return request_line .. "\r\n" .. table.concat(header, "\r\n") .. "\r\n\r\n" .. (body or "")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- A wrapper for comm.tryssl that strictly obeys options.scheme. If it is
|
--- A wrapper for comm.tryssl that strictly obeys options.scheme. If it is
|
||||||
@@ -2034,22 +2035,11 @@ end
|
|||||||
-- @param endtag Boolean true if you are looking for an end tag, otherwise it will look for a start tag
|
-- @param endtag Boolean true if you are looking for an end tag, otherwise it will look for a start tag
|
||||||
-- @return A pattern to find the tag
|
-- @return A pattern to find the tag
|
||||||
function tag_pattern(tag, endtag)
|
function tag_pattern(tag, endtag)
|
||||||
local patt = {}
|
|
||||||
if endtag then
|
if endtag then
|
||||||
patt[1] = "</%s*"
|
return "</%s*" .. stringaux.ipattern(tag) .. "%f[%s>].->"
|
||||||
else
|
else
|
||||||
patt[1] = "<%s*"
|
return "<%s*" .. stringaux.ipattern(tag) .. "%f[%s/>].->"
|
||||||
end
|
end
|
||||||
local up, down = tag:upper(), tag:lower()
|
|
||||||
for i = 1, #tag do
|
|
||||||
patt[#patt+1] = string.format("[%s%s]", up:sub(i,i), down:sub(i,i))
|
|
||||||
end
|
|
||||||
if endtag then
|
|
||||||
patt[#patt+1] = "%f[%s>].->"
|
|
||||||
else
|
|
||||||
patt[#patt+1] = "%f[%s/>].->"
|
|
||||||
end
|
|
||||||
return table.concat(patt)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -2768,9 +2758,9 @@ function save_path(host, port, path, status, links_to, linked_from, contenttype)
|
|||||||
-- Split up the query, if necessary
|
-- Split up the query, if necessary
|
||||||
if(parsed['raw_querystring']) then
|
if(parsed['raw_querystring']) then
|
||||||
parsed['querystring'] = {}
|
parsed['querystring'] = {}
|
||||||
local values = stdnse.strsplit('&', parsed['raw_querystring'])
|
local values = stringaux.strsplit('&', parsed['raw_querystring'])
|
||||||
for i, v in ipairs(values) do
|
for i, v in ipairs(values) do
|
||||||
local name, value = table.unpack(stdnse.strsplit('=', v))
|
local name, value = table.unpack(stringaux.strsplit('=', v))
|
||||||
parsed['querystring'][name] = value
|
parsed['querystring'][name] = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1034,7 +1034,7 @@ Crawler = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ( #limits > 0 ) then
|
if ( #limits > 0 ) then
|
||||||
return ("Spidering limited to: %s"):format(stdnse.strjoin("; ", limits))
|
return ("Spidering limited to: %s"):format(table.concat(limits, "; "))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ local nmap = require "nmap"
|
|||||||
local match = require "match"
|
local match = require "match"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
_ENV = stdnse.module("informix", stdnse.seeall)
|
_ENV = stdnse.module("informix", stdnse.seeall)
|
||||||
|
|
||||||
@@ -1288,7 +1289,7 @@ Helper = {
|
|||||||
local result = {}
|
local result = {}
|
||||||
|
|
||||||
if ( type(query) == "string" ) then
|
if ( type(query) == "string" ) then
|
||||||
query = stdnse.strsplit(";%s*", query)
|
query = stringaux.strsplit(";%s*", query)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, q in ipairs( query ) do
|
for _, q in ipairs( query ) do
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
local math = require "math"
|
local math = require "math"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local type = type
|
local type = type
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
@@ -386,7 +387,7 @@ expand_ip = function( ip, family )
|
|||||||
if hexadectets[#hexadectets]:match( "[%.]+" ) then
|
if hexadectets[#hexadectets]:match( "[%.]+" ) then
|
||||||
hexadectets[#hexadectets], err = expand_ip( hexadectets[#hexadectets] )
|
hexadectets[#hexadectets], err = expand_ip( hexadectets[#hexadectets] )
|
||||||
if err then return nil, ( err:gsub( "IPv4", "IPv4in6" ) ) end
|
if err then return nil, ( err:gsub( "IPv4", "IPv4in6" ) ) end
|
||||||
t = stdnse.strsplit( "[%.]+", hexadectets[#hexadectets] )
|
t = stringaux.strsplit( "[%.]+", hexadectets[#hexadectets] )
|
||||||
for i, v in ipairs( t ) do
|
for i, v in ipairs( t ) do
|
||||||
t[i] = tonumber( v, 10 )
|
t[i] = tonumber( v, 10 )
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ local nmap = require "nmap"
|
|||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local openssl = stdnse.silent_require "openssl"
|
local openssl = stdnse.silent_require "openssl"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
_ENV = stdnse.module("iscsi", stdnse.seeall)
|
_ENV = stdnse.module("iscsi", stdnse.seeall)
|
||||||
|
|
||||||
@@ -219,7 +220,7 @@ Packet = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
resp.kvp = KVP:new()
|
resp.kvp = KVP:new()
|
||||||
for _, kvp in ipairs(stdnse.strsplit( "\0", data )) do
|
for _, kvp in ipairs(stringaux.strsplit( "\0", data )) do
|
||||||
local k, v = kvp:match("(.*)=(.*)")
|
local k, v = kvp:match("(.*)=(.*)")
|
||||||
if ( v ) then resp.kvp:add( k, v ) end
|
if ( v ) then resp.kvp:add( k, v ) end
|
||||||
end
|
end
|
||||||
@@ -320,7 +321,7 @@ Packet = {
|
|||||||
|
|
||||||
resp.records = {}
|
resp.records = {}
|
||||||
|
|
||||||
local kvps = stdnse.strsplit( "\0", textdata )
|
local kvps = stringaux.strsplit( "\0", textdata )
|
||||||
local record
|
local record
|
||||||
|
|
||||||
-- Each target record starts with one text key of the form:
|
-- Each target record starts with one text key of the form:
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ local nmap = require "nmap"
|
|||||||
local os = require "os"
|
local os = require "os"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local comm = require "comm"
|
local comm = require "comm"
|
||||||
_ENV = stdnse.module("ldap", stdnse.seeall)
|
_ENV = stdnse.module("ldap", stdnse.seeall)
|
||||||
@@ -544,7 +545,7 @@ function createFilter( filter )
|
|||||||
local val = ''
|
local val = ''
|
||||||
if ( filter.op == FILTER['substrings'] ) then
|
if ( filter.op == FILTER['substrings'] ) then
|
||||||
|
|
||||||
local tmptable = stdnse.strsplit('*', filter.val)
|
local tmptable = stringaux.strsplit('*', filter.val)
|
||||||
local tmp_result = ''
|
local tmp_result = ''
|
||||||
|
|
||||||
if (#tmptable <= 1 ) then
|
if (#tmptable <= 1 ) then
|
||||||
@@ -577,7 +578,7 @@ function createFilter( filter )
|
|||||||
|
|
||||||
elseif ( filter.op == FILTER['extensibleMatch'] ) then
|
elseif ( filter.op == FILTER['extensibleMatch'] ) then
|
||||||
|
|
||||||
local tmptable = stdnse.strsplit(':=', filter.val)
|
local tmptable = stringaux.strsplit(':=', filter.val)
|
||||||
local tmp_result = ''
|
local tmp_result = ''
|
||||||
local OID, bitmask
|
local OID, bitmask
|
||||||
|
|
||||||
|
|||||||
@@ -2165,7 +2165,7 @@ function lsa_lookupnames2(smbstate, policy_handle, names)
|
|||||||
local result
|
local result
|
||||||
local pos, align
|
local pos, align
|
||||||
|
|
||||||
stdnse.debug2("MSRPC: Calling LsarLookupNames2(%s) [%s]", stdnse.strjoin(", ", names), smbstate['ip'])
|
stdnse.debug2("MSRPC: Calling LsarLookupNames2(%s) [%s]", table.concat(names, ", "), smbstate['ip'])
|
||||||
|
|
||||||
|
|
||||||
-- [in] policy_handle *handle,
|
-- [in] policy_handle *handle,
|
||||||
@@ -2256,7 +2256,7 @@ function lsa_lookupsids2(smbstate, policy_handle, sids)
|
|||||||
local result
|
local result
|
||||||
local pos, align
|
local pos, align
|
||||||
|
|
||||||
stdnse.debug2("MSRPC: Calling LsarLookupSids2(%s) [%s]", stdnse.strjoin(", ", sids), smbstate['ip'])
|
stdnse.debug2("MSRPC: Calling LsarLookupSids2(%s) [%s]", table.concat(sids, ", "), smbstate['ip'])
|
||||||
|
|
||||||
-- [in] policy_handle *handle,
|
-- [in] policy_handle *handle,
|
||||||
arguments = msrpctypes.marshall_policy_handle(policy_handle)
|
arguments = msrpctypes.marshall_policy_handle(policy_handle)
|
||||||
|
|||||||
@@ -106,6 +106,7 @@
|
|||||||
local os = require "os"
|
local os = require "os"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local unicode = require "unicode"
|
local unicode = require "unicode"
|
||||||
_ENV = stdnse.module("msrpctypes", stdnse.seeall)
|
_ENV = stdnse.module("msrpctypes", stdnse.seeall)
|
||||||
@@ -1295,7 +1296,7 @@ local function marshall_Enum32(val, table)
|
|||||||
local result = 0
|
local result = 0
|
||||||
stdnse.debug4("MSRPC: Entering marshall_Enum32()")
|
stdnse.debug4("MSRPC: Entering marshall_Enum32()")
|
||||||
|
|
||||||
local vals = stdnse.strsplit("|", val)
|
local vals = stringaux.strsplit("|", val)
|
||||||
local i
|
local i
|
||||||
|
|
||||||
for i = 1, #vals, 1 do
|
for i = 1, #vals, 1 do
|
||||||
@@ -1381,7 +1382,7 @@ local function marshall_Enum8(val, table, pad)
|
|||||||
local result = 0
|
local result = 0
|
||||||
stdnse.debug4("MSRPC: Entering marshall_Enum8()")
|
stdnse.debug4("MSRPC: Entering marshall_Enum8()")
|
||||||
|
|
||||||
local vals = stdnse.strsplit("|", val)
|
local vals = stringaux.strsplit("|", val)
|
||||||
local i
|
local i
|
||||||
|
|
||||||
for i = 1, #vals, 1 do
|
for i = 1, #vals, 1 do
|
||||||
|
|||||||
@@ -585,7 +585,7 @@ SSRP =
|
|||||||
|
|
||||||
table.insert( instanceStrings, instanceString )
|
table.insert( instanceStrings, instanceString )
|
||||||
until (not firstInstanceEnd)
|
until (not firstInstanceEnd)
|
||||||
stdnse.debug2("%s: SSRP Substrings:\n %s", SSRP.DEBUG_ID, stdnse.strjoin( "\n ", instanceStrings ) )
|
stdnse.debug2("%s: SSRP Substrings:\n %s", SSRP.DEBUG_ID, table.concat(instanceStrings , "\n ") )
|
||||||
|
|
||||||
local instances = {}
|
local instances = {}
|
||||||
for _, instanceString in ipairs( instanceStrings ) do
|
for _, instanceString in ipairs( instanceStrings ) do
|
||||||
@@ -1980,7 +1980,7 @@ TDSStream = {
|
|||||||
|
|
||||||
local status, result, connectionType, errorMessage
|
local status, result, connectionType, errorMessage
|
||||||
stdnse.debug3("%s: Connection preferences for %s: %s",
|
stdnse.debug3("%s: Connection preferences for %s: %s",
|
||||||
"MSSQL", instanceInfo:GetName(), stdnse.strjoin( ", ", connectionPreference ) )
|
"MSSQL", instanceInfo:GetName(), table.concat(connectionPreference, ", ") )
|
||||||
|
|
||||||
for _, connectionType in ipairs( connectionPreference ) do
|
for _, connectionType in ipairs( connectionPreference ) do
|
||||||
if connectionType == "TCP" then
|
if connectionType == "TCP" then
|
||||||
@@ -3162,14 +3162,14 @@ Util =
|
|||||||
for k, v in pairs( tbl.colinfo ) do
|
for k, v in pairs( tbl.colinfo ) do
|
||||||
table.insert( col_names, v.text)
|
table.insert( col_names, v.text)
|
||||||
end
|
end
|
||||||
headers = stdnse.strjoin("\t", col_names)
|
headers = table.concat(col_names, "\t")
|
||||||
table.insert( new_tbl, headers)
|
table.insert( new_tbl, headers)
|
||||||
headers = headers:gsub("[^%s]", "=")
|
headers = headers:gsub("[^%s]", "=")
|
||||||
table.insert( new_tbl, headers )
|
table.insert( new_tbl, headers )
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, v in ipairs( tbl.rows ) do
|
for _, v in ipairs( tbl.rows ) do
|
||||||
table.insert( new_tbl, stdnse.strjoin("\t", v) )
|
table.insert( new_tbl, table.concat(v, "\t") )
|
||||||
end
|
end
|
||||||
|
|
||||||
return new_tbl
|
return new_tbl
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local comm = require "comm"
|
|||||||
local match = require "match"
|
local match = require "match"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
_ENV = stdnse.module("pop3", stdnse.seeall)
|
_ENV = stdnse.module("pop3", stdnse.seeall)
|
||||||
|
|
||||||
@@ -170,7 +171,7 @@ function capabilities(host, port)
|
|||||||
end
|
end
|
||||||
socket:close()
|
socket:close()
|
||||||
|
|
||||||
local lines = stdnse.strsplit("\r\n",line)
|
local lines = stringaux.strsplit("\r\n",line)
|
||||||
if not stat(table.remove(lines,1)) then
|
if not stat(table.remove(lines,1)) then
|
||||||
capas.capa = false
|
capas.capa = false
|
||||||
return capas
|
return capas
|
||||||
@@ -181,7 +182,7 @@ function capabilities(host, port)
|
|||||||
local capability = line:sub(line:find("[%w-]+"))
|
local capability = line:sub(line:find("[%w-]+"))
|
||||||
line = line:sub(#capability + 2)
|
line = line:sub(#capability + 2)
|
||||||
if ( line ~= "" ) then
|
if ( line ~= "" ) then
|
||||||
capas[capability] = stdnse.strsplit(" ", line)
|
capas[capability] = stringaux.strsplit(" ", line)
|
||||||
else
|
else
|
||||||
capas[capability] = {}
|
capas[capability] = {}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ local ipOps = require "ipOps"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
_ENV = stdnse.module("proxy", stdnse.seeall)
|
_ENV = stdnse.module("proxy", stdnse.seeall)
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ end
|
|||||||
--@param pattern The pattern to be searched
|
--@param pattern The pattern to be searched
|
||||||
--@return true if pattern is found, otherwise false
|
--@return true if pattern is found, otherwise false
|
||||||
local function check_pattern(result, pattern)
|
local function check_pattern(result, pattern)
|
||||||
local lines = stdnse.strsplit("\n", result)
|
local lines = stringaux.strsplit("\n", result)
|
||||||
for i, line in ipairs(lines) do
|
for i, line in ipairs(lines) do
|
||||||
if line:lower():match(pattern:lower()) then return true end
|
if line:lower():match(pattern:lower()) then return true end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
_ENV = stdnse.module("rtsp", stdnse.seeall)
|
_ENV = stdnse.module("rtsp", stdnse.seeall)
|
||||||
|
|
||||||
@@ -77,15 +78,13 @@ Request = {
|
|||||||
assert(self.cseq, "Request is missing required header CSeq")
|
assert(self.cseq, "Request is missing required header CSeq")
|
||||||
assert(self.url, "Request is missing URL")
|
assert(self.url, "Request is missing URL")
|
||||||
|
|
||||||
local req = stdnse.strjoin("\r\n", {
|
local req = {
|
||||||
("%s %s RTSP/1.0"):format(self.method, self.url),
|
("%s %s RTSP/1.0"):format(self.method, self.url),
|
||||||
("CSeq: %d"):format(self.cseq)
|
("CSeq: %d"):format(self.cseq),
|
||||||
} ) .. "\r\n"
|
table.unpack(self.headers),
|
||||||
if ( #self.headers > 0 ) then
|
""
|
||||||
req = req .. stdnse.strjoin("\r\n", self.headers) .. "\r\n"
|
}
|
||||||
end
|
return table.concat(req, "\r\n")
|
||||||
|
|
||||||
return req .. "\r\n"
|
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +101,7 @@ Response = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- Split the response into a temporary array
|
-- Split the response into a temporary array
|
||||||
local tmp = stdnse.strsplit("\r\n", data)
|
local tmp = stringaux.strsplit("\r\n", data)
|
||||||
if ( not(tmp) ) then return nil end
|
if ( not(tmp) ) then return nil end
|
||||||
|
|
||||||
-- we should have atleast one entry
|
-- we should have atleast one entry
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ local os = require "os"
|
|||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local openssl = stdnse.silent_require "openssl"
|
local openssl = stdnse.silent_require "openssl"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local rand = require "rand"
|
local rand = require "rand"
|
||||||
_ENV = stdnse.module("sip", stdnse.seeall)
|
_ENV = stdnse.module("sip", stdnse.seeall)
|
||||||
@@ -219,16 +220,17 @@ Session = {
|
|||||||
request:setUri(uri)
|
request:setUri(uri)
|
||||||
request:setSessionData(self.sessdata)
|
request:setSessionData(self.sessdata)
|
||||||
|
|
||||||
local data = {}
|
local data = {
|
||||||
table.insert(data, "v=0")
|
"v=0",
|
||||||
table.insert(data, ("o=- %s %s IN IP4 %s"):format(tm, tm, lhost))
|
("o=- %s %s IN IP4 %s"):format(tm, tm, lhost),
|
||||||
table.insert(data, "s=-")
|
"s=-",
|
||||||
table.insert(data, ("c=IN IP4 %s"):format(lhost))
|
("c=IN IP4 %s"):format(lhost),
|
||||||
table.insert(data, "t=0 0")
|
"t=0 0",
|
||||||
table.insert(data, "m=audio 49174 RTP/AVP 0")
|
"m=audio 49174 RTP/AVP 0",
|
||||||
table.insert(data, "a=rtpmap:0 PCMU/8000")
|
"a=rtpmap:0 PCMU/8000",
|
||||||
|
}
|
||||||
|
|
||||||
request:setContent(stdnse.strjoin("\r\n", data))
|
request:setContent(table.concat(data, "\r\n"))
|
||||||
request:setContentType("application/sdp")
|
request:setContentType("application/sdp")
|
||||||
|
|
||||||
local status, response = self:exch(request)
|
local status, response = self:exch(request)
|
||||||
@@ -452,7 +454,7 @@ Response = {
|
|||||||
local o = {}
|
local o = {}
|
||||||
setmetatable(o, self)
|
setmetatable(o, self)
|
||||||
self.__index = self
|
self.__index = self
|
||||||
o.tbl = stdnse.strsplit("\r\n", str)
|
o.tbl = stringaux.strsplit("\r\n", str)
|
||||||
return o
|
return o
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@@ -577,7 +579,7 @@ Request = {
|
|||||||
--- Sets the allow header
|
--- Sets the allow header
|
||||||
-- @name Request.setAllow
|
-- @name Request.setAllow
|
||||||
-- @param allow table containing all of the allowed SIP methods
|
-- @param allow table containing all of the allowed SIP methods
|
||||||
setAllow = function(self, allow) self.allow = stdnse.strjoin(", ", allow) end,
|
setAllow = function(self, allow) self.allow = table.concat(allow, ", ") end,
|
||||||
|
|
||||||
--- Sets the request content data
|
--- Sets the request content data
|
||||||
-- @name Request.setContent
|
-- @name Request.setContent
|
||||||
@@ -728,7 +730,7 @@ Request = {
|
|||||||
table.insert(data, ("Content-Length: %d"):format(self.length))
|
table.insert(data, ("Content-Length: %d"):format(self.length))
|
||||||
table.insert(data, "")
|
table.insert(data, "")
|
||||||
end
|
end
|
||||||
return stdnse.strjoin("\r\n", data)
|
return table.concat(data, "\r\n")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ local comm = require "comm"
|
|||||||
local sasl = require "sasl"
|
local sasl = require "sasl"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
_ENV = stdnse.module("smtp", stdnse.seeall)
|
_ENV = stdnse.module("smtp", stdnse.seeall)
|
||||||
|
|
||||||
@@ -196,7 +197,7 @@ end
|
|||||||
get_auth_mech = function(response)
|
get_auth_mech = function(response)
|
||||||
local list = {}
|
local list = {}
|
||||||
|
|
||||||
for _, line in pairs(stdnse.strsplit("\r?\n", response)) do
|
for _, line in pairs(stringaux.strsplit("\r?\n", response)) do
|
||||||
local authstr = line:match("%d+%-AUTH%s(.*)$")
|
local authstr = line:match("%d+%-AUTH%s(.*)$")
|
||||||
if authstr then
|
if authstr then
|
||||||
for mech in authstr:gmatch("[^%s]+") do
|
for mech in authstr:gmatch("[^%s]+") do
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ local nmap = require "nmap"
|
|||||||
local os = require "os"
|
local os = require "os"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local openssl = stdnse.silent_require "openssl"
|
local openssl = stdnse.silent_require "openssl"
|
||||||
_ENV = stdnse.module("ssh1", stdnse.seeall)
|
_ENV = stdnse.module("ssh1", stdnse.seeall)
|
||||||
@@ -253,7 +254,7 @@ parse_known_hosts_file = function(path)
|
|||||||
for l in io.lines(knownhostspath) do
|
for l in io.lines(knownhostspath) do
|
||||||
lnumber = lnumber + 1
|
lnumber = lnumber + 1
|
||||||
if l and string.sub(l, 1, 1) ~= "#" then
|
if l and string.sub(l, 1, 1) ~= "#" then
|
||||||
local parts = stdnse.strsplit(" ", l)
|
local parts = stringaux.strsplit(" ", l)
|
||||||
table.insert(known_host_entries, {entry=parts, linenumber=lnumber})
|
table.insert(known_host_entries, {entry=parts, linenumber=lnumber})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -186,47 +186,6 @@ print_verbose = function(level, fmt, ...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Join a list of strings with a separator string.
|
|
||||||
--
|
|
||||||
-- This is Lua's <code>table.concat</code> function with the parameters
|
|
||||||
-- swapped for coherence.
|
|
||||||
-- @usage
|
|
||||||
-- stdnse.strjoin(", ", {"Anna", "Bob", "Charlie", "Dolores"})
|
|
||||||
-- --> "Anna, Bob, Charlie, Dolores"
|
|
||||||
-- @param delimiter String to delimit each element of the list.
|
|
||||||
-- @param list Array of strings to concatenate.
|
|
||||||
-- @return Concatenated string.
|
|
||||||
function strjoin(delimiter, list)
|
|
||||||
assert(type(delimiter) == "string" or type(delimiter) == nil, "delimiter is of the wrong type! (did you get the parameters backward?)")
|
|
||||||
|
|
||||||
return concat(list, delimiter);
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Split a string at a given delimiter, which may be a pattern.
|
|
||||||
-- @usage
|
|
||||||
-- stdnse.strsplit(",%s*", "Anna, Bob, Charlie, Dolores")
|
|
||||||
-- --> { "Anna", "Bob", "Charlie", "Dolores" }
|
|
||||||
-- @param pattern Pattern that separates the desired strings.
|
|
||||||
-- @param text String to split.
|
|
||||||
-- @return Array of substrings without the separating pattern.
|
|
||||||
function strsplit(pattern, text)
|
|
||||||
local list, pos = {}, 1;
|
|
||||||
|
|
||||||
assert(pattern ~= "", "delimiter matches empty string!");
|
|
||||||
|
|
||||||
while true do
|
|
||||||
local first, last = text:find(pattern, pos);
|
|
||||||
if first then -- found?
|
|
||||||
list[#list+1] = text:sub(pos, first-1);
|
|
||||||
pos = last+1;
|
|
||||||
else
|
|
||||||
list[#list+1] = text:sub(pos);
|
|
||||||
break;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return list;
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Return a wrapper closure around a socket that buffers socket reads into
|
--- Return a wrapper closure around a socket that buffers socket reads into
|
||||||
-- chunks separated by a pattern.
|
-- chunks separated by a pattern.
|
||||||
--
|
--
|
||||||
@@ -478,28 +437,6 @@ local function format_get_indent(indent)
|
|||||||
return rep(" ", #indent)
|
return rep(" ", #indent)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function splitlines(s)
|
|
||||||
local result = {}
|
|
||||||
local i = 0
|
|
||||||
|
|
||||||
while i <= #s do
|
|
||||||
local b, e
|
|
||||||
b, e = find(s, "\r?\n", i)
|
|
||||||
if not b then
|
|
||||||
break
|
|
||||||
end
|
|
||||||
result[#result + 1] = sub(s, i, b - 1)
|
|
||||||
i = e + 1
|
|
||||||
end
|
|
||||||
|
|
||||||
if i <= #s then
|
|
||||||
result[#result + 1] = sub(s, i)
|
|
||||||
end
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- A helper for format_output (see below).
|
-- A helper for format_output (see below).
|
||||||
local function format_output_sub(status, data, indent)
|
local function format_output_sub(status, data, indent)
|
||||||
if (#data == 0) then
|
if (#data == 0) then
|
||||||
@@ -1071,42 +1008,6 @@ function pretty_printer (obj, printer)
|
|||||||
return aux(obj, "")
|
return aux(obj, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- This pattern must match the percent sign '%' since it is used in
|
|
||||||
-- escaping.
|
|
||||||
local FILESYSTEM_UNSAFE = "[^a-zA-Z0-9._-]"
|
|
||||||
---
|
|
||||||
-- Escape a string to remove bytes and strings that may have meaning to
|
|
||||||
-- a filesystem, such as slashes.
|
|
||||||
--
|
|
||||||
-- All bytes are escaped, except for:
|
|
||||||
-- * alphabetic <code>a</code>-<code>z</code> and <code>A</code>-<code>Z</code>
|
|
||||||
-- * digits 0-9
|
|
||||||
-- * <code>.</code> <code>_</code> <code>-</code>
|
|
||||||
-- In addition, the strings <code>"."</code> and <code>".."</code> have
|
|
||||||
-- their characters escaped.
|
|
||||||
--
|
|
||||||
-- Bytes are escaped by a percent sign followed by the two-digit
|
|
||||||
-- hexadecimal representation of the byte value.
|
|
||||||
-- * <code>filename_escape("filename.ext") --> "filename.ext"</code>
|
|
||||||
-- * <code>filename_escape("input/output") --> "input%2foutput"</code>
|
|
||||||
-- * <code>filename_escape(".") --> "%2e"</code>
|
|
||||||
-- * <code>filename_escape("..") --> "%2e%2e"</code>
|
|
||||||
-- This escaping is somewhat like that of JavaScript
|
|
||||||
-- <code>encodeURIComponent</code>, except that fewer bytes are
|
|
||||||
-- whitelisted, and it works on bytes, not Unicode characters or UTF-16
|
|
||||||
-- code points.
|
|
||||||
function filename_escape(s)
|
|
||||||
if s == "." then
|
|
||||||
return "%2e"
|
|
||||||
elseif s == ".." then
|
|
||||||
return "%2e%2e"
|
|
||||||
else
|
|
||||||
return (gsub(s, FILESYSTEM_UNSAFE, function (c)
|
|
||||||
return format("%%%02x", byte(c))
|
|
||||||
end))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns a conservative timeout for a host
|
--- Returns a conservative timeout for a host
|
||||||
--
|
--
|
||||||
-- If the host parameter is a NSE host table with a <code>times.timeout</code>
|
-- If the host parameter is a NSE host table with a <code>times.timeout</code>
|
||||||
@@ -1143,29 +1044,4 @@ function get_timeout(host, max_timeout, min_timeout)
|
|||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the case insensitive pattern of given parameter
|
|
||||||
-- Useful while doing case insensitive pattern match using string library.
|
|
||||||
-- https://stackoverflow.com/questions/11401890/case-insensitive-lua-pattern-matching/11402486#11402486
|
|
||||||
--
|
|
||||||
-- Ex: generate_case_insensitive_pattern("user") = "[uU][sS][eE][rR]"
|
|
||||||
--
|
|
||||||
-- @param pattern The string
|
|
||||||
-- @return A case insensitive patterned string
|
|
||||||
function generate_case_insensitive_pattern(pattern)
|
|
||||||
-- Find an optional '%' (group 1) followed by any character (group 2)
|
|
||||||
local p = pattern:gsub("(%%?)(.)", function(percent, letter)
|
|
||||||
|
|
||||||
if percent ~= "" or not letter:match("%a") then
|
|
||||||
-- If the '%' matched, or `letter` is not a letter, return "as is"
|
|
||||||
return percent .. letter
|
|
||||||
else
|
|
||||||
-- Else, return a case-insensitive character class of the matched letter
|
|
||||||
return format("[%s%s]", letter:lower(), letter:upper())
|
|
||||||
end
|
|
||||||
|
|
||||||
end)
|
|
||||||
|
|
||||||
return p
|
|
||||||
end
|
|
||||||
|
|
||||||
return _ENV;
|
return _ENV;
|
||||||
|
|||||||
139
nselib/stringaux.lua
Normal file
139
nselib/stringaux.lua
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
--- Auxiliary functions for string manipulation
|
||||||
|
--
|
||||||
|
-- @author Daniel Miller
|
||||||
|
-- @copyright Same as Nmap--See https://nmap.org/book/man-legal.html
|
||||||
|
-- @class module
|
||||||
|
-- @name stringaux
|
||||||
|
|
||||||
|
local assert = assert
|
||||||
|
local type = type
|
||||||
|
|
||||||
|
local string = require "string"
|
||||||
|
local byte = string.byte
|
||||||
|
local find = string.find
|
||||||
|
local match = string.match
|
||||||
|
local sub = string.sub
|
||||||
|
local gsub = string.gsub
|
||||||
|
local format = string.format
|
||||||
|
local lower = string.lower
|
||||||
|
local upper = string.upper
|
||||||
|
|
||||||
|
local table = require "table"
|
||||||
|
local concat = table.concat
|
||||||
|
|
||||||
|
local _ENV = {}
|
||||||
|
|
||||||
|
--- Join a list of strings with a separator string.
|
||||||
|
--
|
||||||
|
-- This is Lua's <code>table.concat</code> function with the parameters
|
||||||
|
-- swapped for coherence.
|
||||||
|
-- @usage
|
||||||
|
-- stringaux.strjoin(", ", {"Anna", "Bob", "Charlie", "Dolores"})
|
||||||
|
-- --> "Anna, Bob, Charlie, Dolores"
|
||||||
|
-- @param delimiter String to delimit each element of the list.
|
||||||
|
-- @param list Array of strings to concatenate.
|
||||||
|
-- @return Concatenated string.
|
||||||
|
function strjoin(delimiter, list)
|
||||||
|
assert(type(delimiter) == "string" or type(delimiter) == nil, "delimiter is of the wrong type! (did you get the parameters backward?)")
|
||||||
|
|
||||||
|
return concat(list, delimiter);
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Split a string at a given delimiter, which may be a pattern.
|
||||||
|
--
|
||||||
|
-- If you want to loop over the resulting values, consider using string.gmatch instead.
|
||||||
|
-- @usage
|
||||||
|
-- stringaux.strsplit(",%s*", "Anna, Bob, Charlie, Dolores")
|
||||||
|
-- --> { "Anna", "Bob", "Charlie", "Dolores" }
|
||||||
|
-- @param pattern Pattern that separates the desired strings.
|
||||||
|
-- @param text String to split.
|
||||||
|
-- @return Array of substrings without the separating pattern.
|
||||||
|
-- @see string.gmatch
|
||||||
|
function strsplit(pattern, text)
|
||||||
|
local list, pos = {}, 1;
|
||||||
|
|
||||||
|
assert(pattern ~= "", "delimiter matches empty string!");
|
||||||
|
|
||||||
|
while true do
|
||||||
|
local first, last = find(text, pattern, pos);
|
||||||
|
if first then -- found?
|
||||||
|
list[#list+1] = sub(text, pos, first-1);
|
||||||
|
pos = last+1;
|
||||||
|
else
|
||||||
|
list[#list+1] = sub(text, pos);
|
||||||
|
break;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return list;
|
||||||
|
end
|
||||||
|
|
||||||
|
-- This pattern must match the percent sign '%' since it is used in
|
||||||
|
-- escaping.
|
||||||
|
local FILESYSTEM_UNSAFE = "[^a-zA-Z0-9._-]"
|
||||||
|
---
|
||||||
|
-- Escape a string to remove bytes and strings that may have meaning to
|
||||||
|
-- a filesystem, such as slashes.
|
||||||
|
--
|
||||||
|
-- All bytes are escaped, except for:
|
||||||
|
-- * alphabetic <code>a</code>-<code>z</code> and <code>A</code>-<code>Z</code>
|
||||||
|
-- * digits 0-9
|
||||||
|
-- * <code>.</code> <code>_</code> <code>-</code>
|
||||||
|
-- In addition, the strings <code>"."</code> and <code>".."</code> have
|
||||||
|
-- their characters escaped.
|
||||||
|
--
|
||||||
|
-- Bytes are escaped by a percent sign followed by the two-digit
|
||||||
|
-- hexadecimal representation of the byte value.
|
||||||
|
-- * <code>filename_escape("filename.ext") --> "filename.ext"</code>
|
||||||
|
-- * <code>filename_escape("input/output") --> "input%2foutput"</code>
|
||||||
|
-- * <code>filename_escape(".") --> "%2e"</code>
|
||||||
|
-- * <code>filename_escape("..") --> "%2e%2e"</code>
|
||||||
|
-- This escaping is somewhat like that of JavaScript
|
||||||
|
-- <code>encodeURIComponent</code>, except that fewer bytes are
|
||||||
|
-- whitelisted, and it works on bytes, not Unicode characters or UTF-16
|
||||||
|
-- code points.
|
||||||
|
function filename_escape(s)
|
||||||
|
if s == "." then
|
||||||
|
return "%2e"
|
||||||
|
elseif s == ".." then
|
||||||
|
return "%2e%2e"
|
||||||
|
else
|
||||||
|
return (gsub(s, FILESYSTEM_UNSAFE, function (c)
|
||||||
|
return format("%%%02x", byte(c))
|
||||||
|
end))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Returns the case insensitive pattern of given parameter
|
||||||
|
--
|
||||||
|
-- Useful while doing case insensitive pattern match using string library.
|
||||||
|
-- https://stackoverflow.com/questions/11401890/case-insensitive-lua-pattern-matching/11402486#11402486
|
||||||
|
--
|
||||||
|
-- @usage stringaux.ipattern("user")
|
||||||
|
-- --> "[uU][sS][eE][rR]"
|
||||||
|
-- @param pattern The string
|
||||||
|
-- @return A case insensitive patterned string
|
||||||
|
function ipattern(pattern)
|
||||||
|
local in_brackets = false
|
||||||
|
-- Find an optional '%' (group 2) followed by any character (group 3)
|
||||||
|
local p = gsub(pattern, "(%%?)(.)", function(percent, letter)
|
||||||
|
if percent ~= "" then
|
||||||
|
-- It's a %-escape, return as-is
|
||||||
|
return nil
|
||||||
|
elseif not match(letter, "%a") then
|
||||||
|
-- It's not alpha. Update bracket status and return as-is
|
||||||
|
if letter == "[" then
|
||||||
|
in_brackets = true
|
||||||
|
elseif letter == "]" then
|
||||||
|
in_brackets = false
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
elseif not in_brackets then
|
||||||
|
-- Else, return a case-insensitive character class of the matched letter
|
||||||
|
return format("[%s%s]", lower(letter), upper(letter))
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
return p
|
||||||
|
end
|
||||||
|
|
||||||
|
return _ENV
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local math = require "math"
|
local math = require "math"
|
||||||
local os = require "os"
|
local os = require "os"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
@@ -1073,7 +1074,7 @@ function cipher_info (c)
|
|||||||
local info = cipher_info_cache[c]
|
local info = cipher_info_cache[c]
|
||||||
if info then return info end
|
if info then return info end
|
||||||
info = {}
|
info = {}
|
||||||
local tokens = stdnse.strsplit("_", c)
|
local tokens = stringaux.strsplit("_", c)
|
||||||
local i = 1
|
local i = 1
|
||||||
if tokens[i] ~= "TLS" and tokens[i] ~= "SSL" then
|
if tokens[i] ~= "TLS" and tokens[i] ~= "SSL" then
|
||||||
stdnse.debug2("cipher_info: Not a TLS ciphersuite: %s", c)
|
stdnse.debug2("cipher_info: Not a TLS ciphersuite: %s", c)
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ local ipOps = require "ipOps"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local type = type
|
local type = type
|
||||||
local next = next
|
local next = next
|
||||||
@@ -1776,14 +1777,14 @@ local format_vuln_special_fields = function(vuln_field)
|
|||||||
if vuln_field then
|
if vuln_field then
|
||||||
if type(vuln_field) == "table" then
|
if type(vuln_field) == "table" then
|
||||||
for _, line in ipairs(vuln_field) do
|
for _, line in ipairs(vuln_field) do
|
||||||
if type(line) == "string" then
|
if type(line) == "string" then
|
||||||
tadd(out, stdnse.strsplit("\r?\n", line))
|
tadd(out, stringaux.strsplit("\r?\n", line))
|
||||||
else
|
else
|
||||||
insert(out, line)
|
insert(out, line)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif type(vuln_field) == "string" then
|
elseif type(vuln_field) == "string" then
|
||||||
out = stdnse.strsplit("\r?\n", vuln_field)
|
out = stringaux.strsplit("\r?\n", vuln_field)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return next(out) and out or nil
|
return next(out) and out or nil
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ local function format_ipv4(ipv4)
|
|||||||
octets[#octets + 1] = string.format("%d", v)
|
octets[#octets + 1] = string.format("%d", v)
|
||||||
end
|
end
|
||||||
|
|
||||||
return stdnse.strjoin(".", octets)
|
return table.concat(octets, ".")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function do_ipv4(addr)
|
local function do_ipv4(addr)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local ajp = require "ajp"
|
local ajp = require "ajp"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local tableaux = require "table"
|
local tableaux = require "table"
|
||||||
|
|
||||||
@@ -66,14 +67,14 @@ action = function(host, port)
|
|||||||
return "Failed to get a valid response for the OPTION request"
|
return "Failed to get a valid response for the OPTION request"
|
||||||
end
|
end
|
||||||
|
|
||||||
local methods = stdnse.strsplit(",%s", response.headers['allow'])
|
local methods = stringaux.strsplit(",%s", response.headers['allow'])
|
||||||
|
|
||||||
local output = {}
|
local output = {}
|
||||||
table.insert(output, ("Supported methods: %s"):format(stdnse.strjoin(" ", methods)))
|
table.insert(output, ("Supported methods: %s"):format(table.concat(methods, " ")))
|
||||||
|
|
||||||
local interesting = filter_out(methods, UNINTERESTING_METHODS)
|
local interesting = filter_out(methods, UNINTERESTING_METHODS)
|
||||||
if ( #interesting > 0 ) then
|
if ( #interesting > 0 ) then
|
||||||
table.insert(output, "Potentially risky methods: " .. stdnse.strjoin(" ", interesting))
|
table.insert(output, "Potentially risky methods: " .. table.concat(interesting, " "))
|
||||||
table.insert(output, "See https://nmap.org/nsedoc/scripts/ajp-methods.html")
|
table.insert(output, "See https://nmap.org/nsedoc/scripts/ajp-methods.html")
|
||||||
end
|
end
|
||||||
return stdnse.format_output(true, output)
|
return stdnse.format_output(true, output)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local ajp = require "ajp"
|
|||||||
local io = require "io"
|
local io = require "io"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Requests a URI over the Apache JServ Protocol and displays the result
|
Requests a URI over the Apache JServ Protocol and displays the result
|
||||||
@@ -84,7 +85,7 @@ action = function(host, port)
|
|||||||
|
|
||||||
if ( response ) then
|
if ( response ) then
|
||||||
local output = response.status_line .. "\n" ..
|
local output = response.status_line .. "\n" ..
|
||||||
stdnse.strjoin("\n", response.rawheaders) ..
|
table.concat(response.rawheaders, "\n") ..
|
||||||
(response.body and "\n\n" .. response.body or "")
|
(response.body and "\n\n" .. response.body or "")
|
||||||
if ( arg_file ) then
|
if ( arg_file ) then
|
||||||
local f = io.open(arg_file, "w")
|
local f = io.open(arg_file, "w")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local nmap = require "nmap"
|
|||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local tab = require "tab"
|
local tab = require "tab"
|
||||||
local target = require "target"
|
local target = require "target"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Listens for the LAN sync information broadcasts that the Dropbox.com client
|
Listens for the LAN sync information broadcasts that the Dropbox.com client
|
||||||
@@ -113,9 +114,9 @@ action = function()
|
|||||||
info.displayname,
|
info.displayname,
|
||||||
ip,
|
ip,
|
||||||
info.port,
|
info.port,
|
||||||
stdnse.strjoin(".", info.version),
|
table.concat(info.version, "."),
|
||||||
info.host_int,
|
info.host_int,
|
||||||
stdnse.strjoin(", ", info.namespaces)
|
table.concat(info.namespaces, ", ")
|
||||||
)
|
)
|
||||||
|
|
||||||
stdnse.debug1("Added host %s.", info.displayname)
|
stdnse.debug1("Added host %s.", info.displayname)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local target = require "target"
|
local target = require "target"
|
||||||
local os = require "os"
|
local os = require "os"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
@@ -66,7 +67,7 @@ action = function()
|
|||||||
local hid_pkt = data:match("^discovered;.*$")
|
local hid_pkt = data:match("^discovered;.*$")
|
||||||
if ( hid_pkt ) then
|
if ( hid_pkt ) then
|
||||||
local status, _, _, rhost, _ = socket:get_info()
|
local status, _, _, rhost, _ = socket:get_info()
|
||||||
local hid_data = stdnse.strsplit(";", hid_pkt)
|
local hid_data = stringaux.strsplit(";", hid_pkt)
|
||||||
if #hid_data == 10 and hid_data[1] == 'discovered' and tonumber(hid_data[2]) == string.len(hid_pkt) then
|
if #hid_data == 10 and hid_data[1] == 'discovered' and tonumber(hid_data[2]) == string.len(hid_pkt) then
|
||||||
stdnse.print_debug(2, "Received HID discoveryd response from %s (%s bytes)", rhost, string.len(hid_pkt))
|
stdnse.print_debug(2, "Received HID discoveryd response from %s (%s bytes)", rhost, string.len(hid_pkt))
|
||||||
local str = ("MAC: %s; Name: %s; IP Address: %s; Model: %s; Version: %s (%s)"):format(
|
local str = ("MAC: %s; Name: %s; IP Address: %s; Model: %s; Version: %s (%s)"):format(
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local ipOps = require "ipOps"
|
|||||||
local target = require "target"
|
local target = require "target"
|
||||||
local coroutine = require "coroutine"
|
local coroutine = require "coroutine"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local io = require "io"
|
local io = require "io"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -276,7 +277,7 @@ local mgroup_names_fetch = function(filename)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for l in file:lines() do
|
for l in file:lines() do
|
||||||
groupnames_db[#groupnames_db + 1] = stdnse.strsplit("\t", l)
|
groupnames_db[#groupnames_db + 1] = stringaux.strsplit("\t", l)
|
||||||
end
|
end
|
||||||
|
|
||||||
file:close()
|
file:close()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local ipOps = require "ipOps"
|
local ipOps = require "ipOps"
|
||||||
local srvloc = require "srvloc"
|
local srvloc = require "srvloc"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -46,7 +47,7 @@ function action()
|
|||||||
attrib = attrib:match("^%(svcaddr%-ws=(.*)%)$")
|
attrib = attrib:match("^%(svcaddr%-ws=(.*)%)$")
|
||||||
if ( not(attrib) ) then return end
|
if ( not(attrib) ) then return end
|
||||||
|
|
||||||
local attribs = stdnse.strsplit(",", attrib)
|
local attribs = stringaux.strsplit(",", attrib)
|
||||||
if ( not(attribs) ) then return end
|
if ( not(attribs) ) then return end
|
||||||
|
|
||||||
local addrs = { name = "Addresses"}
|
local addrs = { name = "Addresses"}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local unpwdb = require "unpwdb"
|
|||||||
local io = require "io"
|
local io = require "io"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
|
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -115,7 +116,7 @@ Driver = {
|
|||||||
local loop = 1
|
local loop = 1
|
||||||
local err, status
|
local err, status
|
||||||
stdnse.debug(2,"Getting to CICS")
|
stdnse.debug(2,"Getting to CICS")
|
||||||
local run = stdnse.strsplit(";%s*", commands)
|
local run = stringaux.strsplit(";%s*", commands)
|
||||||
for i = 1, #run do
|
for i = 1, #run do
|
||||||
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
||||||
self.tn3270:send_cursor(run[i])
|
self.tn3270:send_cursor(run[i])
|
||||||
@@ -271,7 +272,7 @@ local function cics_test( host, port, commands, user, pass )
|
|||||||
end
|
end
|
||||||
tn:get_screen_debug(2) -- prints TN3270 screen to debug
|
tn:get_screen_debug(2) -- prints TN3270 screen to debug
|
||||||
stdnse.debug("Getting to CICS")
|
stdnse.debug("Getting to CICS")
|
||||||
local run = stdnse.strsplit(";%s*", commands)
|
local run = stringaux.strsplit(";%s*", commands)
|
||||||
for i = 1, #run do
|
for i = 1, #run do
|
||||||
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
||||||
tn:send_cursor(run[i])
|
tn:send_cursor(run[i])
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local tn3270 = require "tn3270"
|
local tn3270 = require "tn3270"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
@@ -104,7 +105,7 @@ local function cics_info( host, port, commands, user, pass, cemt, trans )
|
|||||||
end
|
end
|
||||||
tn:get_screen_debug(2) -- prints TN3270 screen to debug
|
tn:get_screen_debug(2) -- prints TN3270 screen to debug
|
||||||
stdnse.debug("Getting to CICS")
|
stdnse.debug("Getting to CICS")
|
||||||
local run = stdnse.strsplit(";%s*", commands)
|
local run = stringaux.strsplit(";%s*", commands)
|
||||||
for i = 1, #run do
|
for i = 1, #run do
|
||||||
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
||||||
tn:send_cursor(run[i])
|
tn:send_cursor(run[i])
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local tn3270 = require "tn3270"
|
local tn3270 = require "tn3270"
|
||||||
@@ -83,7 +84,7 @@ Driver = {
|
|||||||
local loop = 1
|
local loop = 1
|
||||||
local err
|
local err
|
||||||
stdnse.debug(2,"Getting to CICS")
|
stdnse.debug(2,"Getting to CICS")
|
||||||
local run = stdnse.strsplit(";%s*", commands)
|
local run = stringaux.strsplit(";%s*", commands)
|
||||||
for i = 1, #run do
|
for i = 1, #run do
|
||||||
stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
||||||
self.tn3270:send_cursor(run[i])
|
self.tn3270:send_cursor(run[i])
|
||||||
@@ -201,7 +202,7 @@ local function cics_test( host, port, commands )
|
|||||||
end
|
end
|
||||||
tn:get_screen_debug(2) -- prints TN3270 screen to debug
|
tn:get_screen_debug(2) -- prints TN3270 screen to debug
|
||||||
stdnse.debug(2,"Getting to CICS")
|
stdnse.debug(2,"Getting to CICS")
|
||||||
local run = stdnse.strsplit(";%s*", commands)
|
local run = stringaux.strsplit(";%s*", commands)
|
||||||
for i = 1, #run do
|
for i = 1, #run do
|
||||||
stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
||||||
tn:send_cursor(run[i])
|
tn:send_cursor(run[i])
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ local brute = require "brute"
|
|||||||
local creds = require "creds"
|
local creds = require "creds"
|
||||||
local unpwdb = require "unpwdb"
|
local unpwdb = require "unpwdb"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
CICS User ID enumeration script for the CESL/CESN Login screen.
|
CICS User ID enumeration script for the CESL/CESN Login screen.
|
||||||
@@ -79,7 +80,7 @@ Driver = {
|
|||||||
local loop = 1
|
local loop = 1
|
||||||
local err
|
local err
|
||||||
stdnse.debug(2,"Getting to CICS")
|
stdnse.debug(2,"Getting to CICS")
|
||||||
local run = stdnse.strsplit(";%s*", commands)
|
local run = stringaux.strsplit(";%s*", commands)
|
||||||
for i = 1, #run do
|
for i = 1, #run do
|
||||||
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
||||||
self.tn3270:send_cursor(run[i])
|
self.tn3270:send_cursor(run[i])
|
||||||
@@ -165,7 +166,7 @@ local function cics_test( host, port, commands, transaction )
|
|||||||
end
|
end
|
||||||
tn:get_screen_debug(2) -- prints TN3270 screen to debug
|
tn:get_screen_debug(2) -- prints TN3270 screen to debug
|
||||||
stdnse.debug("Getting to CICS")
|
stdnse.debug("Getting to CICS")
|
||||||
local run = stdnse.strsplit(";%s*", commands)
|
local run = stringaux.strsplit(";%s*", commands)
|
||||||
for i = 1, #run do
|
for i = 1, #run do
|
||||||
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i])
|
||||||
tn:send_cursor(run[i])
|
tn:send_cursor(run[i])
|
||||||
|
|||||||
@@ -93,11 +93,11 @@ function format_output(appdata, mode)
|
|||||||
if AppData.AccessList then
|
if AppData.AccessList then
|
||||||
|
|
||||||
if AppData.AccessList.User then
|
if AppData.AccessList.User then
|
||||||
line = line .. "; Users: " .. stdnse.strjoin(", ", AppData.AccessList.User)
|
line = line .. "; Users: " .. table.concat(AppData.AccessList.User, ", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
if AppData.AccessList.Group then
|
if AppData.AccessList.Group then
|
||||||
line = line .. "; Groups: " .. stdnse.strjoin(", ", AppData.AccessList.Group)
|
line = line .. "; Groups: " .. table.concat(AppData.AccessList.Group, ", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(result, line)
|
table.insert(result, line)
|
||||||
@@ -123,11 +123,11 @@ function format_output(appdata, mode)
|
|||||||
|
|
||||||
if AppData.AccessList then
|
if AppData.AccessList then
|
||||||
if AppData.AccessList.User then
|
if AppData.AccessList.User then
|
||||||
table.insert(result_part, "Users: " .. stdnse.strjoin(", ", AppData.AccessList.User) )
|
table.insert(result_part, "Users: " .. table.concat(AppData.AccessList.User, ", ") )
|
||||||
end
|
end
|
||||||
|
|
||||||
if AppData.AccessList.Group then
|
if AppData.AccessList.Group then
|
||||||
table.insert(result_part, "Groups: " .. stdnse.strjoin(", ", AppData.AccessList.Group) )
|
table.insert(result_part, "Groups: " .. table.concat(AppData.AccessList.Group, ", ") )
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(result, result_part)
|
table.insert(result, result_part)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local coap = require "coap"
|
local coap = require "coap"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -163,7 +164,7 @@ get_blocks = function(helper, options, b2opt, payload, max_reqs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local components = stdnse.strsplit("/", options.uri)
|
local components = stringaux.strsplit("/", options.uri)
|
||||||
for _, component in ipairs(components) do
|
for _, component in ipairs(components) do
|
||||||
if component ~= "" then
|
if component ~= "" then
|
||||||
table.insert(opts.options, {["name"] = "uri_path", ["value"] = component})
|
table.insert(opts.options, {["name"] = "uri_path", ["value"] = component})
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ local function go(host, port)
|
|||||||
-- Decide which type of request to make
|
-- Decide which type of request to make
|
||||||
local request_type = dhcp.request_types[nmap.registry.args.dhcptype or "DHCPINFORM"]
|
local request_type = dhcp.request_types[nmap.registry.args.dhcptype or "DHCPINFORM"]
|
||||||
if(request_type == nil) then
|
if(request_type == nil) then
|
||||||
return false, "Valid request types: " .. stdnse.strjoin(", ", dhcp.request_types_str)
|
return false, "Valid request types: " .. table.concat(dhcp.request_types_str, ", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Generate the MAC address, if it's random
|
-- Generate the MAC address, if it's random
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ action = function(host, port)
|
|||||||
'quit',
|
'quit',
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( not(socket:send(stdnse.strjoin("\r\n", probes) .. "\r\n")) ) then
|
if ( not(socket:send(table.concat(probes, "\r\n") .. "\r\n")) ) then
|
||||||
return fail("Failed to send request to server")
|
return fail("Failed to send request to server")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ local math = require "math"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local target = require "target"
|
local target = require "target"
|
||||||
local rand = require "rand"
|
local rand = require "rand"
|
||||||
@@ -159,7 +160,7 @@ local function srv_main(domainname, srvresults, srv_iter)
|
|||||||
if(res) then
|
if(res) then
|
||||||
for _,addr in ipairs(res) do
|
for _,addr in ipairs(res) do
|
||||||
local hostn = name..'.'..domainname
|
local hostn = name..'.'..domainname
|
||||||
addr = stdnse.strsplit(":",addr)
|
addr = stringaux.strsplit(":",addr)
|
||||||
for _, dtype in ipairs({"A", "AAAA"}) do
|
for _, dtype in ipairs({"A", "AAAA"}) do
|
||||||
local srvres = resolve(addr[4], dtype)
|
local srvres = resolve(addr[4], dtype)
|
||||||
if(srvres) then
|
if(srvres) then
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Performs DNS cache snooping against a DNS server.
|
Performs DNS cache snooping against a DNS server.
|
||||||
@@ -228,5 +229,5 @@ action = function(host, port)
|
|||||||
nmap.set_port_state(host, port, "open")
|
nmap.set_port_state(host, port, "open")
|
||||||
end
|
end
|
||||||
|
|
||||||
return string.format("%d of %d tested domains are cached.\n", #cached, #domains) .. stdnse.strjoin("\n", cached)
|
return string.format("%d of %d tested domains are cached.\n", #cached, #domains) .. table.concat(cached, "\n")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ local dns_checks = {
|
|||||||
|
|
||||||
local output = "None of the servers allow recursive queries."
|
local output = "None of the servers allow recursive queries."
|
||||||
if ( 0 < #result ) then
|
if ( 0 < #result ) then
|
||||||
output = ("The following servers allow recursive queries: %s"):format(stdnse.strjoin(", ", result))
|
output = ("The following servers allow recursive queries: %s"):format(table.concat(result, ", "))
|
||||||
return true, { status = Status.FAIL, output = output }
|
return true, { status = Status.FAIL, output = output }
|
||||||
end
|
end
|
||||||
return true, { status = Status.PASS, output = output }
|
return true, { status = Status.PASS, output = output }
|
||||||
@@ -139,7 +139,7 @@ local dns_checks = {
|
|||||||
|
|
||||||
local output = "All DNS IPs were public"
|
local output = "All DNS IPs were public"
|
||||||
if ( 0 < #result ) then
|
if ( 0 < #result ) then
|
||||||
output = ("The following private IPs were detected: %s"):format(stdnse.strjoin(", ", result))
|
output = ("The following private IPs were detected: %s"):format(table.concat(result, ", "))
|
||||||
status = Status.FAIL
|
status = Status.FAIL
|
||||||
else
|
else
|
||||||
status = Status.PASS
|
status = Status.PASS
|
||||||
@@ -167,7 +167,7 @@ local dns_checks = {
|
|||||||
|
|
||||||
local output = "All servers respond to DNS queries"
|
local output = "All servers respond to DNS queries"
|
||||||
if ( 0 < #result ) then
|
if ( 0 < #result ) then
|
||||||
output = ("The following servers did not respond to DNS queries: %s"):format(stdnse.strjoin(", ", result))
|
output = ("The following servers did not respond to DNS queries: %s"):format(table.concat(result, ", "))
|
||||||
return true, { status = Status.FAIL, output = output }
|
return true, { status = Status.FAIL, output = output }
|
||||||
end
|
end
|
||||||
return true, { status = Status.PASS, output = output }
|
return true, { status = Status.PASS, output = output }
|
||||||
@@ -213,7 +213,7 @@ local dns_checks = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ( 0 < #result ) then
|
if ( 0 < #result ) then
|
||||||
local output = ("The following servers were found in the zone, but not in the parent: %s"):format(stdnse.strjoin(", ", result))
|
local output = ("The following servers were found in the zone, but not in the parent: %s"):format(table.concat(result, ", "))
|
||||||
return true, { status = Status.FAIL, output = output }
|
return true, { status = Status.FAIL, output = output }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -261,7 +261,7 @@ local dns_checks = {
|
|||||||
end
|
end
|
||||||
|
|
||||||
if ( 0 < #result ) then
|
if ( 0 < #result ) then
|
||||||
local output = ("The following servers were found in the parent, but not in the zone: %s"):format(stdnse.strjoin(", ", result))
|
local output = ("The following servers were found in the parent, but not in the zone: %s"):format(table.concat(result, ", "))
|
||||||
return true, { status = Status.FAIL, output = output }
|
return true, { status = Status.FAIL, output = output }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ local dns_checks = {
|
|||||||
|
|
||||||
local output = "All MX records have PTR records"
|
local output = "All MX records have PTR records"
|
||||||
if ( 0 < #result ) then
|
if ( 0 < #result ) then
|
||||||
output = ("The following IPs do not have PTR records: %s"):format(stdnse.strjoin(", ", result))
|
output = ("The following IPs do not have PTR records: %s"):format(table.concat(result, ", "))
|
||||||
return true, { status = Status.FAIL, output = output }
|
return true, { status = Status.FAIL, output = output }
|
||||||
end
|
end
|
||||||
return true, { status = Status.PASS, output = output }
|
return true, { status = Status.PASS, output = output }
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local tableaux = require "tableaux"
|
local tableaux = require "tableaux"
|
||||||
|
|
||||||
@@ -83,11 +84,11 @@ local function remove_empty(t)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function split(domain)
|
local function split(domain)
|
||||||
return stdnse.strsplit("%.", domain)
|
return stringaux.strsplit("%.", domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function join(components)
|
local function join(components)
|
||||||
return stdnse.strjoin(".", remove_empty(components))
|
return table.concat(remove_empty(components, "."))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove the first component of a domain name. Return nil if the number of
|
-- Remove the first component of a domain name. Return nil if the number of
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local dns = require "dns"
|
|||||||
local base32 = require "base32"
|
local base32 = require "base32"
|
||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local tableaux = require "table"
|
local tableaux = require "table"
|
||||||
local rand = require "rand"
|
local rand = require "rand"
|
||||||
@@ -103,11 +104,11 @@ local function remove_empty(t)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function split(domain)
|
local function split(domain)
|
||||||
return stdnse.strsplit("%.", domain)
|
return stringaux.strsplit("%.", domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function join(components)
|
local function join(components)
|
||||||
return stdnse.strjoin(".", remove_empty(components))
|
return table.concat(remove_empty(components, "."))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Remove the first component of a domain name. Return nil if the number of
|
-- Remove the first component of a domain name. Return nil if the number of
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local dns = require "dns"
|
local dns = require "dns"
|
||||||
local ipOps = require "ipOps"
|
local ipOps = require "ipOps"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local tab = require "tab"
|
local tab = require "tab"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ action = function(host)
|
|||||||
"Files Online", "Date added")
|
"Files Online", "Date added")
|
||||||
for _, record in ipairs(result) do
|
for _, record in ipairs(result) do
|
||||||
local name, ip, sbl, asn, country, status, level, files_online,
|
local name, ip, sbl, asn, country, status, level, files_online,
|
||||||
dateadded = table.unpack(stdnse.strsplit("| ", record))
|
dateadded = table.unpack(stringaux.strsplit("| ", record))
|
||||||
level = levels[tonumber(level)] or "Unknown"
|
level = levels[tonumber(level)] or "Unknown"
|
||||||
tab.addrow(output, name, ip, sbl, asn, country, status, level, files_online, dateadded)
|
tab.addrow(output, name, ip, sbl, asn, country, status, level, files_online, dateadded)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local shortport = require "shortport"
|
|||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local strbuf = require "strbuf"
|
local strbuf = require "strbuf"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local tab = require "tab"
|
local tab = require "tab"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local target = require "target"
|
local target = require "target"
|
||||||
@@ -218,7 +219,7 @@ function build_domain(host)
|
|||||||
buf = strbuf.new()
|
buf = strbuf.new()
|
||||||
abs_name = {}
|
abs_name = {}
|
||||||
|
|
||||||
names = stdnse.strsplit('%.', host)
|
names = stringaux.strsplit('%.', host)
|
||||||
if names == nil then names = {host} end
|
if names == nil then names = {host} end
|
||||||
|
|
||||||
-- try to determine root of domain name
|
-- try to determine root of domain name
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -75,7 +76,7 @@ local function readAPIBlock( socket )
|
|||||||
local status, line = socket:receive_lines(1)
|
local status, line = socket:receive_lines(1)
|
||||||
|
|
||||||
if ( not(status) ) then return false, "Failed to read line" end
|
if ( not(status) ) then return false, "Failed to read line" end
|
||||||
lines = stdnse.strsplit( "\n", line )
|
lines = stringaux.strsplit( "\n", line )
|
||||||
|
|
||||||
for _, line in ipairs( lines ) do
|
for _, line in ipairs( lines ) do
|
||||||
if ( not(line:match("BeginData")) and not(line:match("EndData")) ) then
|
if ( not(line:match("BeginData")) and not(line:match("EndData")) ) then
|
||||||
@@ -110,7 +111,7 @@ action = function(host, port)
|
|||||||
if( not(user)) then return fail("No username supplied (see domcon-cmd.user)") end
|
if( not(user)) then return fail("No username supplied (see domcon-cmd.user)") end
|
||||||
if( not(pass)) then return fail("No password supplied (see domcon-cmd.pass)") end
|
if( not(pass)) then return fail("No password supplied (see domcon-cmd.pass)") end
|
||||||
|
|
||||||
cmds = stdnse.strsplit(";%s*", cmd)
|
cmds = stringaux.strsplit(";%s*", cmd)
|
||||||
|
|
||||||
socket:set_timeout(10000)
|
socket:set_timeout(10000)
|
||||||
local status = socket:connect( host, port )
|
local status = socket:connect( host, port )
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local io = require "io"
|
|||||||
local nrpc = require "nrpc"
|
local nrpc = require "nrpc"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local unpwdb = require "unpwdb"
|
local unpwdb = require "unpwdb"
|
||||||
|
|
||||||
@@ -103,7 +104,7 @@ action = function(host, port)
|
|||||||
helper:disconnect()
|
helper:disconnect()
|
||||||
|
|
||||||
if ( status and data and path ) then
|
if ( status and data and path ) then
|
||||||
local filename = path .. "/" .. stdnse.filename_escape(username .. ".id")
|
local filename = path .. "/" .. stringaux.filename_escape(username .. ".id")
|
||||||
local status, err = saveIDFile( filename, data )
|
local status, err = saveIDFile( filename, data )
|
||||||
|
|
||||||
if ( status ) then
|
if ( status ) then
|
||||||
|
|||||||
@@ -788,7 +788,7 @@ local function portrange(ports)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- ranges are delimited by `,'
|
-- ranges are delimited by `,'
|
||||||
return stdnse.strjoin(",", strrange)
|
return table.concat(strrange, ",")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local ftp = require "ftp"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local vulns = require "vulns"
|
local vulns = require "vulns"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -74,7 +75,7 @@ end
|
|||||||
|
|
||||||
-- Returns true if the provided version is vulnerable
|
-- Returns true if the provided version is vulnerable
|
||||||
local function is_version_vulnerable(version)
|
local function is_version_vulnerable(version)
|
||||||
local vers = stdnse.strsplit("%.", version)
|
local vers = stringaux.strsplit("%.", version)
|
||||||
|
|
||||||
if #vers > 0 and vers[3] then
|
if #vers > 0 and vers[3] then
|
||||||
local relnum = string.sub(vers[3], 1, 1)
|
local relnum = string.sub(vers[3], 1, 1)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local match = require "match"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local tab = require "tab"
|
local tab = require "tab"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ local function decodeTag(tag, lines)
|
|||||||
tab.addrow(fs_tab, "Mount point", "Fs type", "Size", "Available")
|
tab.addrow(fs_tab, "Mount point", "Fs type", "Size", "Available")
|
||||||
for _, line in ipairs(lines) do
|
for _, line in ipairs(lines) do
|
||||||
if ( ".clear" ~= line ) then
|
if ( ".clear" ~= line ) then
|
||||||
local mount, prefix, fstype, size, free, used, bs = table.unpack(stdnse.strsplit("%s", line))
|
local mount, prefix, fstype, size, free, used, bs = table.unpack(stringaux.strsplit("%s", line))
|
||||||
if ( size and free and mount and fstype ) then
|
if ( size and free and mount and fstype ) then
|
||||||
size = ("%dM"):format(math.ceil(tonumber(size) * tonumber(bs) / 1048576))
|
size = ("%dM"):format(math.ceil(tonumber(size) * tonumber(bs) / 1048576))
|
||||||
free = ("%dM"):format(math.ceil(tonumber(free) * tonumber(bs) / 1048576))
|
free = ("%dM"):format(math.ceil(tonumber(free) * tonumber(bs) / 1048576))
|
||||||
@@ -116,7 +117,7 @@ local function decodeTag(tag, lines)
|
|||||||
elseif ( "uptime" == tag ) then
|
elseif ( "uptime" == tag ) then
|
||||||
return ("%s: %s"):format(long_names[tag], datetime.format_time(lines[1] * 60))
|
return ("%s: %s"):format(long_names[tag], datetime.format_time(lines[1] * 60))
|
||||||
elseif ( "mem" == tag ) then
|
elseif ( "mem" == tag ) then
|
||||||
local total, used = table.unpack(stdnse.strsplit("%s", lines[1]))
|
local total, used = table.unpack(stringaux.strsplit("%s", lines[1]))
|
||||||
if ( not(total) or not(used) ) then
|
if ( not(total) or not(used) ) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -124,7 +125,7 @@ local function decodeTag(tag, lines)
|
|||||||
total = math.ceil(tonumber(total)/1048576)
|
total = math.ceil(tonumber(total)/1048576)
|
||||||
return ("%s: Total %dM, Free %dM"):format(long_names[tag], total, free)
|
return ("%s: Total %dM, Free %dM"):format(long_names[tag], total, free)
|
||||||
elseif ( "proc" == tag ) then
|
elseif ( "proc" == tag ) then
|
||||||
local procs, _, forks, load, users = table.unpack(stdnse.strsplit("%s", lines[1]))
|
local procs, _, forks, load, users = table.unpack(stringaux.strsplit("%s", lines[1]))
|
||||||
if ( not(procs) or not(forks) or not(load) or not(users) ) then
|
if ( not(procs) or not(forks) or not(load) or not(users) ) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -70,7 +71,7 @@ action = function( host, port )
|
|||||||
while line ~= nil do
|
while line ~= nil do
|
||||||
if #line > 1 then
|
if #line > 1 then
|
||||||
local gtype = string.sub(line, 1, 1)
|
local gtype = string.sub(line, 1, 1)
|
||||||
local fields = stdnse.strsplit("\t", string.sub(line, 2))
|
local fields = stringaux.strsplit("\t", string.sub(line, 2))
|
||||||
if #fields > 1 then
|
if #fields > 1 then
|
||||||
local label = fields[1]
|
local label = fields[1]
|
||||||
local filename = fields[2]
|
local filename = fields[2]
|
||||||
@@ -86,6 +87,6 @@ action = function( host, port )
|
|||||||
end
|
end
|
||||||
line = buffer()
|
line = buffer()
|
||||||
end
|
end
|
||||||
return "\n" .. stdnse.strjoin("\n", files)
|
return "\n" .. table.concat(files, "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local math = require "math"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -51,7 +52,7 @@ action = function( host, port )
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local separator = string.sub(data, 1, 1)
|
local separator = string.sub(data, 1, 1)
|
||||||
local fields = stdnse.strsplit(separator, data)
|
local fields = stringaux.strsplit(separator, data)
|
||||||
local info = {}
|
local info = {}
|
||||||
local disks = math.floor((# fields) / 5)
|
local disks = math.floor((# fields) / 5)
|
||||||
for i = 0, (disks - 1) do
|
for i = 0, (disks - 1) do
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ local io = require "io"
|
|||||||
local ipOps = require "ipOps"
|
local ipOps = require "ipOps"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
|
local table = require "table"
|
||||||
local target = require "target"
|
local target = require "target"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -101,11 +103,11 @@ action = function(host)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
output_tab.hosts = hosts_log
|
output_tab.hosts = hosts_log
|
||||||
local hostnames_str = stdnse.strjoin("\n", hostnames)
|
local hostnames_str = table.concat(hostnames, "\n")
|
||||||
|
|
||||||
local filename_prefix = stdnse.get_script_args("hostmap-bfk.prefix")
|
local filename_prefix = stdnse.get_script_args("hostmap-bfk.prefix")
|
||||||
if filename_prefix then
|
if filename_prefix then
|
||||||
local filename = filename_prefix .. stdnse.filename_escape(host.targetname or host.ip)
|
local filename = filename_prefix .. stringaux.filename_escape(host.targetname or host.ip)
|
||||||
local status, err = write_file(filename, hostnames_str .. "\n")
|
local status, err = write_file(filename, hostnames_str .. "\n")
|
||||||
if status then
|
if status then
|
||||||
output_tab.filename = filename
|
output_tab.filename = filename
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ local io = require "io"
|
|||||||
local http = require "http"
|
local http = require "http"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local target = require "target"
|
local target = require "target"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local tableaux = require "table"
|
local tableaux = require "table"
|
||||||
@@ -106,8 +107,8 @@ action = function(host)
|
|||||||
output_tab.subdomains = hostnames
|
output_tab.subdomains = hostnames
|
||||||
--write to file
|
--write to file
|
||||||
if filename_prefix then
|
if filename_prefix then
|
||||||
local filename = filename_prefix .. stdnse.filename_escape(get_hostname(host))
|
local filename = filename_prefix .. stringaux.filename_escape(get_hostname(host))
|
||||||
hostnames_str = stdnse.strjoin("\n", hostnames)
|
hostnames_str = table.concat(hostnames, "\n")
|
||||||
|
|
||||||
local status, err = write_file(filename, hostnames_str)
|
local status, err = write_file(filename, hostnames_str)
|
||||||
if status then
|
if status then
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ local io = require "io"
|
|||||||
local http = require "http"
|
local http = require "http"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
|
local table = require "table"
|
||||||
local target = require "target"
|
local target = require "target"
|
||||||
|
|
||||||
local HOSTMAP_BING_SERVER = "www.ip2hosts.com"
|
local HOSTMAP_BING_SERVER = "www.ip2hosts.com"
|
||||||
@@ -69,7 +71,7 @@ local function query_bing(ip)
|
|||||||
if not response.status then
|
if not response.status then
|
||||||
return string.format("Error: could not GET http://%s%s", HOSTMAP_BING_SERVER, query)
|
return string.format("Error: could not GET http://%s%s", HOSTMAP_BING_SERVER, query)
|
||||||
end
|
end
|
||||||
entries = stdnse.strsplit(",", response.body);
|
entries = stringaux.strsplit(",", response.body);
|
||||||
for _, entry in pairs(entries) do
|
for _, entry in pairs(entries) do
|
||||||
if not hostnames[entry] and entry ~= "" then
|
if not hostnames[entry] and entry ~= "" then
|
||||||
if target.ALLOW_NEW_TARGETS then
|
if target.ALLOW_NEW_TARGETS then
|
||||||
@@ -100,8 +102,8 @@ action = function(host)
|
|||||||
output_tab.hosts = hostnames
|
output_tab.hosts = hostnames
|
||||||
--write to file
|
--write to file
|
||||||
if filename_prefix then
|
if filename_prefix then
|
||||||
local filename = filename_prefix .. stdnse.filename_escape(host.targetname or host.ip)
|
local filename = filename_prefix .. stringaux.filename_escape(host.targetname or host.ip)
|
||||||
hostnames_str = stdnse.strjoin("\n", hostnames)
|
hostnames_str = table.concat(hostnames, "\n")
|
||||||
local status, err = write_file(filename, hostnames_str)
|
local status, err = write_file(filename, hostnames_str)
|
||||||
if status then
|
if status then
|
||||||
output_tab.filename = filename
|
output_tab.filename = filename
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ action = function(host, port)
|
|||||||
table.insert(schemes, item.scheme)
|
table.insert(schemes, item.scheme)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
tab.addrow(auth_urls, r.url, ("HTTP: %s"):format(stdnse.strjoin(", ", schemes)))
|
tab.addrow(auth_urls, r.url, ("HTTP: %s"):format(table.concat(schemes, ", ")))
|
||||||
else
|
else
|
||||||
tab.addrow(auth_urls, r.url, ("HTTP: %s"):format(auth))
|
tab.addrow(auth_urls, r.url, ("HTTP: %s"):format(auth))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -131,6 +131,6 @@ action = function(host, port)
|
|||||||
|
|
||||||
--output
|
--output
|
||||||
if #output>0 then
|
if #output>0 then
|
||||||
return stdnse.strjoin("\n", output)
|
return table.concat(output, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -192,6 +192,6 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #output > 0 then
|
if #output > 0 then
|
||||||
return stdnse.strjoin("\n", output)
|
return table.concat(output, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ local http = require "http"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
local openssl = stdnse.silent_require "openssl"
|
local openssl = stdnse.silent_require "openssl"
|
||||||
|
|
||||||
@@ -96,17 +97,17 @@ action = function(host, port)
|
|||||||
-- Prepare output
|
-- Prepare output
|
||||||
output_lines = {}
|
output_lines = {}
|
||||||
if installation_version then
|
if installation_version then
|
||||||
output_lines[#output_lines + 1] = "Version of codebase: " .. stdnse.strjoin(", ", installation_version)
|
output_lines[#output_lines + 1] = "Version of codebase: " .. table.concat(installation_version, ", ")
|
||||||
end
|
end
|
||||||
if icon_versions then
|
if icon_versions then
|
||||||
output_lines[#output_lines + 1] = "Version of icons: " .. stdnse.strjoin(", ", icon_versions)
|
output_lines[#output_lines + 1] = "Version of icons: " .. table.concat(icon_versions, ", ")
|
||||||
end
|
end
|
||||||
if stylesheet_versions then
|
if stylesheet_versions then
|
||||||
output_lines[#output_lines + 1] = "Version of stylesheet: " .. stdnse.strjoin(", ", stylesheet_versions)
|
output_lines[#output_lines + 1] = "Version of stylesheet: " .. table.concat(stylesheet_versions, ", ")
|
||||||
elseif stylesheet_hash and nmap.verbosity() >= 2 then
|
elseif stylesheet_hash and nmap.verbosity() >= 2 then
|
||||||
output_lines[#output_lines + 1] = "Default stylesheet has an unknown hash: " .. stylesheet_hash
|
output_lines[#output_lines + 1] = "Default stylesheet has an unknown hash: " .. stylesheet_hash
|
||||||
end
|
end
|
||||||
if #output_lines > 0 then
|
if #output_lines > 0 then
|
||||||
return stdnse.strjoin("\n", output_lines)
|
return table.concat(output_lines, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local http = require "http"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -48,7 +49,7 @@ local function origin_ok(raw, origin)
|
|||||||
if raw == "null" then
|
if raw == "null" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local allowed = stdnse.strsplit(" ", raw)
|
local allowed = stringaux.strsplit(" ", raw)
|
||||||
for _, ao in ipairs(allowed) do
|
for _, ao in ipairs(allowed) do
|
||||||
if origin == ao then
|
if origin == ao then
|
||||||
return true
|
return true
|
||||||
@@ -61,9 +62,9 @@ local function method_ok(raw, method)
|
|||||||
if not raw then
|
if not raw then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
local stuff = stdnse.strsplit(" ", raw)
|
local stuff = stringaux.strsplit(" ", raw)
|
||||||
local nospace = stdnse.strjoin("", stuff)
|
local nospace = table.concat(stuff, "")
|
||||||
local allowed = stdnse.strsplit(",", nospace)
|
local allowed = stringaux.strsplit(",", nospace)
|
||||||
for _, am in ipairs(allowed) do
|
for _, am in ipairs(allowed) do
|
||||||
if method == am then
|
if method == am then
|
||||||
return true
|
return true
|
||||||
@@ -95,6 +96,6 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #allowed > 0 then
|
if #allowed > 0 then
|
||||||
return stdnse.strjoin(" ", allowed)
|
return table.concat(allowed, " ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -291,13 +291,13 @@ Forgery attacks, and may allow third parties to access sensitive data meant for
|
|||||||
tostring(content[i])
|
tostring(content[i])
|
||||||
end
|
end
|
||||||
vuln.check_results = content
|
vuln.check_results = content
|
||||||
vuln.extra_info = string.format("Trusted domains:%s\n", stdnse.strjoin(', ', domains))
|
vuln.extra_info = string.format("Trusted domains:%s\n", table.concat(domains, ', '))
|
||||||
if not(lookup) and nmap.verbosity()>=2 then
|
if not(lookup) and nmap.verbosity()>=2 then
|
||||||
vuln.extra_info = vuln.extra_info .. "Use the script argument 'domain-lookup' to find trusted domains available for purchase"
|
vuln.extra_info = vuln.extra_info .. "Use the script argument 'domain-lookup' to find trusted domains available for purchase"
|
||||||
end
|
end
|
||||||
if lookup ~= nil and #domains_available>0 then
|
if lookup ~= nil and #domains_available>0 then
|
||||||
vuln.state = vulns.STATE.EXPLOIT
|
vuln.state = vulns.STATE.EXPLOIT
|
||||||
vuln.extra_info = vuln.extra_info .. string.format("[!]Trusted domains available for purchase:%s", stdnse.strjoin(', ', domains_available))
|
vuln.extra_info = vuln.extra_info .. string.format("[!]Trusted domains available for purchase:%s", table.concat(domains_available, ', '))
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local io = require "io"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -184,7 +185,7 @@ local function getUserDetails( body )
|
|||||||
-- Remove the parenthesis around the password
|
-- Remove the parenthesis around the password
|
||||||
http_passwd = http_passwd:sub(2,-2)
|
http_passwd = http_passwd:sub(2,-2)
|
||||||
-- In case we have more than one full name, return only the last
|
-- In case we have more than one full name, return only the last
|
||||||
full_name = stdnse.strsplit(";%s*", full_name)
|
full_name = stringaux.strsplit(";%s*", full_name)
|
||||||
full_name = full_name[#full_name]
|
full_name = full_name[#full_name]
|
||||||
|
|
||||||
return { fullname = full_name, passwd = ( http_passwd or dsp_http_passwd ), idfile = id_file }
|
return { fullname = full_name, passwd = ( http_passwd or dsp_http_passwd ), idfile = id_file }
|
||||||
@@ -309,7 +310,7 @@ action = function(host, port)
|
|||||||
http_response = http.get( vhost or host, port, u_details.idfile, { auth = { username = user, password = pass }, no_cache = true })
|
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
|
if ( http_response.status == 200 ) then
|
||||||
local filename = download_path .. "/" .. stdnse.filename_escape(u_details.fullname .. ".id")
|
local filename = download_path .. "/" .. stringaux.filename_escape(u_details.fullname .. ".id")
|
||||||
local status, err = saveIDFile( filename, http_response.body )
|
local status, err = saveIDFile( filename, http_response.body )
|
||||||
if ( status ) then
|
if ( status ) then
|
||||||
table.insert( id_files, ("%s ID File has been downloaded (%s)"):format(u_details.fullname, filename) )
|
table.insert( id_files, ("%s ID File has been downloaded (%s)"):format(u_details.fullname, filename) )
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[The script is used to fetch files from servers.
|
description = [[The script is used to fetch files from servers.
|
||||||
@@ -99,7 +100,7 @@ local function save_file(content, file_name, destination, url)
|
|||||||
if url:getDir() == url:getFile() then
|
if url:getDir() == url:getFile() then
|
||||||
file_path = file_path .. "index.html"
|
file_path = file_path .. "index.html"
|
||||||
else
|
else
|
||||||
file_path = file_path .. stdnse.filename_escape(url:getFile():gsub(url:getDir(),""))
|
file_path = file_path .. stringaux.filename_escape(url:getFile():gsub(url:getDir(),""))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local http = require "http"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Displays the contents of the "generator" meta tag of a web page (default: /)
|
Displays the contents of the "generator" meta tag of a web page (default: /)
|
||||||
@@ -54,14 +55,7 @@ action = function(host, port)
|
|||||||
local redirects = tonumber(stdnse.get_script_args('http-generator.redirects')) or 3
|
local redirects = tonumber(stdnse.get_script_args('http-generator.redirects')) or 3
|
||||||
|
|
||||||
-- Worst case: <meta name=Generator content="Microsoft Word 11">
|
-- Worst case: <meta name=Generator content="Microsoft Word 11">
|
||||||
local pattern = '<meta name=[\"\']?generator[\"\']? content=[\"\']([^\"\']*)[\"\'] ?/?>'
|
local pattern = stringaux.ipattern('<meta name=[\"\']?generator[\"\']? content=[\"\']([^\"\']*)[\"\'] ?/?>')
|
||||||
|
|
||||||
-- Make pattern case-insensitive
|
|
||||||
pattern = pattern:gsub("%a", function (c)
|
|
||||||
return string.format("[%s%s]", string.lower(c),
|
|
||||||
string.upper(c))
|
|
||||||
end)
|
|
||||||
|
|
||||||
response = http.get(host, port, path, {redirect_ok=redirects})
|
response = http.get(host, port, path, {redirect_ok=redirects})
|
||||||
if ( response and response.body ) then
|
if ( response and response.body ) then
|
||||||
return response.body:match(pattern)
|
return response.body:match(pattern)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Checks if hosts are on Google's blacklist of suspected malware and phishing
|
Checks if hosts are on Google's blacklist of suspected malware and phishing
|
||||||
@@ -103,6 +104,6 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #output_lns > 0 then
|
if #output_lns > 0 then
|
||||||
return stdnse.strjoin("\n", output_lns)
|
return table.concat(output_lns, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Checks for a vulnerability in IIS 5.1/6.0 that allows arbitrary users to access
|
Checks for a vulnerability in IIS 5.1/6.0 that allows arbitrary users to access
|
||||||
@@ -211,7 +212,7 @@ action = function(host, port)
|
|||||||
return nmap.verbosity() > 0 and "WebDAV is ENABLED. No protected folder found; check not run. If you know a protected folder, add --script-args=webdavfolder=<path>" or nil
|
return nmap.verbosity() > 0 and "WebDAV is ENABLED. No protected folder found; check not run. If you know a protected folder, add --script-args=webdavfolder=<path>" or nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return "WebDAV is ENABLED. Vulnerable folders discovered: " .. stdnse.strjoin(", ", results)
|
return "WebDAV is ENABLED. Vulnerable folders discovered: " .. table.concat(results, ", ")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Exploits a null-byte poisoning vulnerability in Litespeed Web Servers 4.0.x
|
Exploits a null-byte poisoning vulnerability in Litespeed Web Servers 4.0.x
|
||||||
@@ -69,6 +70,6 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #output>0 then
|
if #output>0 then
|
||||||
return stdnse.strjoin("\n", output)
|
return table.concat(output, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local io = require "io"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Exploits a directory traversal vulnerability existing in Majordomo2 to retrieve remote files. (CVE-2011-0049).
|
Exploits a directory traversal vulnerability existing in Majordomo2 to retrieve remote files. (CVE-2011-0049).
|
||||||
@@ -90,6 +91,6 @@ action = function(host, port)
|
|||||||
output_lines[#output_lines+1] = string.format("Error saving %s to %s: %s\n", rfile, filewrite, err)
|
output_lines[#output_lines+1] = string.format("Error saving %s to %s: %s\n", rfile, filewrite, err)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return stdnse.strjoin("\n", output_lines)
|
return table.concat(output_lines, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local tableaux = require "table"
|
local tableaux = require "table"
|
||||||
local rand = require "rand"
|
local rand = require "rand"
|
||||||
@@ -97,7 +98,7 @@ local function merge_headers(headers, names)
|
|||||||
for _, name in ipairs(names) do
|
for _, name in ipairs(names) do
|
||||||
name = string.lower(name)
|
name = string.lower(name)
|
||||||
if headers[name] then
|
if headers[name] then
|
||||||
for _, v in ipairs(stdnse.strsplit(",%s*", headers[name])) do
|
for _, v in ipairs(stringaux.strsplit(",%s*", headers[name])) do
|
||||||
if not seen[v] then
|
if not seen[v] then
|
||||||
result[#result + 1] = v
|
result[#result + 1] = v
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
local openssl = stdnse.silent_require "openssl"
|
local openssl = stdnse.silent_require "openssl"
|
||||||
|
|
||||||
@@ -146,12 +147,12 @@ action = function(host, port)
|
|||||||
|
|
||||||
lines = {}
|
lines = {}
|
||||||
if logo_versions then
|
if logo_versions then
|
||||||
lines[#lines + 1] = "Versions from logo query (less accurate): " .. stdnse.strjoin(", ", logo_versions)
|
lines[#lines + 1] = "Versions from logo query (less accurate): " .. table.concat(logo_versions, ", ")
|
||||||
elseif logo_hash and nmap.verbosity() >= 2 then
|
elseif logo_hash and nmap.verbosity() >= 2 then
|
||||||
lines[#lines + 1] = "Logo query returned unknown hash " .. logo_hash
|
lines[#lines + 1] = "Logo query returned unknown hash " .. logo_hash
|
||||||
end
|
end
|
||||||
if credits_versions then
|
if credits_versions then
|
||||||
lines[#lines + 1] = "Versions from credits query (more accurate): " .. stdnse.strjoin(", ", credits_versions)
|
lines[#lines + 1] = "Versions from credits query (more accurate): " .. table.concat(credits_versions, ", ")
|
||||||
elseif credits_hash and nmap.verbosity() >= 2 then
|
elseif credits_hash and nmap.verbosity() >= 2 then
|
||||||
lines[#lines + 1] = "Credits query returned unknown hash " .. credits_hash
|
lines[#lines + 1] = "Credits query returned unknown hash " .. credits_hash
|
||||||
end
|
end
|
||||||
@@ -160,6 +161,6 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if #lines > 0 then
|
if #lines > 0 then
|
||||||
return stdnse.strjoin("\n", lines)
|
return table.concat(lines, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local http = require "http"
|
|||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Sends an HTTP TRACE request and shows if the method TRACE is enabled. If debug
|
Sends an HTTP TRACE request and shows if the method TRACE is enabled. If debug
|
||||||
@@ -53,7 +54,7 @@ local validate = function(response, response_headers)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #output_lines > 0 then
|
if #output_lines > 0 then
|
||||||
return stdnse.strjoin("\n", output_lines)
|
return table.concat(output_lines, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
Enumerates usernames in Wordpress blog/CMS installations by exploiting an
|
Enumerates usernames in Wordpress blog/CMS installations by exploiting an
|
||||||
@@ -133,7 +134,7 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if filewrite and #users>0 then
|
if filewrite and #users>0 then
|
||||||
local status, err = write_file(filewrite, stdnse.strjoin("\n", users))
|
local status, err = write_file(filewrite, table.concat(users, "\n"))
|
||||||
if status then
|
if status then
|
||||||
output[#output+1] = string.format("Users saved to %s\n", filewrite)
|
output[#output+1] = string.format("Users saved to %s\n", filewrite)
|
||||||
else
|
else
|
||||||
@@ -143,6 +144,6 @@ action = function(host, port)
|
|||||||
|
|
||||||
if #output > 1 then
|
if #output > 1 then
|
||||||
output[#output+1] = string.format("Search stopped at ID #%s. Increase the upper limit if necessary with 'http-wordpress-users.limit'", limit)
|
output[#output+1] = string.format("Search stopped at ID #%s. Increase the upper limit if necessary with 'http-wordpress-users.limit'", limit)
|
||||||
return stdnse.strjoin("\n", output)
|
return table.concat(output, "\n")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local nmap = require "nmap"
|
|||||||
local match = require "match"
|
local match = require "match"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -49,7 +50,7 @@ local function parseResponse(resp)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local resp_p = { header = {}, rawheader = {} }
|
local resp_p = { header = {}, rawheader = {} }
|
||||||
local resp_tbl = stdnse.strsplit("\r?\n", resp)
|
local resp_tbl = stringaux.strsplit("\r?\n", resp)
|
||||||
|
|
||||||
if ( not(resp_tbl) or #resp_tbl == 0 ) then
|
if ( not(resp_tbl) or #resp_tbl == 0 ) then
|
||||||
stdnse.debug2("Received an invalid response from server")
|
stdnse.debug2("Received an invalid response from server")
|
||||||
@@ -91,7 +92,7 @@ action = function(host, port)
|
|||||||
return fail("Failed to connect to server")
|
return fail("Failed to connect to server")
|
||||||
end
|
end
|
||||||
|
|
||||||
local request = (stdnse.strjoin("\r\n", probe) .. "\r\n\r\n"):format(hostname, service, hostname)
|
local request = (table.concat(probe, "\r\n") .. "\r\n\r\n"):format(hostname, service, hostname)
|
||||||
|
|
||||||
if ( not(socket:send(request)) ) then
|
if ( not(socket:send(request)) ) then
|
||||||
socket:close()
|
socket:close()
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ action = function(host, port)
|
|||||||
for cap, args in pairs(capa) do
|
for cap, args in pairs(capa) do
|
||||||
table.insert(capstrings, cap)
|
table.insert(capstrings, cap)
|
||||||
end
|
end
|
||||||
return stdnse.strjoin(" ", capstrings)
|
return table.concat(capstrings, " ")
|
||||||
elseif type(capa) == "string" then
|
elseif type(capa) == "string" then
|
||||||
stdnse.debug1("'%s' for %s", capa, host.ip)
|
stdnse.debug1("'%s' for %s", capa, host.ip)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local nmap = require "nmap"
|
|||||||
local packet = require "packet"
|
local packet = require "packet"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local table = require "table"
|
||||||
local rand = require "rand"
|
local rand = require "rand"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -153,7 +154,7 @@ end
|
|||||||
|
|
||||||
local commasep = {
|
local commasep = {
|
||||||
__tostring = function (t)
|
__tostring = function (t)
|
||||||
return stdnse.strjoin(", ", t)
|
return table.concat(t, ", ")
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ local function irc_compose_message(prefix, command, ...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return stdnse.strjoin(" ", parts) .. "\r\n"
|
return table.concat(parts, " ") .. "\r\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function splitlines(s)
|
local function splitlines(s)
|
||||||
@@ -257,7 +257,7 @@ local function concat_channel_list(channels)
|
|||||||
mod[#mod + 1] = channel
|
mod[#mod + 1] = channel
|
||||||
end
|
end
|
||||||
|
|
||||||
return stdnse.strjoin(",", mod)
|
return table.concat(mod, ",")
|
||||||
end
|
end
|
||||||
|
|
||||||
function action(host, port)
|
function action(host, port)
|
||||||
@@ -308,7 +308,7 @@ function action(host, port)
|
|||||||
irc_disconnect(irc)
|
irc_disconnect(irc)
|
||||||
|
|
||||||
if errorparams then
|
if errorparams then
|
||||||
channels[#channels + 1] = "ERROR: " .. stdnse.strjoin(" ", errorparams)
|
channels[#channels + 1] = "ERROR: " .. table.concat(errorparams, " ")
|
||||||
end
|
end
|
||||||
|
|
||||||
return stdnse.format_output(true, channels)
|
return stdnse.format_output(true, channels)
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ function action(host,port)
|
|||||||
result_part.name = result_part.name .. ("; QFilter: %s"):format(qfilter)
|
result_part.name = result_part.name .. ("; QFilter: %s"):format(qfilter)
|
||||||
end
|
end
|
||||||
if ( attribs ) then
|
if ( attribs ) then
|
||||||
result_part.name = result_part.name .. ("; Attributes: %s"):format(stdnse.strjoin(",", attribs))
|
result_part.name = result_part.name .. ("; Attributes: %s"):format(table.concat(attribs, ","))
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert( result, result_part )
|
table.insert( result, result_part )
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local tab = require "tab"
|
local tab = require "tab"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
@@ -101,7 +102,7 @@ end
|
|||||||
local function parseVersion(data)
|
local function parseVersion(data)
|
||||||
local version_info = {}
|
local version_info = {}
|
||||||
if ( #data > 27 ) then
|
if ( #data > 27 ) then
|
||||||
for _, line in ipairs(stdnse.strsplit("\n", data:sub(28))) do
|
for _, line in ipairs(stringaux.strsplit("\n", data:sub(28))) do
|
||||||
local key, val = line:match("^(%S+)%s-=%s(.*)%s*$")
|
local key, val = line:match("^(%S+)%s-=%s(.*)%s*$")
|
||||||
if ( key ) then version_info[key] = val end
|
if ( key ) then version_info[key] = val end
|
||||||
end
|
end
|
||||||
@@ -115,7 +116,7 @@ end
|
|||||||
local function parseDatabases(data)
|
local function parseDatabases(data)
|
||||||
local result = tab.new(5)
|
local result = tab.new(5)
|
||||||
tab.addrow(result, "instance", "path", "version", "kernel", "state")
|
tab.addrow(result, "instance", "path", "version", "kernel", "state")
|
||||||
for _, line in ipairs(stdnse.strsplit("\n", data:sub(28))) do
|
for _, line in ipairs(stringaux.strsplit("\n", data:sub(28))) do
|
||||||
local cols = {}
|
local cols = {}
|
||||||
cols.instance, cols.path, cols.ver, cols.kernel,
|
cols.instance, cols.path, cols.ver, cols.kernel,
|
||||||
cols.state = line:match("^(.-)%s*\t(.-)%s*\t(.-)%s*\t(.-)%s-\t(.-)%s-$")
|
cols.state = line:match("^(.-)%s*\t(.-)%s*\t(.-)%s*\t(.-)%s-\t(.-)%s-$")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local http = require "http"
|
|||||||
local json = require "json"
|
local json = require "json"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
|
local table = require "table"
|
||||||
local tab = require "tab"
|
local tab = require "tab"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -112,7 +113,7 @@ local function cmdReq(host, port, url, result)
|
|||||||
|
|
||||||
if ( val ) then
|
if ( val ) then
|
||||||
local name = filter[item].name
|
local name = filter[item].name
|
||||||
val = ( "table" == type(val) and stdnse.strjoin(",", val) or val )
|
val = ( "table" == type(val) and table.concat(val, ",") or val )
|
||||||
result[item] = { name = name, value = val }
|
result[item] = { name = name, value = val }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local io = require "io"
|
|||||||
local mssql = require "mssql"
|
local mssql = require "mssql"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -123,7 +124,7 @@ action = function( host, port )
|
|||||||
local filename
|
local filename
|
||||||
if ( dir ) then
|
if ( dir ) then
|
||||||
local instance = instance:GetName():match("%\\+(.+)$") or instance:GetName()
|
local instance = instance:GetName():match("%\\+(.+)$") or instance:GetName()
|
||||||
filename = dir .. "/" .. stdnse.filename_escape(("%s_%s_ms-sql_hashes.txt"):format(host.ip, instance))
|
filename = dir .. "/" .. stringaux.filename_escape(("%s_%s_ms-sql_hashes.txt"):format(host.ip, instance))
|
||||||
saveToFile(filename, instanceOutput[1])
|
saveToFile(filename, instanceOutput[1])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ local function process_instance( instance )
|
|||||||
|
|
||||||
|
|
||||||
"INSERT INTO #hasaccess EXEC sp_MShasdbaccess",
|
"INSERT INTO #hasaccess EXEC sp_MShasdbaccess",
|
||||||
("SELECT %s dbname, owner FROM #hasaccess WHERE dbname NOT IN(%s)"):format(limit, stdnse.strjoin(",", exclude_dbs)),
|
("SELECT %s dbname, owner FROM #hasaccess WHERE dbname NOT IN(%s)"):format(limit, table.concat(exclude_dbs, ",")),
|
||||||
"DROP TABLE #hasaccess" }
|
"DROP TABLE #hasaccess" }
|
||||||
|
|
||||||
local creds = mssql.Helper.GetLoginCredentials_All( instance )
|
local creds = mssql.Helper.GetLoginCredentials_All( instance )
|
||||||
|
|||||||
@@ -143,12 +143,12 @@ local function process_instance( instance )
|
|||||||
end
|
end
|
||||||
|
|
||||||
keywords_filter = (" AND ( so.name IN (%s) or sc.name IN (%s) ) "):format(
|
keywords_filter = (" AND ( so.name IN (%s) or sc.name IN (%s) ) "):format(
|
||||||
stdnse.strjoin(",", tmp_tbl),
|
table.concat(tmp_tbl, ","),
|
||||||
stdnse.strjoin(",", tmp_tbl)
|
table.concat(tmp_tbl, ",")
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
db_query = ("SELECT %s name from master..sysdatabases WHERE name NOT IN (%s)"):format(db_limit, stdnse.strjoin(",", exclude_dbs))
|
db_query = ("SELECT %s name from master..sysdatabases WHERE name NOT IN (%s)"):format(db_limit, table.concat(exclude_dbs, ","))
|
||||||
|
|
||||||
|
|
||||||
local creds = mssql.Helper.GetLoginCredentials_All( instance )
|
local creds = mssql.Helper.GetLoginCredentials_All( instance )
|
||||||
@@ -210,7 +210,7 @@ local function process_instance( instance )
|
|||||||
if keywords_arg then
|
if keywords_arg then
|
||||||
local tmp = keywords_arg
|
local tmp = keywords_arg
|
||||||
if ( type(tmp) == 'table' ) then
|
if ( type(tmp) == 'table' ) then
|
||||||
tmp = stdnse.strjoin(',', tmp)
|
tmp = table.concat(tmp, ',')
|
||||||
end
|
end
|
||||||
table.insert(restrict_tbl, 1, ("Filter: %s"):format(tmp))
|
table.insert(restrict_tbl, 1, ("Filter: %s"):format(tmp))
|
||||||
pos = pos + 1
|
pos = pos + 1
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ action = function( host, port )
|
|||||||
|
|
||||||
table.insert(results, "")
|
table.insert(results, "")
|
||||||
table.insert(results, {name = "Additional information", ("The audit was performed using the db-account: %s"):format(username),
|
table.insert(results, {name = "Additional information", ("The audit was performed using the db-account: %s"):format(username),
|
||||||
("The following admin accounts were excluded from the audit: %s"):format(stdnse.strjoin(",", ADMIN_ACCOUNTS))
|
("The following admin accounts were excluded from the audit: %s"):format(table.concat(ADMIN_ACCOUNTS, ","))
|
||||||
})
|
})
|
||||||
|
|
||||||
return stdnse.format_output(true, { results })
|
return stdnse.format_output(true, { results })
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -93,7 +94,7 @@ local function format_acl(acl)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local payload = string.sub(acl, 9) --skip header
|
local payload = string.sub(acl, 9) --skip header
|
||||||
local fields = stdnse.strsplit("|", payload)
|
local fields = stringaux.strsplit("|", payload)
|
||||||
table.remove(fields, (# fields))
|
table.remove(fields, (# fields))
|
||||||
return fields
|
return fields
|
||||||
end
|
end
|
||||||
@@ -103,7 +104,7 @@ local function format_apps(apps)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local payload = string.sub(apps, 10) --skip header
|
local payload = string.sub(apps, 10) --skip header
|
||||||
local fields = stdnse.strsplit("|", payload)
|
local fields = stringaux.strsplit("|", payload)
|
||||||
table.remove(fields, (# fields))
|
table.remove(fields, (# fields))
|
||||||
return fields
|
return fields
|
||||||
end
|
end
|
||||||
@@ -113,7 +114,7 @@ local function format_info(info)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local payload = string.sub(info, 6) --skip header
|
local payload = string.sub(info, 6) --skip header
|
||||||
local fields = stdnse.strsplit("|", payload)
|
local fields = stringaux.strsplit("|", payload)
|
||||||
return fields
|
return fields
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ local function format_setup(setup)
|
|||||||
if setup == nil then
|
if setup == nil then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local fields = stdnse.strsplit(";", setup)
|
local fields = stringaux.strsplit(";", setup)
|
||||||
if # fields < 7 then
|
if # fields < 7 then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@@ -139,7 +140,7 @@ local function format_volume(volume)
|
|||||||
if volume == nil then
|
if volume == nil then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local fields = stdnse.strsplit(";", volume)
|
local fields = stringaux.strsplit(";", volume)
|
||||||
if # fields < 4 then
|
if # fields < 4 then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for _, v in ipairs( mounts ) do
|
for _, v in ipairs( mounts ) do
|
||||||
local entry = v.name .. " " .. stdnse.strjoin(" ", v)
|
local entry = v.name .. " " .. table.concat(v, " ")
|
||||||
table.insert( result, entry )
|
table.insert( result, entry )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local io = require "io"
|
local io = require "io"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
@@ -147,7 +148,7 @@ end
|
|||||||
|
|
||||||
action = function( host, port )
|
action = function( host, port )
|
||||||
-- Oftentimes the LPAR will be one of the subdomain of a system.
|
-- Oftentimes the LPAR will be one of the subdomain of a system.
|
||||||
local names = host.name and stdnse.strsplit("%.", host.name) or {}
|
local names = host.name and stringaux.strsplit("%.", host.name) or {}
|
||||||
local o_host = stdnse.get_script_args('nje-node-brute.ohost') or nil
|
local o_host = stdnse.get_script_args('nje-node-brute.ohost') or nil
|
||||||
local options = {}
|
local options = {}
|
||||||
if o_host then options = { ohost = o_host:upper() } end
|
if o_host then options = { ohost = o_host:upper() } end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local tab = require "tab"
|
local tab = require "tab"
|
||||||
|
|
||||||
-- -*- mode: lua -*-
|
-- -*- mode: lua -*-
|
||||||
@@ -195,7 +196,7 @@ action = function(host, port)
|
|||||||
-- Get script arguments.
|
-- Get script arguments.
|
||||||
local cmds = stdnse.get_script_args("nrpe-enum.cmds")
|
local cmds = stdnse.get_script_args("nrpe-enum.cmds")
|
||||||
if cmds then
|
if cmds then
|
||||||
cmds = stdnse.strsplit(":", cmds)
|
cmds = stringaux.strsplit(":", cmds)
|
||||||
else
|
else
|
||||||
cmds = NRPE_COMMANDS
|
cmds = NRPE_COMMANDS
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ action = function(host, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if target.ALLOW_NEW_TARGETS and targets ~= nil then
|
if target.ALLOW_NEW_TARGETS and targets ~= nil then
|
||||||
stdnse.debug1("adding new targets %s", stdnse.strjoin(", ", targets))
|
stdnse.debug1("adding new targets %s", table.concat(targets, ", "))
|
||||||
target.add(table.unpack(targets))
|
target.add(table.unpack(targets))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -44,7 +45,7 @@ portrule = shortport.version_port_or_service(5850, "openlookup")
|
|||||||
|
|
||||||
-- parses a Netstring element
|
-- parses a Netstring element
|
||||||
local function parsechunk(data)
|
local function parsechunk(data)
|
||||||
local parts = stdnse.strsplit(":", data)
|
local parts = stringaux.strsplit(":", data)
|
||||||
if #parts < 2 then
|
if #parts < 2 then
|
||||||
return nil, data
|
return nil, data
|
||||||
end
|
end
|
||||||
@@ -53,7 +54,7 @@ local function parsechunk(data)
|
|||||||
if not size then
|
if not size then
|
||||||
return nil, data
|
return nil, data
|
||||||
end
|
end
|
||||||
local body = stdnse.strjoin(":", parts)
|
local body = table.concat(parts, ":")
|
||||||
if #body < size then
|
if #body < size then
|
||||||
return nil, data
|
return nil, data
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local stdnse = require "stdnse"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local comm = require "comm"
|
local comm = require "comm"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local table = require "table"
|
local table = require "table"
|
||||||
|
|
||||||
description = [[
|
description = [[
|
||||||
@@ -189,7 +190,7 @@ local function format_dimensions(res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
local values = {}
|
local values = {}
|
||||||
for counter, val in ipairs(stdnse.strsplit("%.%s*", res["Date and Time"])) do
|
for counter, val in ipairs(stringaux.strsplit("%.%s*", res["Date and Time"])) do
|
||||||
values[ params[counter] ] = val
|
values[ params[counter] ] = val
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -217,7 +218,7 @@ local function format_dimensions(res)
|
|||||||
"d", "h", "m", "s"
|
"d", "h", "m", "s"
|
||||||
}
|
}
|
||||||
|
|
||||||
for counter, v in ipairs(stdnse.strsplit("%.%s*", res["Uptime"])) do
|
for counter, v in ipairs(stringaux.strsplit("%.%s*", res["Uptime"])) do
|
||||||
table.insert(t, v .. units[counter])
|
table.insert(t, v .. units[counter])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ local nmap = require "nmap"
|
|||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
local stdnse = require "stdnse"
|
local stdnse = require "stdnse"
|
||||||
local string = require "string"
|
local string = require "string"
|
||||||
|
local stringaux = require "stringaux"
|
||||||
local tns = require "tns"
|
local tns = require "tns"
|
||||||
local unpwdb = require "unpwdb"
|
local unpwdb = require "unpwdb"
|
||||||
|
|
||||||
@@ -190,7 +191,7 @@ action = function(host, port)
|
|||||||
|
|
||||||
engine.iterator = brute.Iterators.credential_iterator(f)
|
engine.iterator = brute.Iterators.credential_iterator(f)
|
||||||
elseif( "accounts" == mode ) then
|
elseif( "accounts" == mode ) then
|
||||||
engine.iterator = unpwdb.table_iterator(stdnse.strsplit(",%s*", arg_accounts))
|
engine.iterator = unpwdb.table_iterator(stringaux.strsplit(",%s*", arg_accounts))
|
||||||
end
|
end
|
||||||
|
|
||||||
engine.options.useraspass = false
|
engine.options.useraspass = false
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user