From 0500811f5ae53036c5e99a92dc97a5e37dbcc9ff Mon Sep 17 00:00:00 2001 From: dmiller Date: Thu, 18 Oct 2018 01:08:19 +0000 Subject: [PATCH] Move string utility functions to stringaux.lua --- CHANGELOG | 3 + docs/scripting.xml | 2 +- nselib/afp.lua | 17 ++- nselib/bjnp.lua | 3 +- nselib/coap.lua | 3 +- nselib/creds.lua | 3 +- nselib/cvs.lua | 15 +- nselib/data/mysql-cis.audit | 2 +- nselib/data/packetdecoders.lua | 9 +- nselib/dhcp6.lua | 10 +- nselib/dns.lua | 5 +- nselib/dnsbl.lua | 3 +- nselib/dnssd.lua | 5 +- nselib/http.lua | 26 +--- nselib/httpspider.lua | 2 +- nselib/informix.lua | 3 +- nselib/ipOps.lua | 3 +- nselib/iscsi.lua | 5 +- nselib/ldap.lua | 5 +- nselib/msrpc.lua | 4 +- nselib/msrpctypes.lua | 5 +- nselib/mssql.lua | 8 +- nselib/pop3.lua | 5 +- nselib/proxy.lua | 3 +- nselib/rtsp.lua | 17 +-- nselib/sip.lua | 26 ++-- nselib/smtp.lua | 3 +- nselib/ssh1.lua | 3 +- nselib/stdnse.lua | 124 ---------------- nselib/stringaux.lua | 139 ++++++++++++++++++ nselib/tls.lua | 3 +- nselib/vulns.lua | 13 +- scripts/address-info.nse | 2 +- scripts/ajp-methods.nse | 7 +- scripts/ajp-request.nse | 3 +- scripts/broadcast-dropbox-listener.nse | 5 +- scripts/broadcast-hid-discoveryd.nse | 3 +- scripts/broadcast-igmp-discovery.nse | 3 +- scripts/broadcast-novell-locate.nse | 3 +- scripts/cics-enum.nse | 5 +- scripts/cics-info.nse | 3 +- scripts/cics-user-brute.nse | 5 +- scripts/cics-user-enum.nse | 5 +- scripts/citrix-enum-apps-xml.nse | 8 +- scripts/coap-resources.nse | 3 +- scripts/dhcp-discover.nse | 2 +- scripts/dict-info.nse | 2 +- scripts/dns-brute.nse | 3 +- scripts/dns-cache-snoop.nse | 3 +- scripts/dns-check-zone.nse | 12 +- scripts/dns-nsec-enum.nse | 5 +- scripts/dns-nsec3-enum.nse | 5 +- scripts/dns-zeustracker.nse | 3 +- scripts/dns-zone-transfer.nse | 3 +- scripts/domcon-cmd.nse | 5 +- scripts/domino-enum-users.nse | 3 +- scripts/firewalk.nse | 2 +- scripts/ftp-vuln-cve2010-4221.nse | 3 +- scripts/gkrellm-info.nse | 7 +- scripts/gopher-ls.nse | 5 +- scripts/hddtemp-info.nse | 3 +- scripts/hostmap-bfk.nse | 6 +- scripts/hostmap-crtsh.nse | 5 +- scripts/hostmap-ip2hosts.nse | 8 +- scripts/http-auth-finder.nse | 2 +- scripts/http-awstatstotals-exec.nse | 2 +- scripts/http-axis2-dir-traversal.nse | 2 +- scripts/http-cakephp-version.nse | 9 +- scripts/http-cors.nse | 11 +- scripts/http-cross-domain-policy.nse | 4 +- scripts/http-domino-enum-passwords.nse | 5 +- scripts/http-fetch.nse | 3 +- scripts/http-generator.nse | 10 +- scripts/http-google-malware.nse | 3 +- scripts/http-iis-webdav-vuln.nse | 3 +- .../http-litespeed-sourcecode-download.nse | 3 +- scripts/http-majordomo2-dir-traversal.nse | 3 +- scripts/http-methods.nse | 3 +- scripts/http-php-version.nse | 7 +- scripts/http-trace.nse | 3 +- scripts/http-wordpress-users.nse | 5 +- scripts/icap-info.nse | 5 +- scripts/imap-capabilities.nse | 2 +- scripts/ipv6-node-info.nse | 3 +- scripts/irc-botnet-channels.nse | 6 +- scripts/ldap-search.nse | 2 +- scripts/maxdb-info.nse | 5 +- scripts/membase-http-info.nse | 3 +- scripts/ms-sql-dump-hashes.nse | 3 +- scripts/ms-sql-hasdbaccess.nse | 2 +- scripts/ms-sql-tables.nse | 8 +- scripts/mysql-audit.nse | 2 +- scripts/netbus-info.nse | 11 +- scripts/nfs-showmount.nse | 2 +- scripts/nje-node-brute.nse | 3 +- scripts/nrpe-enum.nse | 3 +- scripts/omp2-enum-targets.nse | 2 +- scripts/openlookup-info.nse | 5 +- scripts/openwebnet-discovery.nse | 5 +- scripts/oracle-brute-stealth.nse | 3 +- scripts/pop3-capabilities.nse | 4 +- scripts/quake3-info.nse | 11 +- scripts/quake3-master-getservers.nse | 9 +- scripts/redis-info.nse | 9 +- scripts/rfc868-time.nse | 3 +- scripts/rpcinfo.nse | 2 +- scripts/rtsp-methods.nse | 3 +- scripts/servicetags.nse | 3 +- scripts/sip-methods.nse | 3 +- scripts/smb-brute.nse | 5 +- scripts/smb-enum-domains.nse | 6 +- scripts/smb-enum-processes.nse | 2 +- scripts/smb-enum-users.nse | 4 +- scripts/smb-ls.nse | 3 +- scripts/smb-mbenum.nse | 2 +- scripts/smb-os-discovery.nse | 2 +- scripts/smb-psexec.nse | 9 +- scripts/smtp-commands.nse | 2 +- scripts/smtp-open-relay.nse | 2 +- scripts/smtp-vuln-cve2010-4344.nse | 3 +- scripts/smtp-vuln-cve2011-1720.nse | 5 +- scripts/snmp-ios-config.nse | 3 +- scripts/ssh-hostkey.nse | 3 +- scripts/ssh2-enum-algos.nse | 3 +- scripts/ssl-cert-intaddr.nse | 3 +- scripts/ssl-cert.nse | 9 +- scripts/stuxnet-detect.nse | 3 +- scripts/svn-brute.nse | 3 +- scripts/targets-asn.nse | 3 +- scripts/targets-ipv6-map4to6.nse | 3 +- scripts/targets-ipv6-wordlist.nse | 3 +- scripts/targets-sniffer.nse | 4 +- scripts/tftp-enum.nse | 3 +- scripts/tn3270-screen.nse | 3 +- scripts/tso-brute.nse | 7 +- scripts/tso-enum.nse | 7 +- scripts/url-snarf.nse | 5 +- scripts/vtam-enum.nse | 3 +- scripts/whois-ip.nse | 5 +- scripts/xmlrpc-methods.nse | 4 +- 140 files changed, 521 insertions(+), 418 deletions(-) create mode 100644 nselib/stringaux.lua diff --git a/CHANGELOG b/CHANGELOG index 68b5577b5..c6f643bb5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ #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 server responds with 200 status to a POST request to any URI. [Francesco Soncina] diff --git a/docs/scripting.xml b/docs/scripting.xml index 641a04ca0..949a22913 100644 --- a/docs/scripting.xml +++ b/docs/scripting.xml @@ -2357,7 +2357,7 @@ output.users[#output.users + 1] = "root" output.users[#output.users + 1] = "foo" output.users[#output.users + 1] = "bar" 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 then the normal output would appear as follows: diff --git a/nselib/afp.lua b/nselib/afp.lua index 4f84e42c7..7f3113ad8 100644 --- a/nselib/afp.lua +++ b/nselib/afp.lua @@ -117,6 +117,7 @@ local nmap = require "nmap" local os = require "os" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" _ENV = stdnse.module("afp", stdnse.seeall); @@ -1404,7 +1405,7 @@ Helper = { -- @return item table containing node information DirectoryId and DirectoryName WalkDirTree = function( self, str_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 d_bm = DIR_BITMAP.NodeId + DIR_BITMAP.ParentDirId + DIR_BITMAP.LongName local item = { DirectoryId = 2 } @@ -1822,7 +1823,7 @@ Util = -- @param str_path string containing the path to split -- @return dir table containing dir and file SplitPath = function( str_path ) - local elements = stdnse.strsplit("/", str_path) + local elements = stringaux.strsplit("/", str_path) local dir, file = "", "" if #elements < 2 then @@ -1832,7 +1833,7 @@ Util = file = elements[#elements] table.remove( elements, #elements ) - dir = stdnse.strjoin( "/", elements ) + dir = table.concat( elements, "/" ) return { ['dir']=dir, ['file']=file } @@ -1888,13 +1889,13 @@ Util = local acls_tbl = {} - table.insert( acls_tbl, string.format( "Owner: %s", stdnse.strjoin(",", owner) ) ) - table.insert( acls_tbl, string.format( "Group: %s", stdnse.strjoin(",", group) ) ) - table.insert( acls_tbl, string.format( "Everyone: %s", stdnse.strjoin(",", everyone) ) ) - table.insert( acls_tbl, string.format( "User: %s", stdnse.strjoin(",", user) ) ) + table.insert( acls_tbl, string.format( "Owner: %s", table.concat(owner, ",") ) ) + table.insert( acls_tbl, string.format( "Group: %s", table.concat(group, ",") ) ) + table.insert( acls_tbl, string.format( "Everyone: %s", table.concat(everyone, ",") ) ) + table.insert( acls_tbl, string.format( "User: %s", table.concat(user, ",") ) ) 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 return acls_tbl diff --git a/nselib/bjnp.lua b/nselib/bjnp.lua index f1d7e6477..0922d8d3f 100644 --- a/nselib/bjnp.lua +++ b/nselib/bjnp.lua @@ -13,6 +13,7 @@ local os = require("os") local stdnse = require("stdnse") local table = require("table") local string = require "string" +local stringaux = require "stringaux" _ENV = stdnse.module("bjnp", stdnse.seeall) @@ -325,7 +326,7 @@ Helper = { end 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("^([^:]*):(.*)$") if ( nm ) then kvps[nm] = val end end diff --git a/nselib/coap.lua b/nselib/coap.lua index 49e0fc508..978146ffe 100644 --- a/nselib/coap.lua +++ b/nselib/coap.lua @@ -5,6 +5,7 @@ local math = require "math" local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local unittest = require "unittest" @@ -2082,7 +2083,7 @@ Helper = { end assert(options.uri) - local components = stdnse.strsplit("/", options.uri) + local components = stringaux.strsplit("/", options.uri) for _, component in ipairs(components) do if component ~= "" then table.insert(options.options, {["name"] = "uri_path", ["value"] = component}) diff --git a/nselib/creds.lua b/nselib/creds.lua index 116070656..7a3a55526 100644 --- a/nselib/creds.lua +++ b/nselib/creds.lua @@ -119,6 +119,7 @@ local io = require "io" local ipOps = require "ipOps" local nmap = require "nmap" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" local tableaux = require "tableaux" _ENV = stdnse.module("creds", stdnse.seeall) @@ -413,7 +414,7 @@ Credentials = { 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 not, we only have a user with an empty password local user, pass diff --git a/nselib/cvs.lua b/nselib/cvs.lua index d767778f0..d6cb72b2e 100644 --- a/nselib/cvs.lua +++ b/nselib/cvs.lua @@ -31,7 +31,6 @@ Helper = { end, login = function(self, repo, user, pass ) - local auth_tab = {} assert(repo, "No repository was specified") assert(user, "No user was specified") assert(pass, "No pass was specified") @@ -39,13 +38,15 @@ Helper = { -- Add a leading slash if it's missing if ( repo:sub(1,1) ~= "/" ) then repo = "/" .. repo end - table.insert(auth_tab, "BEGIN AUTH REQUEST") - table.insert(auth_tab, repo) - table.insert(auth_tab, user) - table.insert(auth_tab, Util.pwscramble(pass)) - table.insert(auth_tab, "END AUTH REQUEST") + local auth_tab = { + "BEGIN AUTH REQUEST", + repo, + user, + 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) if ( not(status) ) then return false, "Failed to send login request" end diff --git a/nselib/data/mysql-cis.audit b/nselib/data/mysql-cis.audit index cf049b23c..7542bf734 100644 --- a/nselib/data/mysql-cis.audit +++ b/nselib/data/mysql-cis.audit @@ -37,7 +37,7 @@ end local function createINstmt(tab) local tab2 = {} for i=1, #tab do tab2[i] = ("'%s'"):format(tab[i]) end - return stdnse.strjoin(",", tab2) + return table.concat(tab2, ",") end diff --git a/nselib/data/packetdecoders.lua b/nselib/data/packetdecoders.lua index 5ab27d45c..5fd8144a8 100644 --- a/nselib/data/packetdecoders.lua +++ b/nselib/data/packetdecoders.lua @@ -2,6 +2,7 @@ local ipOps = require "ipOps" local packet = require "packet" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local tab = require "tab" local table = require "table" local target = require "target" @@ -356,7 +357,7 @@ udp = { for _, v in ipairs(options) do if ( v.name == name ) then if ( type(v.value) == "table" ) then - return stdnse.strjoin(", ", v.value) + return table.concat(v.value, ", ") else return v.value end @@ -597,7 +598,7 @@ udp = { local p = packet.Packet:new( layer3, #layer3 ) 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 local st = "" if ( h:match("^ST:.*") ) then @@ -713,9 +714,9 @@ udp = { info.displayname, p.ip_src, info.port, - stdnse.strjoin(".", info.version), + table.concat(info.version, "."), info.host_int, - stdnse.strjoin(", ", info.namespaces) + table.concat(info.namespaces, ", ") ) self.dups[p.ip_src] = true if ( target.ALLOW_NEW_TARGETS ) then target.add(p.ip_src) end diff --git a/nselib/dhcp6.lua b/nselib/dhcp6.lua index 26f833059..cba464360 100644 --- a/nselib/dhcp6.lua +++ b/nselib/dhcp6.lua @@ -267,7 +267,7 @@ DHCP6.Option = { table.insert(domain, part) end until( part == "" ) - table.insert(opt.domains, stdnse.strjoin(".", domain)) + table.insert(opt.domains, table.concat(domain, ".")) until( pos > #data ) return opt end, @@ -419,7 +419,7 @@ DHCP6.Option = { tmp, pos = string.unpack("s1", data, pos) table.insert(pieces, tmp) until(pos >= #data) - opt.fqdn = stdnse.strjoin(".", pieces) + opt.fqdn = table.concat(pieces, ".") return opt end, @@ -549,11 +549,11 @@ OptionToString = { local ipv6 = ipOps.str_to_ip(srv) table.insert(servers, ipv6) end - return "DNS Servers", stdnse.strjoin(",", servers) + return "DNS Servers", table.concat(servers, ",") end, [DHCP6.OptionTypes.OPTION_DOMAIN_LIST] = function(opt) - return "Domain Search", stdnse.strjoin(", ", opt.domains) + return "Domain Search", table.concat(opt.domains, ", ") end, [DHCP6.OptionTypes.OPTION_STATUS_CODE] = function(opt) @@ -561,7 +561,7 @@ OptionToString = { end, [DHCP6.OptionTypes.OPTION_SNTP_SERVERS] = function(opt) - return "NTP Servers", stdnse.strjoin(", ", opt.servers) + return "NTP Servers", table.concat(opt.servers, ", ") end, } diff --git a/nselib/dns.lua b/nselib/dns.lua index 8ae3edc66..566176a57 100644 --- a/nselib/dns.lua +++ b/nselib/dns.lua @@ -35,6 +35,7 @@ local ipOps = require "ipOps" local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local base32 = require "base32" local unittest = require "unittest" @@ -413,7 +414,7 @@ function reverse(ip) delim = ":" arpa = ".ip6.arpa" end - local ipParts = stdnse.strsplit(delim, ip) + local ipParts = stringaux.strsplit(delim, ip) if #ipParts == 8 then -- padding local mask = "0000" @@ -590,7 +591,7 @@ answerFetcher[types.NSEC] = function(dec, retAll) return false, "No Answers" end 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 if not retAll then return true, answers[1] end return true, answers diff --git a/nselib/dnsbl.lua b/nselib/dnsbl.lua index 3d6ecba78..b55179905 100644 --- a/nselib/dnsbl.lua +++ b/nselib/dnsbl.lua @@ -23,6 +23,7 @@ local dns = require "dns" local ipOps = require "ipOps" local nmap = require "nmap" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" _ENV = stdnse.module("dnsbl", stdnse.seeall) @@ -504,7 +505,7 @@ Helper = { local all = SERVICES[self.category] 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 self.filter = nil return false, ("Service does not exist '%s'"):format(f) diff --git a/nselib/dnssd.lua b/nselib/dnssd.lua index 678d70362..b4aadcc6e 100644 --- a/nselib/dnssd.lua +++ b/nselib/dnssd.lua @@ -43,6 +43,7 @@ local ipOps = require "ipOps" local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local target = require "target" _ENV = stdnse.module("dnssd", stdnse.seeall) @@ -235,7 +236,7 @@ Comm = { status, srv = Comm.getRecordType( dns.types.SRV, response, false ) if status then - local srvparams = stdnse.strsplit( ":", srv ) + local srvparams = stringaux.strsplit( ":", srv ) if #srvparams > 3 then port = srvparams[3] @@ -251,7 +252,7 @@ Comm = { deviceinfo = service table.insert(result, deviceinfo) else - local serviceparams = stdnse.strsplit("[.]", record) + local serviceparams = stringaux.strsplit("[.]", record) if #serviceparams > 2 then local servicename = serviceparams[1]:sub(2) diff --git a/nselib/http.lua b/nselib/http.lua index 2dba6a491..4b602dc61 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -121,6 +121,7 @@ local shortport = require "shortport" local slaxml = require "slaxml" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local tableaux = require "tableaux" local url = require "url" @@ -689,7 +690,7 @@ local function parse_header(header, response) local s, e response.header = {} - response.rawheader = stdnse.strsplit("\r?\n", header) + response.rawheader = stringaux.strsplit("\r?\n", header) pos = 1 while pos <= #header do -- Get the field name. @@ -867,7 +868,7 @@ local function getPipelineMax(response) if response then 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 response.version >= "1.1" or tableaux.contains(opts, "keep-alive") then 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 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 --- 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 -- @return A pattern to find the tag function tag_pattern(tag, endtag) - local patt = {} if endtag then - patt[1] = "].->" else - patt[1] = "<%s*" + return "<%s*" .. stringaux.ipattern(tag) .. "%f[%s/>].->" 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 --- @@ -2768,9 +2758,9 @@ function save_path(host, port, path, status, links_to, linked_from, contenttype) -- Split up the query, if necessary if(parsed['raw_querystring']) then parsed['querystring'] = {} - local values = stdnse.strsplit('&', parsed['raw_querystring']) + local values = stringaux.strsplit('&', parsed['raw_querystring']) 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 end end diff --git a/nselib/httpspider.lua b/nselib/httpspider.lua index b392e6f33..a2b219b94 100644 --- a/nselib/httpspider.lua +++ b/nselib/httpspider.lua @@ -1034,7 +1034,7 @@ Crawler = { end if ( #limits > 0 ) then - return ("Spidering limited to: %s"):format(stdnse.strjoin("; ", limits)) + return ("Spidering limited to: %s"):format(table.concat(limits, "; ")) end end, diff --git a/nselib/informix.lua b/nselib/informix.lua index d91d1fbd3..30b1eef90 100644 --- a/nselib/informix.lua +++ b/nselib/informix.lua @@ -75,6 +75,7 @@ local nmap = require "nmap" local match = require "match" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" _ENV = stdnse.module("informix", stdnse.seeall) @@ -1288,7 +1289,7 @@ Helper = { local result = {} if ( type(query) == "string" ) then - query = stdnse.strsplit(";%s*", query) + query = stringaux.strsplit(";%s*", query) end for _, q in ipairs( query ) do diff --git a/nselib/ipOps.lua b/nselib/ipOps.lua index d7cb6b529..0feef1a58 100644 --- a/nselib/ipOps.lua +++ b/nselib/ipOps.lua @@ -6,6 +6,7 @@ local math = require "math" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local type = type local ipairs = ipairs @@ -386,7 +387,7 @@ expand_ip = function( ip, family ) if hexadectets[#hexadectets]:match( "[%.]+" ) then hexadectets[#hexadectets], err = expand_ip( hexadectets[#hexadectets] ) 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 t[i] = tonumber( v, 10 ) end diff --git a/nselib/iscsi.lua b/nselib/iscsi.lua index 6b7747438..56d64b97d 100644 --- a/nselib/iscsi.lua +++ b/nselib/iscsi.lua @@ -40,6 +40,7 @@ local nmap = require "nmap" local stdnse = require "stdnse" local openssl = stdnse.silent_require "openssl" local string = require "string" +local stringaux = require "stringaux" local table = require "table" _ENV = stdnse.module("iscsi", stdnse.seeall) @@ -219,7 +220,7 @@ Packet = { end 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("(.*)=(.*)") if ( v ) then resp.kvp:add( k, v ) end end @@ -320,7 +321,7 @@ Packet = { resp.records = {} - local kvps = stdnse.strsplit( "\0", textdata ) + local kvps = stringaux.strsplit( "\0", textdata ) local record -- Each target record starts with one text key of the form: diff --git a/nselib/ldap.lua b/nselib/ldap.lua index f7eaf9a0f..8d46757b2 100644 --- a/nselib/ldap.lua +++ b/nselib/ldap.lua @@ -25,6 +25,7 @@ local nmap = require "nmap" local os = require "os" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local comm = require "comm" _ENV = stdnse.module("ldap", stdnse.seeall) @@ -544,7 +545,7 @@ function createFilter( filter ) local val = '' if ( filter.op == FILTER['substrings'] ) then - local tmptable = stdnse.strsplit('*', filter.val) + local tmptable = stringaux.strsplit('*', filter.val) local tmp_result = '' if (#tmptable <= 1 ) then @@ -577,7 +578,7 @@ function createFilter( filter ) elseif ( filter.op == FILTER['extensibleMatch'] ) then - local tmptable = stdnse.strsplit(':=', filter.val) + local tmptable = stringaux.strsplit(':=', filter.val) local tmp_result = '' local OID, bitmask diff --git a/nselib/msrpc.lua b/nselib/msrpc.lua index bc25c2414..08a6365dc 100644 --- a/nselib/msrpc.lua +++ b/nselib/msrpc.lua @@ -2165,7 +2165,7 @@ function lsa_lookupnames2(smbstate, policy_handle, names) local result 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, @@ -2256,7 +2256,7 @@ function lsa_lookupsids2(smbstate, policy_handle, sids) local result 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, arguments = msrpctypes.marshall_policy_handle(policy_handle) diff --git a/nselib/msrpctypes.lua b/nselib/msrpctypes.lua index 462feacaf..9e3e4544b 100644 --- a/nselib/msrpctypes.lua +++ b/nselib/msrpctypes.lua @@ -106,6 +106,7 @@ local os = require "os" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local unicode = require "unicode" _ENV = stdnse.module("msrpctypes", stdnse.seeall) @@ -1295,7 +1296,7 @@ local function marshall_Enum32(val, table) local result = 0 stdnse.debug4("MSRPC: Entering marshall_Enum32()") - local vals = stdnse.strsplit("|", val) + local vals = stringaux.strsplit("|", val) local i for i = 1, #vals, 1 do @@ -1381,7 +1382,7 @@ local function marshall_Enum8(val, table, pad) local result = 0 stdnse.debug4("MSRPC: Entering marshall_Enum8()") - local vals = stdnse.strsplit("|", val) + local vals = stringaux.strsplit("|", val) local i for i = 1, #vals, 1 do diff --git a/nselib/mssql.lua b/nselib/mssql.lua index 9d186f16e..9fe6fbd6f 100644 --- a/nselib/mssql.lua +++ b/nselib/mssql.lua @@ -585,7 +585,7 @@ SSRP = table.insert( instanceStrings, instanceString ) 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 = {} for _, instanceString in ipairs( instanceStrings ) do @@ -1980,7 +1980,7 @@ TDSStream = { local status, result, connectionType, errorMessage 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 if connectionType == "TCP" then @@ -3162,14 +3162,14 @@ Util = for k, v in pairs( tbl.colinfo ) do table.insert( col_names, v.text) end - headers = stdnse.strjoin("\t", col_names) + headers = table.concat(col_names, "\t") table.insert( new_tbl, headers) headers = headers:gsub("[^%s]", "=") table.insert( new_tbl, headers ) end for _, v in ipairs( tbl.rows ) do - table.insert( new_tbl, stdnse.strjoin("\t", v) ) + table.insert( new_tbl, table.concat(v, "\t") ) end return new_tbl diff --git a/nselib/pop3.lua b/nselib/pop3.lua index b92148ae1..d025fa885 100644 --- a/nselib/pop3.lua +++ b/nselib/pop3.lua @@ -8,6 +8,7 @@ local comm = require "comm" local match = require "match" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" _ENV = stdnse.module("pop3", stdnse.seeall) @@ -170,7 +171,7 @@ function capabilities(host, port) end socket:close() - local lines = stdnse.strsplit("\r\n",line) + local lines = stringaux.strsplit("\r\n",line) if not stat(table.remove(lines,1)) then capas.capa = false return capas @@ -181,7 +182,7 @@ function capabilities(host, port) local capability = line:sub(line:find("[%w-]+")) line = line:sub(#capability + 2) if ( line ~= "" ) then - capas[capability] = stdnse.strsplit(" ", line) + capas[capability] = stringaux.strsplit(" ", line) else capas[capability] = {} end diff --git a/nselib/proxy.lua b/nselib/proxy.lua index d2180e3f8..ef2a56657 100644 --- a/nselib/proxy.lua +++ b/nselib/proxy.lua @@ -12,6 +12,7 @@ local ipOps = require "ipOps" local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" _ENV = stdnse.module("proxy", stdnse.seeall) @@ -39,7 +40,7 @@ end --@param pattern The pattern to be searched --@return true if pattern is found, otherwise false 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 if line:lower():match(pattern:lower()) then return true end end diff --git a/nselib/rtsp.lua b/nselib/rtsp.lua index 6606ebf93..7186eb5a8 100644 --- a/nselib/rtsp.lua +++ b/nselib/rtsp.lua @@ -36,6 +36,7 @@ local nmap = require "nmap" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" _ENV = stdnse.module("rtsp", stdnse.seeall) @@ -77,15 +78,13 @@ Request = { assert(self.cseq, "Request is missing required header CSeq") 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), - ("CSeq: %d"):format(self.cseq) - } ) .. "\r\n" - if ( #self.headers > 0 ) then - req = req .. stdnse.strjoin("\r\n", self.headers) .. "\r\n" - end - - return req .. "\r\n" + ("CSeq: %d"):format(self.cseq), + table.unpack(self.headers), + "" + } + return table.concat(req, "\r\n") end, } @@ -102,7 +101,7 @@ Response = { } -- 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 -- we should have atleast one entry diff --git a/nselib/sip.lua b/nselib/sip.lua index 84b1e06f0..370ade1f6 100644 --- a/nselib/sip.lua +++ b/nselib/sip.lua @@ -39,6 +39,7 @@ local os = require "os" local stdnse = require "stdnse" local openssl = stdnse.silent_require "openssl" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local rand = require "rand" _ENV = stdnse.module("sip", stdnse.seeall) @@ -219,16 +220,17 @@ Session = { request:setUri(uri) request:setSessionData(self.sessdata) - local data = {} - table.insert(data, "v=0") - table.insert(data, ("o=- %s %s IN IP4 %s"):format(tm, tm, lhost)) - table.insert(data, "s=-") - table.insert(data, ("c=IN IP4 %s"):format(lhost)) - table.insert(data, "t=0 0") - table.insert(data, "m=audio 49174 RTP/AVP 0") - table.insert(data, "a=rtpmap:0 PCMU/8000") + local data = { + "v=0", + ("o=- %s %s IN IP4 %s"):format(tm, tm, lhost), + "s=-", + ("c=IN IP4 %s"):format(lhost), + "t=0 0", + "m=audio 49174 RTP/AVP 0", + "a=rtpmap:0 PCMU/8000", + } - request:setContent(stdnse.strjoin("\r\n", data)) + request:setContent(table.concat(data, "\r\n")) request:setContentType("application/sdp") local status, response = self:exch(request) @@ -452,7 +454,7 @@ Response = { local o = {} setmetatable(o, self) self.__index = self - o.tbl = stdnse.strsplit("\r\n", str) + o.tbl = stringaux.strsplit("\r\n", str) return o end, @@ -577,7 +579,7 @@ Request = { --- Sets the allow header -- @name Request.setAllow -- @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 -- @name Request.setContent @@ -728,7 +730,7 @@ Request = { table.insert(data, ("Content-Length: %d"):format(self.length)) table.insert(data, "") end - return stdnse.strjoin("\r\n", data) + return table.concat(data, "\r\n") end, } diff --git a/nselib/smtp.lua b/nselib/smtp.lua index c0fc8e0f3..f0d3fbaf6 100644 --- a/nselib/smtp.lua +++ b/nselib/smtp.lua @@ -10,6 +10,7 @@ local comm = require "comm" local sasl = require "sasl" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" _ENV = stdnse.module("smtp", stdnse.seeall) @@ -196,7 +197,7 @@ end get_auth_mech = function(response) 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(.*)$") if authstr then for mech in authstr:gmatch("[^%s]+") do diff --git a/nselib/ssh1.lua b/nselib/ssh1.lua index f72463bc4..34803b48d 100644 --- a/nselib/ssh1.lua +++ b/nselib/ssh1.lua @@ -12,6 +12,7 @@ local nmap = require "nmap" local os = require "os" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local openssl = stdnse.silent_require "openssl" _ENV = stdnse.module("ssh1", stdnse.seeall) @@ -253,7 +254,7 @@ parse_known_hosts_file = function(path) for l in io.lines(knownhostspath) do lnumber = lnumber + 1 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}) end end diff --git a/nselib/stdnse.lua b/nselib/stdnse.lua index 5de07880f..9897b04a4 100644 --- a/nselib/stdnse.lua +++ b/nselib/stdnse.lua @@ -186,47 +186,6 @@ print_verbose = function(level, fmt, ...) end end ---- Join a list of strings with a separator string. --- --- This is Lua's table.concat 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 -- chunks separated by a pattern. -- @@ -478,28 +437,6 @@ local function format_get_indent(indent) return rep(" ", #indent) 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). local function format_output_sub(status, data, indent) if (#data == 0) then @@ -1071,42 +1008,6 @@ function pretty_printer (obj, printer) return aux(obj, "") 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 a-z and A-Z --- * digits 0-9 --- * . _ - --- In addition, the strings "." and ".." have --- their characters escaped. --- --- Bytes are escaped by a percent sign followed by the two-digit --- hexadecimal representation of the byte value. --- * filename_escape("filename.ext") --> "filename.ext" --- * filename_escape("input/output") --> "input%2foutput" --- * filename_escape(".") --> "%2e" --- * filename_escape("..") --> "%2e%2e" --- This escaping is somewhat like that of JavaScript --- encodeURIComponent, 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 -- -- If the host parameter is a NSE host table with a times.timeout @@ -1143,29 +1044,4 @@ function get_timeout(host, max_timeout, min_timeout) return t 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; diff --git a/nselib/stringaux.lua b/nselib/stringaux.lua new file mode 100644 index 000000000..797473f14 --- /dev/null +++ b/nselib/stringaux.lua @@ -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 table.concat 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 a-z and A-Z +-- * digits 0-9 +-- * . _ - +-- In addition, the strings "." and ".." have +-- their characters escaped. +-- +-- Bytes are escaped by a percent sign followed by the two-digit +-- hexadecimal representation of the byte value. +-- * filename_escape("filename.ext") --> "filename.ext" +-- * filename_escape("input/output") --> "input%2foutput" +-- * filename_escape(".") --> "%2e" +-- * filename_escape("..") --> "%2e%2e" +-- This escaping is somewhat like that of JavaScript +-- encodeURIComponent, 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 diff --git a/nselib/tls.lua b/nselib/tls.lua index 9c0124272..e57a87f1e 100644 --- a/nselib/tls.lua +++ b/nselib/tls.lua @@ -11,6 +11,7 @@ local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local math = require "math" local os = require "os" local table = require "table" @@ -1073,7 +1074,7 @@ function cipher_info (c) local info = cipher_info_cache[c] if info then return info end info = {} - local tokens = stdnse.strsplit("_", c) + local tokens = stringaux.strsplit("_", c) local i = 1 if tokens[i] ~= "TLS" and tokens[i] ~= "SSL" then stdnse.debug2("cipher_info: Not a TLS ciphersuite: %s", c) diff --git a/nselib/vulns.lua b/nselib/vulns.lua index 3cc8da462..09bf0319a 100644 --- a/nselib/vulns.lua +++ b/nselib/vulns.lua @@ -192,6 +192,7 @@ local ipOps = require "ipOps" local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local type = type local next = next @@ -1776,14 +1777,14 @@ local format_vuln_special_fields = function(vuln_field) if vuln_field then if type(vuln_field) == "table" then for _, line in ipairs(vuln_field) do - if type(line) == "string" then - tadd(out, stdnse.strsplit("\r?\n", line)) - else - insert(out, line) - end + if type(line) == "string" then + tadd(out, stringaux.strsplit("\r?\n", line)) + else + insert(out, line) + end end elseif type(vuln_field) == "string" then - out = stdnse.strsplit("\r?\n", vuln_field) + out = stringaux.strsplit("\r?\n", vuln_field) end end return next(out) and out or nil diff --git a/scripts/address-info.nse b/scripts/address-info.nse index 6118487dc..e0f07289d 100644 --- a/scripts/address-info.nse +++ b/scripts/address-info.nse @@ -170,7 +170,7 @@ local function format_ipv4(ipv4) octets[#octets + 1] = string.format("%d", v) end - return stdnse.strjoin(".", octets) + return table.concat(octets, ".") end local function do_ipv4(addr) diff --git a/scripts/ajp-methods.nse b/scripts/ajp-methods.nse index 703c32921..121df5be7 100644 --- a/scripts/ajp-methods.nse +++ b/scripts/ajp-methods.nse @@ -1,6 +1,7 @@ local ajp = require "ajp" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = 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" end - local methods = stdnse.strsplit(",%s", response.headers['allow']) + local methods = stringaux.strsplit(",%s", response.headers['allow']) 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) 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") end return stdnse.format_output(true, output) diff --git a/scripts/ajp-request.nse b/scripts/ajp-request.nse index 29ffd526c..42eea5822 100644 --- a/scripts/ajp-request.nse +++ b/scripts/ajp-request.nse @@ -2,6 +2,7 @@ local ajp = require "ajp" local io = require "io" local shortport = require "shortport" local stdnse = require "stdnse" +local table = require "table" description = [[ Requests a URI over the Apache JServ Protocol and displays the result @@ -84,7 +85,7 @@ action = function(host, port) if ( response ) then local output = response.status_line .. "\n" .. - stdnse.strjoin("\n", response.rawheaders) .. + table.concat(response.rawheaders, "\n") .. (response.body and "\n\n" .. response.body or "") if ( arg_file ) then local f = io.open(arg_file, "w") diff --git a/scripts/broadcast-dropbox-listener.nse b/scripts/broadcast-dropbox-listener.nse index c7fb4f617..914453961 100644 --- a/scripts/broadcast-dropbox-listener.nse +++ b/scripts/broadcast-dropbox-listener.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local stdnse = require "stdnse" local tab = require "tab" local target = require "target" +local table = require "table" description = [[ Listens for the LAN sync information broadcasts that the Dropbox.com client @@ -113,9 +114,9 @@ action = function() info.displayname, ip, info.port, - stdnse.strjoin(".", info.version), + table.concat(info.version, "."), info.host_int, - stdnse.strjoin(", ", info.namespaces) + table.concat(info.namespaces, ", ") ) stdnse.debug1("Added host %s.", info.displayname) diff --git a/scripts/broadcast-hid-discoveryd.nse b/scripts/broadcast-hid-discoveryd.nse index 8bab09550..ed7ce7a60 100644 --- a/scripts/broadcast-hid-discoveryd.nse +++ b/scripts/broadcast-hid-discoveryd.nse @@ -1,6 +1,7 @@ local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local target = require "target" local os = require "os" local table = require "table" @@ -66,7 +67,7 @@ action = function() local hid_pkt = data:match("^discovered;.*$") if ( hid_pkt ) then 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 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( diff --git a/scripts/broadcast-igmp-discovery.nse b/scripts/broadcast-igmp-discovery.nse index 26b23afcf..9359ee5a4 100644 --- a/scripts/broadcast-igmp-discovery.nse +++ b/scripts/broadcast-igmp-discovery.nse @@ -6,6 +6,7 @@ local ipOps = require "ipOps" local target = require "target" local coroutine = require "coroutine" local string = require "string" +local stringaux = require "stringaux" local io = require "io" description = [[ @@ -276,7 +277,7 @@ local mgroup_names_fetch = function(filename) end 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 file:close() diff --git a/scripts/broadcast-novell-locate.nse b/scripts/broadcast-novell-locate.nse index 09354bc39..610c37649 100644 --- a/scripts/broadcast-novell-locate.nse +++ b/scripts/broadcast-novell-locate.nse @@ -1,6 +1,7 @@ local ipOps = require "ipOps" local srvloc = require "srvloc" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -46,7 +47,7 @@ function action() attrib = attrib:match("^%(svcaddr%-ws=(.*)%)$") if ( not(attrib) ) then return end - local attribs = stdnse.strsplit(",", attrib) + local attribs = stringaux.strsplit(",", attrib) if ( not(attribs) ) then return end local addrs = { name = "Addresses"} diff --git a/scripts/cics-enum.nse b/scripts/cics-enum.nse index e4a05c4d9..b9866cb4e 100644 --- a/scripts/cics-enum.nse +++ b/scripts/cics-enum.nse @@ -8,6 +8,7 @@ local unpwdb = require "unpwdb" local io = require "io" local table = require "table" local string = require "string" +local stringaux = require "stringaux" description = [[ @@ -115,7 +116,7 @@ Driver = { local loop = 1 local err, status stdnse.debug(2,"Getting to CICS") - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) self.tn3270:send_cursor(run[i]) @@ -271,7 +272,7 @@ local function cics_test( host, port, commands, user, pass ) end tn:get_screen_debug(2) -- prints TN3270 screen to debug stdnse.debug("Getting to CICS") - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) tn:send_cursor(run[i]) diff --git a/scripts/cics-info.nse b/scripts/cics-info.nse index 905c82a83..f9c1144df 100644 --- a/scripts/cics-info.nse +++ b/scripts/cics-info.nse @@ -1,6 +1,7 @@ local nmap = require "nmap" local stdnse = require "stdnse" local shortport = require "shortport" +local stringaux = require "stringaux" local tn3270 = require "tn3270" local table = require "table" @@ -104,7 +105,7 @@ local function cics_info( host, port, commands, user, pass, cemt, trans ) end tn:get_screen_debug(2) -- prints TN3270 screen to debug stdnse.debug("Getting to CICS") - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) tn:send_cursor(run[i]) diff --git a/scripts/cics-user-brute.nse b/scripts/cics-user-brute.nse index 2e824419e..49a617504 100644 --- a/scripts/cics-user-brute.nse +++ b/scripts/cics-user-brute.nse @@ -1,5 +1,6 @@ local nmap = require "nmap" local string = require "string" +local stringaux = require "stringaux" local stdnse = require "stdnse" local shortport = require "shortport" local tn3270 = require "tn3270" @@ -83,7 +84,7 @@ Driver = { local loop = 1 local err stdnse.debug(2,"Getting to CICS") - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) self.tn3270:send_cursor(run[i]) @@ -201,7 +202,7 @@ local function cics_test( host, port, commands ) end tn:get_screen_debug(2) -- prints TN3270 screen to debug stdnse.debug(2,"Getting to CICS") - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) tn:send_cursor(run[i]) diff --git a/scripts/cics-user-enum.nse b/scripts/cics-user-enum.nse index c4be3995b..e8917de4a 100644 --- a/scripts/cics-user-enum.nse +++ b/scripts/cics-user-enum.nse @@ -5,6 +5,7 @@ local brute = require "brute" local creds = require "creds" local unpwdb = require "unpwdb" local string = require "string" +local stringaux = require "stringaux" description = [[ CICS User ID enumeration script for the CESL/CESN Login screen. @@ -79,7 +80,7 @@ Driver = { local loop = 1 local err stdnse.debug(2,"Getting to CICS") - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) self.tn3270:send_cursor(run[i]) @@ -165,7 +166,7 @@ local function cics_test( host, port, commands, transaction ) end tn:get_screen_debug(2) -- prints TN3270 screen to debug stdnse.debug("Getting to CICS") - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) tn:send_cursor(run[i]) diff --git a/scripts/citrix-enum-apps-xml.nse b/scripts/citrix-enum-apps-xml.nse index 52af47001..f5fab283c 100644 --- a/scripts/citrix-enum-apps-xml.nse +++ b/scripts/citrix-enum-apps-xml.nse @@ -93,11 +93,11 @@ function format_output(appdata, mode) if AppData.AccessList then if AppData.AccessList.User then - line = line .. "; Users: " .. stdnse.strjoin(", ", AppData.AccessList.User) + line = line .. "; Users: " .. table.concat(AppData.AccessList.User, ", ") end if AppData.AccessList.Group then - line = line .. "; Groups: " .. stdnse.strjoin(", ", AppData.AccessList.Group) + line = line .. "; Groups: " .. table.concat(AppData.AccessList.Group, ", ") end table.insert(result, line) @@ -123,11 +123,11 @@ function format_output(appdata, mode) if AppData.AccessList 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 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 table.insert(result, result_part) diff --git a/scripts/coap-resources.nse b/scripts/coap-resources.nse index c600bca7f..9009def6d 100644 --- a/scripts/coap-resources.nse +++ b/scripts/coap-resources.nse @@ -1,6 +1,7 @@ local coap = require "coap" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" 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 if component ~= "" then table.insert(opts.options, {["name"] = "uri_path", ["value"] = component}) diff --git a/scripts/dhcp-discover.nse b/scripts/dhcp-discover.nse index cc5b6eb22..ac825d519 100644 --- a/scripts/dhcp-discover.nse +++ b/scripts/dhcp-discover.nse @@ -103,7 +103,7 @@ local function go(host, port) -- Decide which type of request to make local request_type = dhcp.request_types[nmap.registry.args.dhcptype or "DHCPINFORM"] 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 -- Generate the MAC address, if it's random diff --git a/scripts/dict-info.nse b/scripts/dict-info.nse index 5dfbb40f9..73aaabe7f 100644 --- a/scripts/dict-info.nse +++ b/scripts/dict-info.nse @@ -52,7 +52,7 @@ action = function(host, port) '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") end diff --git a/scripts/dns-brute.nse b/scripts/dns-brute.nse index 1caac448e..b556aaef6 100644 --- a/scripts/dns-brute.nse +++ b/scripts/dns-brute.nse @@ -5,6 +5,7 @@ local math = require "math" local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local target = require "target" local rand = require "rand" @@ -159,7 +160,7 @@ local function srv_main(domainname, srvresults, srv_iter) if(res) then for _,addr in ipairs(res) do local hostn = name..'.'..domainname - addr = stdnse.strsplit(":",addr) + addr = stringaux.strsplit(":",addr) for _, dtype in ipairs({"A", "AAAA"}) do local srvres = resolve(addr[4], dtype) if(srvres) then diff --git a/scripts/dns-cache-snoop.nse b/scripts/dns-cache-snoop.nse index 56c2c946f..14fcb58ed 100644 --- a/scripts/dns-cache-snoop.nse +++ b/scripts/dns-cache-snoop.nse @@ -4,6 +4,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local table = require "table" description = [[ Performs DNS cache snooping against a DNS server. @@ -228,5 +229,5 @@ action = function(host, port) nmap.set_port_state(host, port, "open") 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 diff --git a/scripts/dns-check-zone.nse b/scripts/dns-check-zone.nse index 7fe56092e..043caca7c 100644 --- a/scripts/dns-check-zone.nse +++ b/scripts/dns-check-zone.nse @@ -91,7 +91,7 @@ local dns_checks = { local output = "None of the servers allow recursive queries." 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 } end return true, { status = Status.PASS, output = output } @@ -139,7 +139,7 @@ local dns_checks = { local output = "All DNS IPs were public" 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 else status = Status.PASS @@ -167,7 +167,7 @@ local dns_checks = { local output = "All servers respond to DNS queries" 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 } end return true, { status = Status.PASS, output = output } @@ -213,7 +213,7 @@ local dns_checks = { end 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 } end @@ -261,7 +261,7 @@ local dns_checks = { end 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 } end @@ -418,7 +418,7 @@ local dns_checks = { local output = "All MX records have PTR records" 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 } end return true, { status = Status.PASS, output = output } diff --git a/scripts/dns-nsec-enum.nse b/scripts/dns-nsec-enum.nse index 36ce39b28..505e219a1 100644 --- a/scripts/dns-nsec-enum.nse +++ b/scripts/dns-nsec-enum.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local tableaux = require "tableaux" @@ -83,11 +84,11 @@ local function remove_empty(t) end local function split(domain) - return stdnse.strsplit("%.", domain) + return stringaux.strsplit("%.", domain) end local function join(components) - return stdnse.strjoin(".", remove_empty(components)) + return table.concat(remove_empty(components, ".")) end -- Remove the first component of a domain name. Return nil if the number of diff --git a/scripts/dns-nsec3-enum.nse b/scripts/dns-nsec3-enum.nse index a13bc243a..669356bb7 100644 --- a/scripts/dns-nsec3-enum.nse +++ b/scripts/dns-nsec3-enum.nse @@ -4,6 +4,7 @@ local dns = require "dns" local base32 = require "base32" local nmap = require "nmap" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local tableaux = require "table" local rand = require "rand" @@ -103,11 +104,11 @@ local function remove_empty(t) end local function split(domain) - return stdnse.strsplit("%.", domain) + return stringaux.strsplit("%.", domain) end local function join(components) - return stdnse.strjoin(".", remove_empty(components)) + return table.concat(remove_empty(components, ".")) end -- Remove the first component of a domain name. Return nil if the number of diff --git a/scripts/dns-zeustracker.nse b/scripts/dns-zeustracker.nse index 1e19a9658..c53a4e886 100644 --- a/scripts/dns-zeustracker.nse +++ b/scripts/dns-zeustracker.nse @@ -1,6 +1,7 @@ local dns = require "dns" local ipOps = require "ipOps" local stdnse = require "stdnse" +local stringaux = require "stringaux" local tab = require "tab" local table = require "table" @@ -52,7 +53,7 @@ action = function(host) "Files Online", "Date added") for _, record in ipairs(result) do 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" tab.addrow(output, name, ip, sbl, asn, country, status, level, files_online, dateadded) end diff --git a/scripts/dns-zone-transfer.nse b/scripts/dns-zone-transfer.nse index 96587ff51..14810ea83 100644 --- a/scripts/dns-zone-transfer.nse +++ b/scripts/dns-zone-transfer.nse @@ -6,6 +6,7 @@ local shortport = require "shortport" local stdnse = require "stdnse" local strbuf = require "strbuf" local string = require "string" +local stringaux = require "stringaux" local tab = require "tab" local table = require "table" local target = require "target" @@ -218,7 +219,7 @@ function build_domain(host) buf = strbuf.new() abs_name = {} - names = stdnse.strsplit('%.', host) + names = stringaux.strsplit('%.', host) if names == nil then names = {host} end -- try to determine root of domain name diff --git a/scripts/domcon-cmd.nse b/scripts/domcon-cmd.nse index cdae66598..9cbfbfb34 100644 --- a/scripts/domcon-cmd.nse +++ b/scripts/domcon-cmd.nse @@ -1,6 +1,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -75,7 +76,7 @@ local function readAPIBlock( socket ) local status, line = socket:receive_lines(1) 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 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(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) local status = socket:connect( host, port ) diff --git a/scripts/domino-enum-users.nse b/scripts/domino-enum-users.nse index 84027de94..62a54ab4e 100644 --- a/scripts/domino-enum-users.nse +++ b/scripts/domino-enum-users.nse @@ -2,6 +2,7 @@ local io = require "io" local nrpc = require "nrpc" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" local unpwdb = require "unpwdb" @@ -103,7 +104,7 @@ action = function(host, port) helper:disconnect() 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 ) if ( status ) then diff --git a/scripts/firewalk.nse b/scripts/firewalk.nse index 698291bfa..31b4d31eb 100644 --- a/scripts/firewalk.nse +++ b/scripts/firewalk.nse @@ -788,7 +788,7 @@ local function portrange(ports) end -- ranges are delimited by `,' - return stdnse.strjoin(",", strrange) + return table.concat(strrange, ",") end diff --git a/scripts/ftp-vuln-cve2010-4221.nse b/scripts/ftp-vuln-cve2010-4221.nse index c3cbb7447..82f054d04 100644 --- a/scripts/ftp-vuln-cve2010-4221.nse +++ b/scripts/ftp-vuln-cve2010-4221.nse @@ -2,6 +2,7 @@ local ftp = require "ftp" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local vulns = require "vulns" description = [[ @@ -74,7 +75,7 @@ end -- Returns true if the provided version is vulnerable local function is_version_vulnerable(version) - local vers = stdnse.strsplit("%.", version) + local vers = stringaux.strsplit("%.", version) if #vers > 0 and vers[3] then local relnum = string.sub(vers[3], 1, 1) diff --git a/scripts/gkrellm-info.nse b/scripts/gkrellm-info.nse index d6dc3959c..5ebc028bc 100644 --- a/scripts/gkrellm-info.nse +++ b/scripts/gkrellm-info.nse @@ -4,6 +4,7 @@ local match = require "match" local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" local tab = require "tab" local table = require "table" @@ -91,7 +92,7 @@ local function decodeTag(tag, lines) tab.addrow(fs_tab, "Mount point", "Fs type", "Size", "Available") for _, line in ipairs(lines) do 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 size = ("%dM"):format(math.ceil(tonumber(size) * 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 return ("%s: %s"):format(long_names[tag], datetime.format_time(lines[1] * 60)) 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 return end @@ -124,7 +125,7 @@ local function decodeTag(tag, lines) total = math.ceil(tonumber(total)/1048576) return ("%s: Total %dM, Free %dM"):format(long_names[tag], total, free) 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 return end diff --git a/scripts/gopher-ls.nse b/scripts/gopher-ls.nse index 07c521a63..70ae90c38 100644 --- a/scripts/gopher-ls.nse +++ b/scripts/gopher-ls.nse @@ -2,6 +2,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -70,7 +71,7 @@ action = function( host, port ) while line ~= nil do if #line > 1 then 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 local label = fields[1] local filename = fields[2] @@ -86,6 +87,6 @@ action = function( host, port ) end line = buffer() end - return "\n" .. stdnse.strjoin("\n", files) + return "\n" .. table.concat(files, "\n") end diff --git a/scripts/hddtemp-info.nse b/scripts/hddtemp-info.nse index ec867b41a..9025ab473 100644 --- a/scripts/hddtemp-info.nse +++ b/scripts/hddtemp-info.nse @@ -3,6 +3,7 @@ local math = require "math" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -51,7 +52,7 @@ action = function( host, port ) return end local separator = string.sub(data, 1, 1) - local fields = stdnse.strsplit(separator, data) + local fields = stringaux.strsplit(separator, data) local info = {} local disks = math.floor((# fields) / 5) for i = 0, (disks - 1) do diff --git a/scripts/hostmap-bfk.nse b/scripts/hostmap-bfk.nse index e66702660..f28a8ae37 100644 --- a/scripts/hostmap-bfk.nse +++ b/scripts/hostmap-bfk.nse @@ -3,6 +3,8 @@ local io = require "io" local ipOps = require "ipOps" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" +local table = require "table" local target = require "target" description = [[ @@ -101,11 +103,11 @@ action = function(host) return nil end 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") 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") if status then output_tab.filename = filename diff --git a/scripts/hostmap-crtsh.nse b/scripts/hostmap-crtsh.nse index d10ef92fb..dd520d462 100644 --- a/scripts/hostmap-crtsh.nse +++ b/scripts/hostmap-crtsh.nse @@ -48,6 +48,7 @@ local io = require "io" local http = require "http" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local target = require "target" local table = require "table" local tableaux = require "table" @@ -106,8 +107,8 @@ action = function(host) output_tab.subdomains = hostnames --write to file if filename_prefix then - local filename = filename_prefix .. stdnse.filename_escape(get_hostname(host)) - hostnames_str = stdnse.strjoin("\n", hostnames) + local filename = filename_prefix .. stringaux.filename_escape(get_hostname(host)) + hostnames_str = table.concat(hostnames, "\n") local status, err = write_file(filename, hostnames_str) if status then diff --git a/scripts/hostmap-ip2hosts.nse b/scripts/hostmap-ip2hosts.nse index 55c7301b4..12e43ff52 100644 --- a/scripts/hostmap-ip2hosts.nse +++ b/scripts/hostmap-ip2hosts.nse @@ -49,6 +49,8 @@ local io = require "io" local http = require "http" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" +local table = require "table" local target = require "target" local HOSTMAP_BING_SERVER = "www.ip2hosts.com" @@ -69,7 +71,7 @@ local function query_bing(ip) if not response.status then return string.format("Error: could not GET http://%s%s", HOSTMAP_BING_SERVER, query) end - entries = stdnse.strsplit(",", response.body); + entries = stringaux.strsplit(",", response.body); for _, entry in pairs(entries) do if not hostnames[entry] and entry ~= "" then if target.ALLOW_NEW_TARGETS then @@ -100,8 +102,8 @@ action = function(host) output_tab.hosts = hostnames --write to file if filename_prefix then - local filename = filename_prefix .. stdnse.filename_escape(host.targetname or host.ip) - hostnames_str = stdnse.strjoin("\n", hostnames) + local filename = filename_prefix .. stringaux.filename_escape(host.targetname or host.ip) + hostnames_str = table.concat(hostnames, "\n") local status, err = write_file(filename, hostnames_str) if status then output_tab.filename = filename diff --git a/scripts/http-auth-finder.nse b/scripts/http-auth-finder.nse index 9bc9a7f5f..a46a5443c 100644 --- a/scripts/http-auth-finder.nse +++ b/scripts/http-auth-finder.nse @@ -97,7 +97,7 @@ action = function(host, port) table.insert(schemes, item.scheme) 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 tab.addrow(auth_urls, r.url, ("HTTP: %s"):format(auth)) end diff --git a/scripts/http-awstatstotals-exec.nse b/scripts/http-awstatstotals-exec.nse index 7c1e73d1c..ad4397ce9 100644 --- a/scripts/http-awstatstotals-exec.nse +++ b/scripts/http-awstatstotals-exec.nse @@ -131,6 +131,6 @@ action = function(host, port) --output if #output>0 then - return stdnse.strjoin("\n", output) + return table.concat(output, "\n") end end diff --git a/scripts/http-axis2-dir-traversal.nse b/scripts/http-axis2-dir-traversal.nse index 1fac104b6..1826207e4 100644 --- a/scripts/http-axis2-dir-traversal.nse +++ b/scripts/http-axis2-dir-traversal.nse @@ -192,6 +192,6 @@ action = function(host, port) end if #output > 0 then - return stdnse.strjoin("\n", output) + return table.concat(output, "\n") end end diff --git a/scripts/http-cakephp-version.nse b/scripts/http-cakephp-version.nse index be8e3029e..0e0db5f84 100644 --- a/scripts/http-cakephp-version.nse +++ b/scripts/http-cakephp-version.nse @@ -34,6 +34,7 @@ local http = require "http" local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local table = require "table" local openssl = stdnse.silent_require "openssl" @@ -96,17 +97,17 @@ action = function(host, port) -- Prepare output output_lines = {} 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 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 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 output_lines[#output_lines + 1] = "Default stylesheet has an unknown hash: " .. stylesheet_hash end if #output_lines > 0 then - return stdnse.strjoin("\n", output_lines) + return table.concat(output_lines, "\n") end end diff --git a/scripts/http-cors.nse b/scripts/http-cors.nse index 835e360fa..11493b962 100644 --- a/scripts/http-cors.nse +++ b/scripts/http-cors.nse @@ -2,6 +2,7 @@ local http = require "http" local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -48,7 +49,7 @@ local function origin_ok(raw, origin) if raw == "null" then return false end - local allowed = stdnse.strsplit(" ", raw) + local allowed = stringaux.strsplit(" ", raw) for _, ao in ipairs(allowed) do if origin == ao then return true @@ -61,9 +62,9 @@ local function method_ok(raw, method) if not raw then return false end - local stuff = stdnse.strsplit(" ", raw) - local nospace = stdnse.strjoin("", stuff) - local allowed = stdnse.strsplit(",", nospace) + local stuff = stringaux.strsplit(" ", raw) + local nospace = table.concat(stuff, "") + local allowed = stringaux.strsplit(",", nospace) for _, am in ipairs(allowed) do if method == am then return true @@ -95,6 +96,6 @@ action = function(host, port) end end if #allowed > 0 then - return stdnse.strjoin(" ", allowed) + return table.concat(allowed, " ") end end diff --git a/scripts/http-cross-domain-policy.nse b/scripts/http-cross-domain-policy.nse index 8a9deac2c..88cb8bef3 100644 --- a/scripts/http-cross-domain-policy.nse +++ b/scripts/http-cross-domain-policy.nse @@ -291,13 +291,13 @@ Forgery attacks, and may allow third parties to access sensitive data meant for tostring(content[i]) end 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 vuln.extra_info = vuln.extra_info .. "Use the script argument 'domain-lookup' to find trusted domains available for purchase" end if lookup ~= nil and #domains_available>0 then 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 diff --git a/scripts/http-domino-enum-passwords.nse b/scripts/http-domino-enum-passwords.nse index 5543a577a..0f9973ed4 100644 --- a/scripts/http-domino-enum-passwords.nse +++ b/scripts/http-domino-enum-passwords.nse @@ -4,6 +4,7 @@ local io = require "io" local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -184,7 +185,7 @@ local function getUserDetails( body ) -- Remove the parenthesis around the password http_passwd = http_passwd:sub(2,-2) -- 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] 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 }) 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 ) if ( status ) then table.insert( id_files, ("%s ID File has been downloaded (%s)"):format(u_details.fullname, filename) ) diff --git a/scripts/http-fetch.nse b/scripts/http-fetch.nse index 8ae686657..d90d5d245 100644 --- a/scripts/http-fetch.nse +++ b/scripts/http-fetch.nse @@ -6,6 +6,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" 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 file_path = file_path .. "index.html" 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 diff --git a/scripts/http-generator.nse b/scripts/http-generator.nse index f1645c873..8c6e292a3 100644 --- a/scripts/http-generator.nse +++ b/scripts/http-generator.nse @@ -2,6 +2,7 @@ local http = require "http" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" description = [[ 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 -- Worst case: - local pattern = '' - - -- Make pattern case-insensitive - pattern = pattern:gsub("%a", function (c) - return string.format("[%s%s]", string.lower(c), - string.upper(c)) - end) - + local pattern = stringaux.ipattern('') response = http.get(host, port, path, {redirect_ok=redirects}) if ( response and response.body ) then return response.body:match(pattern) diff --git a/scripts/http-google-malware.nse b/scripts/http-google-malware.nse index 8b0f203f8..7006fd656 100644 --- a/scripts/http-google-malware.nse +++ b/scripts/http-google-malware.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local table = require "table" description = [[ Checks if hosts are on Google's blacklist of suspected malware and phishing @@ -103,6 +104,6 @@ action = function(host, port) end if #output_lns > 0 then - return stdnse.strjoin("\n", output_lns) + return table.concat(output_lns, "\n") end end diff --git a/scripts/http-iis-webdav-vuln.nse b/scripts/http-iis-webdav-vuln.nse index a8edda983..7b851193d 100644 --- a/scripts/http-iis-webdav-vuln.nse +++ b/scripts/http-iis-webdav-vuln.nse @@ -4,6 +4,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local table = require "table" description = [[ 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=" or nil end else - return "WebDAV is ENABLED. Vulnerable folders discovered: " .. stdnse.strjoin(", ", results) + return "WebDAV is ENABLED. Vulnerable folders discovered: " .. table.concat(results, ", ") end end end diff --git a/scripts/http-litespeed-sourcecode-download.nse b/scripts/http-litespeed-sourcecode-download.nse index c8487edeb..e21c5ae52 100644 --- a/scripts/http-litespeed-sourcecode-download.nse +++ b/scripts/http-litespeed-sourcecode-download.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local table = require "table" description = [[ Exploits a null-byte poisoning vulnerability in Litespeed Web Servers 4.0.x @@ -69,6 +70,6 @@ action = function(host, port) end if #output>0 then - return stdnse.strjoin("\n", output) + return table.concat(output, "\n") end end diff --git a/scripts/http-majordomo2-dir-traversal.nse b/scripts/http-majordomo2-dir-traversal.nse index 165efa6e8..2254ee826 100644 --- a/scripts/http-majordomo2-dir-traversal.nse +++ b/scripts/http-majordomo2-dir-traversal.nse @@ -3,6 +3,7 @@ local io = require "io" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local table = require "table" description = [[ 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) end end - return stdnse.strjoin("\n", output_lines) + return table.concat(output_lines, "\n") end end diff --git a/scripts/http-methods.nse b/scripts/http-methods.nse index 55bd679ee..923a6a61f 100644 --- a/scripts/http-methods.nse +++ b/scripts/http-methods.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local tableaux = require "table" local rand = require "rand" @@ -97,7 +98,7 @@ local function merge_headers(headers, names) for _, name in ipairs(names) do name = string.lower(name) 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 result[#result + 1] = v end diff --git a/scripts/http-php-version.nse b/scripts/http-php-version.nse index 0d00605a6..c1767ee43 100644 --- a/scripts/http-php-version.nse +++ b/scripts/http-php-version.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local table = require "table" local openssl = stdnse.silent_require "openssl" @@ -146,12 +147,12 @@ action = function(host, port) lines = {} 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 lines[#lines + 1] = "Logo query returned unknown hash " .. logo_hash end 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 lines[#lines + 1] = "Credits query returned unknown hash " .. credits_hash end @@ -160,6 +161,6 @@ action = function(host, port) end if #lines > 0 then - return stdnse.strjoin("\n", lines) + return table.concat(lines, "\n") end end diff --git a/scripts/http-trace.nse b/scripts/http-trace.nse index af2b098ef..42967b30a 100644 --- a/scripts/http-trace.nse +++ b/scripts/http-trace.nse @@ -2,6 +2,7 @@ local http = require "http" local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local table = require "table" description = [[ 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 if #output_lines > 0 then - return stdnse.strjoin("\n", output_lines) + return table.concat(output_lines, "\n") end end diff --git a/scripts/http-wordpress-users.nse b/scripts/http-wordpress-users.nse index 42fb7b3ca..1f6a5e748 100644 --- a/scripts/http-wordpress-users.nse +++ b/scripts/http-wordpress-users.nse @@ -4,6 +4,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local table = require "table" description = [[ Enumerates usernames in Wordpress blog/CMS installations by exploiting an @@ -133,7 +134,7 @@ action = function(host, port) end 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 output[#output+1] = string.format("Users saved to %s\n", filewrite) else @@ -143,6 +144,6 @@ action = function(host, port) 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) - return stdnse.strjoin("\n", output) + return table.concat(output, "\n") end end diff --git a/scripts/icap-info.nse b/scripts/icap-info.nse index 501171602..11c9e7ee5 100644 --- a/scripts/icap-info.nse +++ b/scripts/icap-info.nse @@ -2,6 +2,7 @@ local nmap = require "nmap" local match = require "match" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -49,7 +50,7 @@ local function parseResponse(resp) end 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 stdnse.debug2("Received an invalid response from server") @@ -91,7 +92,7 @@ action = function(host, port) return fail("Failed to connect to server") 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 socket:close() diff --git a/scripts/imap-capabilities.nse b/scripts/imap-capabilities.nse index 53d3a0af7..b7d3798e0 100644 --- a/scripts/imap-capabilities.nse +++ b/scripts/imap-capabilities.nse @@ -43,7 +43,7 @@ action = function(host, port) for cap, args in pairs(capa) do table.insert(capstrings, cap) end - return stdnse.strjoin(" ", capstrings) + return table.concat(capstrings, " ") elseif type(capa) == "string" then stdnse.debug1("'%s' for %s", capa, host.ip) return diff --git a/scripts/ipv6-node-info.nse b/scripts/ipv6-node-info.nse index ebc4dccfe..89311a996 100644 --- a/scripts/ipv6-node-info.nse +++ b/scripts/ipv6-node-info.nse @@ -4,6 +4,7 @@ local nmap = require "nmap" local packet = require "packet" local stdnse = require "stdnse" local string = require "string" +local table = require "table" local rand = require "rand" description = [[ @@ -153,7 +154,7 @@ end local commasep = { __tostring = function (t) - return stdnse.strjoin(", ", t) + return table.concat(t, ", ") end } diff --git a/scripts/irc-botnet-channels.nse b/scripts/irc-botnet-channels.nse index a56c83ed4..73da1f291 100644 --- a/scripts/irc-botnet-channels.nse +++ b/scripts/irc-botnet-channels.nse @@ -158,7 +158,7 @@ local function irc_compose_message(prefix, command, ...) end end - return stdnse.strjoin(" ", parts) .. "\r\n" + return table.concat(parts, " ") .. "\r\n" end local function splitlines(s) @@ -257,7 +257,7 @@ local function concat_channel_list(channels) mod[#mod + 1] = channel end - return stdnse.strjoin(",", mod) + return table.concat(mod, ",") end function action(host, port) @@ -308,7 +308,7 @@ function action(host, port) irc_disconnect(irc) if errorparams then - channels[#channels + 1] = "ERROR: " .. stdnse.strjoin(" ", errorparams) + channels[#channels + 1] = "ERROR: " .. table.concat(errorparams, " ") end return stdnse.format_output(true, channels) diff --git a/scripts/ldap-search.nse b/scripts/ldap-search.nse index f5de4d215..612e33fc9 100644 --- a/scripts/ldap-search.nse +++ b/scripts/ldap-search.nse @@ -280,7 +280,7 @@ function action(host,port) result_part.name = result_part.name .. ("; QFilter: %s"):format(qfilter) end 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 table.insert( result, result_part ) diff --git a/scripts/maxdb-info.nse b/scripts/maxdb-info.nse index ab6832b7f..50d375a80 100644 --- a/scripts/maxdb-info.nse +++ b/scripts/maxdb-info.nse @@ -2,6 +2,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local tab = require "tab" local table = require "table" @@ -101,7 +102,7 @@ end local function parseVersion(data) local version_info = {} 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*$") if ( key ) then version_info[key] = val end end @@ -115,7 +116,7 @@ end local function parseDatabases(data) local result = tab.new(5) 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 = {} cols.instance, cols.path, cols.ver, cols.kernel, cols.state = line:match("^(.-)%s*\t(.-)%s*\t(.-)%s*\t(.-)%s-\t(.-)%s-$") diff --git a/scripts/membase-http-info.nse b/scripts/membase-http-info.nse index 16398adf2..107acab22 100644 --- a/scripts/membase-http-info.nse +++ b/scripts/membase-http-info.nse @@ -3,6 +3,7 @@ local http = require "http" local json = require "json" local shortport = require "shortport" local stdnse = require "stdnse" +local table = require "table" local tab = require "tab" description = [[ @@ -112,7 +113,7 @@ local function cmdReq(host, port, url, result) if ( val ) then 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 } end end diff --git a/scripts/ms-sql-dump-hashes.nse b/scripts/ms-sql-dump-hashes.nse index 36edde4af..7993dc037 100644 --- a/scripts/ms-sql-dump-hashes.nse +++ b/scripts/ms-sql-dump-hashes.nse @@ -2,6 +2,7 @@ local io = require "io" local mssql = require "mssql" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -123,7 +124,7 @@ action = function( host, port ) local filename if ( dir ) then 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]) end end diff --git a/scripts/ms-sql-hasdbaccess.nse b/scripts/ms-sql-hasdbaccess.nse index 53e7db68a..7e362c205 100644 --- a/scripts/ms-sql-hasdbaccess.nse +++ b/scripts/ms-sql-hasdbaccess.nse @@ -102,7 +102,7 @@ local function process_instance( instance ) "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" } local creds = mssql.Helper.GetLoginCredentials_All( instance ) diff --git a/scripts/ms-sql-tables.nse b/scripts/ms-sql-tables.nse index cb2f08f7c..c69c8c21b 100644 --- a/scripts/ms-sql-tables.nse +++ b/scripts/ms-sql-tables.nse @@ -143,12 +143,12 @@ local function process_instance( instance ) end keywords_filter = (" AND ( so.name IN (%s) or sc.name IN (%s) ) "):format( - stdnse.strjoin(",", tmp_tbl), - stdnse.strjoin(",", tmp_tbl) + table.concat(tmp_tbl, ","), + table.concat(tmp_tbl, ",") ) 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 ) @@ -210,7 +210,7 @@ local function process_instance( instance ) if keywords_arg then local tmp = keywords_arg if ( type(tmp) == 'table' ) then - tmp = stdnse.strjoin(',', tmp) + tmp = table.concat(tmp, ',') end table.insert(restrict_tbl, 1, ("Filter: %s"):format(tmp)) pos = pos + 1 diff --git a/scripts/mysql-audit.nse b/scripts/mysql-audit.nse index 586c85857..c6b934066 100644 --- a/scripts/mysql-audit.nse +++ b/scripts/mysql-audit.nse @@ -177,7 +177,7 @@ action = function( host, port ) table.insert(results, "") 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 }) diff --git a/scripts/netbus-info.nse b/scripts/netbus-info.nse index d076716ff..447c6e67e 100644 --- a/scripts/netbus-info.nse +++ b/scripts/netbus-info.nse @@ -2,6 +2,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -93,7 +94,7 @@ local function format_acl(acl) return nil end local payload = string.sub(acl, 9) --skip header - local fields = stdnse.strsplit("|", payload) + local fields = stringaux.strsplit("|", payload) table.remove(fields, (# fields)) return fields end @@ -103,7 +104,7 @@ local function format_apps(apps) return nil end local payload = string.sub(apps, 10) --skip header - local fields = stdnse.strsplit("|", payload) + local fields = stringaux.strsplit("|", payload) table.remove(fields, (# fields)) return fields end @@ -113,7 +114,7 @@ local function format_info(info) return nil end local payload = string.sub(info, 6) --skip header - local fields = stdnse.strsplit("|", payload) + local fields = stringaux.strsplit("|", payload) return fields end @@ -121,7 +122,7 @@ local function format_setup(setup) if setup == nil then return nil end - local fields = stdnse.strsplit(";", setup) + local fields = stringaux.strsplit(";", setup) if # fields < 7 then return nil end @@ -139,7 +140,7 @@ local function format_volume(volume) if volume == nil then return nil end - local fields = stdnse.strsplit(";", volume) + local fields = stringaux.strsplit(";", volume) if # fields < 4 then return nil end diff --git a/scripts/nfs-showmount.nse b/scripts/nfs-showmount.nse index f67f98627..007bd7d3d 100644 --- a/scripts/nfs-showmount.nse +++ b/scripts/nfs-showmount.nse @@ -88,7 +88,7 @@ action = function(host, port) end for _, v in ipairs( mounts ) do - local entry = v.name .. " " .. stdnse.strjoin(" ", v) + local entry = v.name .. " " .. table.concat(v, " ") table.insert( result, entry ) end diff --git a/scripts/nje-node-brute.nse b/scripts/nje-node-brute.nse index 03dac7031..3f10a8aed 100644 --- a/scripts/nje-node-brute.nse +++ b/scripts/nje-node-brute.nse @@ -1,5 +1,6 @@ local io = require "io" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local nmap = require "nmap" local stdnse = require "stdnse" @@ -147,7 +148,7 @@ end action = function( host, port ) -- 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 options = {} if o_host then options = { ohost = o_host:upper() } end diff --git a/scripts/nrpe-enum.nse b/scripts/nrpe-enum.nse index 14628aabd..3bab7bc37 100644 --- a/scripts/nrpe-enum.nse +++ b/scripts/nrpe-enum.nse @@ -2,6 +2,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local tab = require "tab" -- -*- mode: lua -*- @@ -195,7 +196,7 @@ action = function(host, port) -- Get script arguments. local cmds = stdnse.get_script_args("nrpe-enum.cmds") if cmds then - cmds = stdnse.strsplit(":", cmds) + cmds = stringaux.strsplit(":", cmds) else cmds = NRPE_COMMANDS end diff --git a/scripts/omp2-enum-targets.nse b/scripts/omp2-enum-targets.nse index 7afd8df5a..71bbb63a0 100644 --- a/scripts/omp2-enum-targets.nse +++ b/scripts/omp2-enum-targets.nse @@ -115,7 +115,7 @@ action = function(host, port) end 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)) end diff --git a/scripts/openlookup-info.nse b/scripts/openlookup-info.nse index 21d1bcc13..0d24959b1 100644 --- a/scripts/openlookup-info.nse +++ b/scripts/openlookup-info.nse @@ -4,6 +4,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -44,7 +45,7 @@ portrule = shortport.version_port_or_service(5850, "openlookup") -- parses a Netstring element local function parsechunk(data) - local parts = stdnse.strsplit(":", data) + local parts = stringaux.strsplit(":", data) if #parts < 2 then return nil, data end @@ -53,7 +54,7 @@ local function parsechunk(data) if not size then return nil, data end - local body = stdnse.strjoin(":", parts) + local body = table.concat(parts, ":") if #body < size then return nil, data end diff --git a/scripts/openwebnet-discovery.nse b/scripts/openwebnet-discovery.nse index 274c8f808..79edb2889 100644 --- a/scripts/openwebnet-discovery.nse +++ b/scripts/openwebnet-discovery.nse @@ -3,6 +3,7 @@ local stdnse = require "stdnse" local shortport = require "shortport" local comm = require "comm" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -189,7 +190,7 @@ local function format_dimensions(res) } 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 end @@ -217,7 +218,7 @@ local function format_dimensions(res) "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]) end diff --git a/scripts/oracle-brute-stealth.nse b/scripts/oracle-brute-stealth.nse index d05d1d7c3..00d90414f 100644 --- a/scripts/oracle-brute-stealth.nse +++ b/scripts/oracle-brute-stealth.nse @@ -6,6 +6,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local tns = require "tns" local unpwdb = require "unpwdb" @@ -190,7 +191,7 @@ action = function(host, port) engine.iterator = brute.Iterators.credential_iterator(f) 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 engine.options.useraspass = false diff --git a/scripts/pop3-capabilities.nse b/scripts/pop3-capabilities.nse index ef8a449b5..322bc1ad3 100644 --- a/scripts/pop3-capabilities.nse +++ b/scripts/pop3-capabilities.nse @@ -32,12 +32,12 @@ action = function(host, port) local capstrings = {} for cap, args in pairs(capa) do if ( #args > 0 ) then - table.insert(capstrings, ("%s(%s)"):format(cap, stdnse.strjoin(" ", args))) + table.insert(capstrings, ("%s(%s)"):format(cap, table.concat(args, " "))) else table.insert(capstrings, cap) end end - return stdnse.strjoin(" ", capstrings) + return table.concat(capstrings, " ") elseif type(err) == "string" then stdnse.debug1("'%s' for %s", err, host.ip) return diff --git a/scripts/quake3-info.nse b/scripts/quake3-info.nse index 13fb1a268..197137e50 100644 --- a/scripts/quake3-info.nse +++ b/scripts/quake3-info.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -79,7 +80,7 @@ portrule = shortport.version_port_or_service(range(27960, 27970), {'quake3'}, 'u local function parsefields(data) local fields = {} - local parts = stdnse.strsplit("\\", data) + local parts = stringaux.strsplit("\\", data) local nullprefix = table.remove(parts, 1) if nullprefix ~= "" then stdnse.debug2("unrecognized field format, skipping options") @@ -94,7 +95,7 @@ local function parsefields(data) end local function parsename(data) - local parts = stdnse.strsplit('"', data) + local parts = stringaux.strsplit('"', data) if #parts ~= 3 then return nil end @@ -109,7 +110,7 @@ local function parsename(data) end local function parseplayer(data) - local parts = stdnse.strsplit(" ", data) + local parts = stringaux.strsplit(" ", data) if #parts < 3 then stdnse.debug2("player info line is missing elements, skipping a player") return nil @@ -197,7 +198,7 @@ action = function(host, port) if not status then return end - local parts = stdnse.strsplit("\n", data) + local parts = stringaux.strsplit("\n", data) local header = table.remove(parts, 1) if header ~= STATUSRESP then return @@ -224,7 +225,7 @@ action = function(host, port) -- "ioq3 1.36+svn1933-1/Ubuntu linux-x86_64 Apr  4 2011" local versionline = basic["version"] if versionline then - local fields = stdnse.strsplit(" ", versionline) + local fields = stringaux.strsplit(" ", versionline) local product = fields[1] local version = fields[2] local osline = fields[3] diff --git a/scripts/quake3-master-getservers.nse b/scripts/quake3-master-getservers.nse index 20b39a30b..aeade6709 100644 --- a/scripts/quake3-master-getservers.nse +++ b/scripts/quake3-master-getservers.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local tab = require "tab" local table = require "table" @@ -103,12 +104,12 @@ local function getservers(host, port, q3protocol) nmap.set_port_version(host, port) local EOT = "EOT\0\0\0" - local pieces = stdnse.strsplit("\\", data) + local pieces = stringaux.strsplit("\\", data) while pieces[#pieces] ~= EOT do -- get all data status, tmp = socket:receive() if status then data = data .. tmp - pieces = stdnse.strsplit("\\", data) + pieces = stringaux.strsplit("\\", data) end end @@ -188,7 +189,7 @@ local function protocols() local filter = {} local count = {} for _, advert in ipairs(nmap.registry.q3m_servers) do - local key = stdnse.strjoin(":", {advert.ip, advert.port, advert.protocol}) + local key = table.concat({advert.ip, advert.port, advert.protocol}, ":") if filter[key] == nil then if count[advert.protocol] == nil then count[advert.protocol] = 0 @@ -196,7 +197,7 @@ local function protocols() count[advert.protocol] = count[advert.protocol] + 1 filter[key] = true end - local mkey = stdnse.strjoin(":", {advert.masterip, advert.masterport}) + local mkey = table.concat({advert.masterip, advert.masterport}, ":") end local sortable = {} for k, v in pairs(count) do diff --git a/scripts/redis-info.nse b/scripts/redis-info.nse index 7664facf8..810565459 100644 --- a/scripts/redis-info.nse +++ b/scripts/redis-info.nse @@ -4,6 +4,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local ipOps = require "ipOps" @@ -92,7 +93,7 @@ local extras = { if data[1] ~= "bind" or not data[2] then return nil end - local restab = stdnse.strsplit(" ", data[2]) + local restab = stringaux.strsplit(" ", data[2]) if not restab or 0 == #restab then stdnse.debug1("Failed to parse response from server") return nil @@ -126,7 +127,7 @@ local extras = { }, { "Client connections", {"CLIENT", "LIST"}, function(data) - local restab = stdnse.strsplit("\n", data) + local restab = stringaux.strsplit("\n", data) if not restab or 0 == #restab then stdnse.debug1("Failed to parse response from server") return nil @@ -160,7 +161,7 @@ local extras = { }, { "Cluster nodes", {"CLUSTER", "NODES"}, function(data) - local restab = stdnse.strsplit("\n", data) + local restab = stringaux.strsplit("\n", data) if not restab or 0 == #restab then return nil end @@ -211,7 +212,7 @@ action = function(host, port) return fail(response.data) end - local restab = stdnse.strsplit("\r\n", response.data) + local restab = stringaux.strsplit("\r\n", response.data) if ( not(restab) or 0 == #restab ) then return fail("Failed to parse response from server") end diff --git a/scripts/rfc868-time.nse b/scripts/rfc868-time.nse index 1b2b39f46..ebdbdbb9f 100644 --- a/scripts/rfc868-time.nse +++ b/scripts/rfc868-time.nse @@ -3,6 +3,7 @@ local datetime = require "datetime" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local nmap = require "nmap" local os = require "os" @@ -38,7 +39,7 @@ action = function(host, port) stamp = string.unpack(">I4", result) port.version.extrainfo = "64 bits" else - stdnse.debug1("Odd response: %s", stdnse.filename_escape(result)) + stdnse.debug1("Odd response: %s", stringaux.filename_escape(result)) return nil end diff --git a/scripts/rpcinfo.nse b/scripts/rpcinfo.nse index 8c3726dca..99a42244b 100644 --- a/scripts/rpcinfo.nse +++ b/scripts/rpcinfo.nse @@ -117,7 +117,7 @@ action = function(host, port) end end - table.insert( result, ("%-7d %-10s %5d/%s %s"):format(progid, stdnse.strjoin(",", v2.version), v2.port, proto, rpc.Util.ProgNumberToName(progid) or "") ) + table.insert( result, ("%-7d %-10s %5d/%s %s"):format(progid, table.concat(v2.version, ","), v2.port, proto, rpc.Util.ProgNumberToName(progid) or "") ) end end diff --git a/scripts/rtsp-methods.nse b/scripts/rtsp-methods.nse index 59b84c5ae..e7db1cabe 100644 --- a/scripts/rtsp-methods.nse +++ b/scripts/rtsp-methods.nse @@ -1,6 +1,7 @@ local rtsp = require "rtsp" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" description = [[ Determines which methods are supported by the RTSP (real time streaming protocol) server. @@ -52,6 +53,6 @@ action = function(host, port) helper:close() if ( status ) then local opts = response.headers['Public'] - return stdnse.strsplit(",%s*", opts), opts + return stringaux.strsplit(",%s*", opts), opts end end diff --git a/scripts/servicetags.nse b/scripts/servicetags.nse index 35188ab27..9f3577e06 100644 --- a/scripts/servicetags.nse +++ b/scripts/servicetags.nse @@ -4,6 +4,7 @@ local os = require "os" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -166,7 +167,7 @@ action = function(host, port) -- We should get a response back that has contains one line for the -- agent URN and TCP port local urn, xport, split - split = stdnse.strsplit(" ", response) + split = stringaux.strsplit(" ", response) urn = split[1] xport = split[2] table.insert(output, "URN: " .. urn) diff --git a/scripts/sip-methods.nse b/scripts/sip-methods.nse index 458f48f07..ec404ca5c 100644 --- a/scripts/sip-methods.nse +++ b/scripts/sip-methods.nse @@ -2,6 +2,7 @@ local nmap = require "nmap" local shortport = require "shortport" local sip = require "sip" local stdnse = require "stdnse" +local stringaux = require "stringaux" description = [[ Enumerates a SIP Server's allowed methods (INVITE, OPTIONS, SUBSCRIBE, etc.) @@ -58,7 +59,7 @@ action = function(host, port) -- Check if allow header exists in response local allow = response:getHeader("allow") if allow then - return stdnse.strsplit(",%s*", allow), allow + return stringaux.strsplit(",%s*", allow), allow end end end diff --git a/scripts/smb-brute.nse b/scripts/smb-brute.nse index 8261e3484..edc2501cb 100644 --- a/scripts/smb-brute.nse +++ b/scripts/smb-brute.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local smb = require "smb" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local unpwdb = require "unpwdb" local rand = require "rand" @@ -183,7 +184,7 @@ end -- for domain. local function split_domain(str) local username, domain - local split = stdnse.strsplit("\\", str) + local split = stringaux.strsplit("\\", str) if(#split > 1) then domain = split[1] @@ -1107,7 +1108,7 @@ action = function(host) table.sort(locked) -- Display the list - table.insert(response, string.format("Locked accounts found: %s", stdnse.strjoin(", ", locked))) + table.insert(response, string.format("Locked accounts found: %s", table.concat(locked, ", "))) end return stdnse.format_output(true, response) diff --git a/scripts/smb-enum-domains.nse b/scripts/smb-enum-domains.nse index 2a2385990..6f6cf1407 100644 --- a/scripts/smb-enum-domains.nse +++ b/scripts/smb-enum-domains.nse @@ -82,13 +82,13 @@ action = function(host) piece['name'] = domain if(#data.groups > 0) then - table.insert(piece, string.format("Groups: %s", stdnse.strjoin(", ", data.groups))) + table.insert(piece, string.format("Groups: %s", table.concat(data.groups, ", "))) else table.insert(piece, "Groups: n/a") end if(#data.users > 0) then - table.insert(piece, string.format("Users: %s", stdnse.strjoin(", ", data.users))) + table.insert(piece, string.format("Users: %s", table.concat(data.users, ", "))) else table.insert(piece, "Users: n/a") end @@ -105,7 +105,7 @@ action = function(host) data.max_password_age or "n/a", data.password_history or "n/a")) if(data.password_properties and #data.password_properties) then - table.insert(piece, string.format("Properties: %s", stdnse.strjoin(", ", data.password_properties))) + table.insert(piece, string.format("Properties: %s", table.concat(data.password_properties, ", "))) end if(data.lockout_threshold) then diff --git a/scripts/smb-enum-processes.nse b/scripts/smb-enum-processes.nse index 64cc6b1ed..cb81df52e 100644 --- a/scripts/smb-enum-processes.nse +++ b/scripts/smb-enum-processes.nse @@ -269,7 +269,7 @@ action = function(host) -- Produce final output. local response if nmap.verbosity() == 0 then - response = "|_ " .. stdnse.strjoin(", ", names) + response = "|_ " .. table.concat(names, ", ") else response = "\n" .. psl_print(psl, nmap.verbosity()) end diff --git a/scripts/smb-enum-users.nse b/scripts/smb-enum-users.nse index 26b1b1a96..19ba7fb43 100644 --- a/scripts/smb-enum-users.nse +++ b/scripts/smb-enum-users.nse @@ -238,7 +238,7 @@ action = function(host) end -- Add this domain to the response - table.insert(response, string.format("Domain: %s; Users: %s", domain, stdnse.strjoin(", ", names))) + table.insert(response, string.format("Domain: %s; Users: %s", domain, table.concat(names, ", "))) end else for domain, domain_users in pairs(domains) do @@ -253,7 +253,7 @@ action = function(host) table.insert(response_part, string.format("Description: %s", info['description'])) end if(info['flags']) then - table.insert(response_part, string.format("Flags: %s", stdnse.strjoin(", ", info['flags']))) + table.insert(response_part, string.format("Flags: %s", table.concat(info['flags'], ", "))) end table.insert(response, response_part) diff --git a/scripts/smb-ls.nse b/scripts/smb-ls.nse index 7b8a3cf66..09570aa6e 100644 --- a/scripts/smb-ls.nse +++ b/scripts/smb-ls.nse @@ -1,5 +1,6 @@ local smb = require 'smb' local string = require 'string' +local stringaux = require "stringaux" local stdnse = require 'stdnse' local ls = require 'ls' @@ -170,7 +171,7 @@ action = function(host) -- give priority to specified shares if specified if arg_shares ~= nil then - arg_shares = stdnse.strsplit(":", arg_shares) + arg_shares = stringaux.strsplit(":", arg_shares) elseif arg_share ~= nil then arg_shares = {arg_share} else diff --git a/scripts/smb-mbenum.nse b/scripts/smb-mbenum.nse index f8e6dbc28..edca83000 100644 --- a/scripts/smb-mbenum.nse +++ b/scripts/smb-mbenum.nse @@ -215,7 +215,7 @@ action = function(host, port) if ( format == OutputFormat.BY_TYPE_H ) then for k, v in pairs(results) do - local row = ("%s: %s"):format( k, stdnse.strjoin(",", v) ) + local row = ("%s: %s"):format( k, table.concat(v, ",") ) table.insert(output, row) end table.sort(output) diff --git a/scripts/smb-os-discovery.nse b/scripts/smb-os-discovery.nse index d15ad42c8..879941575 100644 --- a/scripts/smb-os-discovery.nse +++ b/scripts/smb-os-discovery.nse @@ -136,7 +136,7 @@ function make_cpe(result) end if #parts > 0 then - return "cpe:/" .. stdnse.strjoin(":", parts) + return "cpe:/" .. table.concat(parts, ":") end end diff --git a/scripts/smb-psexec.nse b/scripts/smb-psexec.nse index ad7b0ec18..9f895419b 100644 --- a/scripts/smb-psexec.nse +++ b/scripts/smb-psexec.nse @@ -6,6 +6,7 @@ local nmap = require "nmap" local smb = require "smb" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -727,7 +728,7 @@ local function find_share(host) if(path == nil) then return false, string.format("Couldn't find path to writable share (we probably don't have admin access): '%s'", share) end - stdnse.debug1("Found usable share %s (%s) (all writable shares: %s)", share, path, stdnse.strjoin(", ", shares)) + stdnse.debug1("Found usable share %s (%s) (all writable shares: %s)", share, path, table.concat(shares, ", ")) end return true, share, path, shares @@ -941,7 +942,7 @@ local function get_config(host, config) if(#missing_args > 0) then enabled = false mod.disabled_message = {} - table.insert(mod.disabled_message, string.format("Configuration error: Required argument(s) ('%s') weren't given.", stdnse.strjoin("', '", missing_args))) + table.insert(mod.disabled_message, string.format("Configuration error: Required argument(s) ('%s') weren't given.", table.concat('", missing_args, "'))) table.insert(mod.disabled_message, "Please add --script-args=[arg]=[value] to your commandline to run this module") if(#missing_args == 1) then table.insert(mod.disabled_message, string.format("For example: --script-args=%s=123", missing_args[1])) @@ -1355,7 +1356,7 @@ local function parse_output(config, data) data = data or "" -- Split the result at newlines - local lines = stdnse.strsplit("\n", data) + local lines = stringaux.strsplit("\n", data) local module_num = -1 local mod = nil @@ -1496,7 +1497,7 @@ and place it in nselib/data/psexec/ under the Nmap DATADIR. table.insert(response, "* Running the script with --script-args=cleanup=1 to force a cleanup (passing -d and looking for error messages might help),") table.insert(response, "* Running the script with --script-args=randomseed=ABCD (or something) to change the name of the uploaded files,") table.insert(response, "* Changing the share and path using, for example, --script-args=share=C$,sharepath=C:, or") - table.insert(response, "* Deleting the affected file(s) off the server manually (\\\\" .. config.share .. "\\" .. stdnse.strjoin(", \\\\" .. config.share .. "\\", files) .. ")") + table.insert(response, "* Deleting the affected file(s) off the server manually (\\\\" .. config.share .. "\\" .. table.concat(files, ", \\\\" .. config.share .. "\\") .. ")") return stdnse.format_output(false, response) end diff --git a/scripts/smtp-commands.nse b/scripts/smtp-commands.nse index d8900f530..4b1b6d435 100644 --- a/scripts/smtp-commands.nse +++ b/scripts/smtp-commands.nse @@ -125,7 +125,7 @@ action = function(host, port) for index, test in ipairs(result) do table.insert(final, test) end - return stdnse.strjoin("\n ", final) + return table.concat(final, "\n ") end end end diff --git a/scripts/smtp-open-relay.nse b/scripts/smtp-open-relay.nse index 6bc238942..040d232de 100644 --- a/scripts/smtp-open-relay.nse +++ b/scripts/smtp-open-relay.nse @@ -280,7 +280,7 @@ action = function(host, port) end end - return stdnse.strjoin("\n ", final) + return table.concat(final, "\n ") end return "Server doesn't seem to be an open relay, all tests failed" diff --git a/scripts/smtp-vuln-cve2010-4344.nse b/scripts/smtp-vuln-cve2010-4344.nse index 7b6b6af05..537e4eac4 100644 --- a/scripts/smtp-vuln-cve2010-4344.nse +++ b/scripts/smtp-vuln-cve2010-4344.nse @@ -3,6 +3,7 @@ local shortport = require "shortport" local smtp = require "smtp" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -366,7 +367,7 @@ local function check_exim(smtp_opts) return smtp_finish(nil, status, response) end - for _, line in pairs(stdnse.strsplit("\r?\n", response)) do + for _, line in pairs(stringaux.strsplit("\r?\n", response)) do if not smtp_opts.ehlo_host or not smtp_opts.domain_ip then smtp_opts.ehlo_host, smtp_opts.domain_ip = line:match("%d.-Hello%s(.*)%s%[([^]]*)%]") diff --git a/scripts/smtp-vuln-cve2011-1720.nse b/scripts/smtp-vuln-cve2011-1720.nse index 2544712e9..5552c47dd 100644 --- a/scripts/smtp-vuln-cve2011-1720.nse +++ b/scripts/smtp-vuln-cve2011-1720.nse @@ -2,6 +2,7 @@ local shortport = require "shortport" local smtp = require "smtp" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local vulns = require "vulns" @@ -168,7 +169,7 @@ local function check_smtpd(smtp_opts) local auth_mech_list, auth_mech_str = {}, "" -- parse server response - for _, line in pairs(stdnse.strsplit("\r?\n", response)) do + for _, line in pairs(stringaux.strsplit("\r?\n", response)) do if not next(auth_mech_list) then auth_mech_str = chk_auth_mechanisms(line, auth_mech_list) end @@ -192,7 +193,7 @@ local function check_smtpd(smtp_opts) return status, response end - for _, line in pairs(stdnse.strsplit("\r?\n", response)) do + for _, line in pairs(stringaux.strsplit("\r?\n", response)) do if not next(auth_mech_list) then auth_mech_str = chk_auth_mechanisms(line, auth_mech_list) end diff --git a/scripts/snmp-ios-config.nse b/scripts/snmp-ios-config.nse index 3dfc6d925..7608c8f21 100644 --- a/scripts/snmp-ios-config.nse +++ b/scripts/snmp-ios-config.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local shortport = require "shortport" local snmp = require "snmp" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" local tftp = require "tftp" @@ -151,7 +152,7 @@ action = function(host, port) result = ( infile and infile:getContent() ) if ( tftproot ) then - local fname = tftproot .. stdnse.filename_escape(host.ip .. "-config") + local fname = tftproot .. stringaux.filename_escape(host.ip .. "-config") local file, err = io.open(fname, "w") if ( file ) then file:write(result) diff --git a/scripts/ssh-hostkey.nse b/scripts/ssh-hostkey.nse index 873abbaf2..2e4248797 100644 --- a/scripts/ssh-hostkey.nse +++ b/scripts/ssh-hostkey.nse @@ -5,6 +5,7 @@ local ssh1 = require "ssh1" local ssh2 = require "ssh2" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local tableaux = require "table" local base64 = require "base64" @@ -168,7 +169,7 @@ local function check_keys(host, keys, f) -- the line might be hashed if string.match(parts[1], "^|") then -- split the first part of the line - it contains base64'ed salt and hashed hostname - local parts_hostname = stdnse.strsplit("|", parts[1]) + local parts_hostname = stringaux.strsplit("|", parts[1]) if #parts_hostname == 4 then -- check if the hash corresponds to the host being scanned local salt = base64.dec(parts_hostname[3]) diff --git a/scripts/ssh2-enum-algos.nse b/scripts/ssh2-enum-algos.nse index f4f5d5e64..1830c0b44 100644 --- a/scripts/ssh2-enum-algos.nse +++ b/scripts/ssh2-enum-algos.nse @@ -2,6 +2,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local openssl = stdnse.silent_require "openssl" @@ -136,7 +137,7 @@ local output = function(parsed, lists) for _, l in ipairs(lists) do local v = parsed[l] - local a = v:len() > 0 and stdnse.strsplit(",", v) or {} + local a = v:len() > 0 and stringaux.strsplit(",", v) or {} if nmap.verbosity() > 0 then setmetatable(a, { __tostring = function(t) diff --git a/scripts/ssl-cert-intaddr.nse b/scripts/ssl-cert-intaddr.nse index 739093df5..7536e7177 100644 --- a/scripts/ssl-cert-intaddr.nse +++ b/scripts/ssl-cert-intaddr.nse @@ -2,6 +2,7 @@ local shortport = require "shortport" local sslcert = require "sslcert" local stdnse = require "stdnse" local string = require "string" +local table = require "table" local ipOps = require "ipOps" description = [[ @@ -86,7 +87,7 @@ local searchCertField = function(certField, certFieldName) -- if the name of this X509 field is numeric object identifier -- (i.e. "1.2.33.4..") if type(k)=="table" then - k = stdnse.strjoin(".", k) + k = table.concat(k, ".") end stdnse.debug2("search %s %s", certFieldName, k) diff --git a/scripts/ssl-cert.nse b/scripts/ssl-cert.nse index 6fe3d4db8..162bdcdd6 100644 --- a/scripts/ssl-cert.nse +++ b/scripts/ssl-cert.nse @@ -4,6 +4,7 @@ local shortport = require "shortport" local sslcert = require "sslcert" local stdnse = require "stdnse" local string = require "string" +local table = require "table" local tls = require "tls" local unicode = require "unicode" @@ -187,20 +188,20 @@ function stringify_name(name) -- Don't include a field twice. if not table_find(NON_VERBOSE_FIELDS, k) then if type(k) == "table" then - k = stdnse.strjoin(".", k) + k = table.concat(k, ".") end fields[#fields + 1] = string.format("%s=%s", k, maybe_decode(v) or '') end end end - return stdnse.strjoin("/", fields) + return table.concat(fields, "/") end local function name_to_table(name) local output = {} for k, v in pairs(name) do if type(k) == "table" then - k = stdnse.strjoin(".", k) + k = table.concat(k, ".") end output[k] = v end @@ -264,7 +265,7 @@ local function output_str(cert) if nmap.verbosity() > 1 then lines[#lines + 1] = cert.pem end - return stdnse.strjoin("\n", lines) + return table.concat(lines, "\n") end action = function(host, port) diff --git a/scripts/stuxnet-detect.nse b/scripts/stuxnet-detect.nse index 548430680..800dbc636 100644 --- a/scripts/stuxnet-detect.nse +++ b/scripts/stuxnet-detect.nse @@ -2,6 +2,7 @@ local io = require "io" local msrpc = require "msrpc" local smb = require "smb" local stdnse = require "stdnse" +local stringaux = require "stringaux" -- -*- mode: lua -*- -- vim: set filetype=lua : @@ -82,7 +83,7 @@ local function check_infected(host, path, save) fmt = save:gsub("%%h", host.ip) fmt = fmt:gsub("%%v", version) - file = io.open(stdnse.filename_escape(fmt), "w") + file = io.open(stringaux.filename_escape(fmt), "w") if file then stdnse.debug1("Wrote %d bytes to file %s.", #result.arguments, fmt) file:write(result.arguments) diff --git a/scripts/svn-brute.nse b/scripts/svn-brute.nse index e45cf6841..4c0aaf878 100644 --- a/scripts/svn-brute.nse +++ b/scripts/svn-brute.nse @@ -3,6 +3,7 @@ local creds = require "creds" local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" +local stringaux = require "stringaux" local openssl = stdnse.silent_require "openssl" description = [[ @@ -94,7 +95,7 @@ svn = if ( msg:match("%( success") ) then local tmp = msg:match("%( success %( %( ([%S+%s*]-) %)") if ( not(tmp) ) then return false, "Failed to detect authentication" end - tmp = stdnse.strsplit(" ", tmp) + tmp = stringaux.strsplit(" ", tmp) self.auth_mech = {} for _, v in pairs(tmp) do self.auth_mech[v] = true end elseif ( msg:match("%( failure") ) then diff --git a/scripts/targets-asn.nse b/scripts/targets-asn.nse index dcef9c117..1002e0b3e 100644 --- a/scripts/targets-asn.nse +++ b/scripts/targets-asn.nse @@ -1,5 +1,6 @@ local nmap = require "nmap" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" local target = require "target" @@ -81,7 +82,7 @@ action = function(host, port) table.insert(prefixes, err) break else - for i, prefix in ipairs(stdnse.strsplit("\n",data)) do + for i, prefix in ipairs(stringaux.strsplit("\n",data)) do if ( #prefix > 1 ) then table.insert(prefixes,prefix) if target.ALLOW_NEW_TARGETS then diff --git a/scripts/targets-ipv6-map4to6.nse b/scripts/targets-ipv6-map4to6.nse index 1ddb15c57..f588e7523 100644 --- a/scripts/targets-ipv6-map4to6.nse +++ b/scripts/targets-ipv6-map4to6.nse @@ -2,6 +2,7 @@ local ipOps = require "ipOps" local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local target = require "target" @@ -61,7 +62,7 @@ categories = { } local function split_prefix (net) - local split = stdnse.strsplit("/", net) + local split = stringaux.strsplit("/", net) return split[1], tonumber(split[2]) end --- diff --git a/scripts/targets-ipv6-wordlist.nse b/scripts/targets-ipv6-wordlist.nse index f5b871aa4..163da01aa 100644 --- a/scripts/targets-ipv6-wordlist.nse +++ b/scripts/targets-ipv6-wordlist.nse @@ -2,6 +2,7 @@ local ipOps = require "ipOps" local nmap = require "nmap" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local target = require "target" local datafiles = require "datafiles" local table = require "table" @@ -48,7 +49,7 @@ categories = { } local function split_prefix (net) - local split = stdnse.strsplit("/", net) + local split = stringaux.strsplit("/", net) return split[1], tonumber(split[2]) end diff --git a/scripts/targets-sniffer.nse b/scripts/targets-sniffer.nse index 265d21dc5..830b8507d 100644 --- a/scripts/targets-sniffer.nse +++ b/scripts/targets-sniffer.nse @@ -105,7 +105,7 @@ action = function() packet_counter=packet_counter+1 addresses = get_ip_addresses(layer3) - stdnse.debug1("Got IP addresses %s", stdnse.strjoin(" ", addresses)) + stdnse.debug1("Got IP addresses %s", table.concat(addresses, " ")) for _, addr in ipairs(addresses) do if check_if_valid(addr) == true then @@ -147,5 +147,5 @@ action = function() stdnse.debug1("Added %s address(es) to newtargets", #all_addresses) end - return string.format("Sniffed %s address(es). \n", #all_addresses) .. stdnse.strjoin("\n",all_addresses) + return string.format("Sniffed %s address(es). \n", #all_addresses) .. table.concat(all_addresses, "\n") end diff --git a/scripts/tftp-enum.nse b/scripts/tftp-enum.nse index 257575247..831cbad66 100644 --- a/scripts/tftp-enum.nse +++ b/scripts/tftp-enum.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" local rand = require "rand" @@ -67,7 +68,7 @@ end local generate_cisco_address_confg = function(base_address) local filenames = {} - local octets = stdnse.strsplit("%.", base_address) + local octets = stringaux.strsplit("%.", base_address) for i = 0, 255 do local address_confg = octets[1] .. "." .. octets[2] .. "." .. octets[3] .. "." .. i .. "-confg" diff --git a/scripts/tn3270-screen.nse b/scripts/tn3270-screen.nse index 8ca13e402..c37acd9bd 100644 --- a/scripts/tn3270-screen.nse +++ b/scripts/tn3270-screen.nse @@ -1,4 +1,5 @@ local stdnse = require "stdnse" +local stringaux = require "stringaux" local shortport = require "shortport" local tn3270 = require "tn3270" @@ -72,7 +73,7 @@ action = function(host, port) return else if commands then - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(1,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) t:send_cursor(run[i]) diff --git a/scripts/tso-brute.nse b/scripts/tso-brute.nse index cb6d6f528..a1005e446 100644 --- a/scripts/tso-brute.nse +++ b/scripts/tso-brute.nse @@ -6,6 +6,7 @@ local creds = require "creds" local unpwdb = require "unpwdb" local nmap = require "nmap" local string = require "string" +local stringaux = require "stringaux" description = [[ TSO account brute forcer. @@ -96,7 +97,7 @@ Driver = { local always_logon = self.options['key2'] local skip = self.options['skip'] stdnse.debug(2,"Getting to TSO") - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) stdnse.verbose(2,"Trying User ID/Password: %s/%s", user, pass) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) @@ -235,7 +236,7 @@ local function tso_test( host, port, commands ) stdnse.debug("Could not initiate TN3270: %s", err ) return tso, "Could not Initiate TN3270" end - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) tn:send_cursor(run[i]) @@ -290,7 +291,7 @@ local function tso_skip( host, port, commands ) stdnse.debug(2,"Not using LOGON command, testing adding userid to command" ) end - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) if i == #run then diff --git a/scripts/tso-enum.nse b/scripts/tso-enum.nse index 40f4ebc09..bec164392 100644 --- a/scripts/tso-enum.nse +++ b/scripts/tso-enum.nse @@ -6,6 +6,7 @@ local creds = require "creds" local unpwdb = require "unpwdb" local nmap = require "nmap" local string = require "string" +local stringaux = require "stringaux" description = [[ TSO User ID enumerator for IBM mainframes (z/OS). The TSO logon panel @@ -95,7 +96,7 @@ Driver = { local commands = self.options['key1'] local skip = self.options['skip'] stdnse.debug(2,"Getting to TSO") - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) if i == #run and run[i]:upper():find("LOGON APPLID") and skip then @@ -172,7 +173,7 @@ local function tso_test( host, port, commands ) stdnse.debug("Could not initiate TN3270: %s", err ) return tso, "Could not Initiate TN3270" end - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) tn:send_cursor(run[i]) @@ -227,7 +228,7 @@ local function tso_skip( host, port, commands ) stdnse.debug(2,"Not using LOGON command, testing adding userid to command" ) end - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) if i == #run then diff --git a/scripts/url-snarf.nse b/scripts/url-snarf.nse index e0aab648c..473eb008d 100644 --- a/scripts/url-snarf.nse +++ b/scripts/url-snarf.nse @@ -3,6 +3,7 @@ local nmap = require "nmap" local os = require "os" local packet = require "packet" local stdnse = require "stdnse" +local stringaux = require "stringaux" local table = require "table" local url = require "url" @@ -55,11 +56,11 @@ end -- are all declared local. local function get_url(data) - local headers, body = table.unpack(stdnse.strsplit("\r\n\r\n", data)) + local headers, body = table.unpack(stringaux.strsplit("\r\n\r\n", data)) if ( not(headers) ) then return end - headers = stdnse.strsplit("\r\n", headers) + headers = stringaux.strsplit("\r\n", headers) if ( not(headers) or 1 > #headers ) then return end diff --git a/scripts/vtam-enum.nse b/scripts/vtam-enum.nse index 3f465ecb9..8d8392c19 100644 --- a/scripts/vtam-enum.nse +++ b/scripts/vtam-enum.nse @@ -7,6 +7,7 @@ local unpwdb = require "unpwdb" local io = require "io" local nmap = require "nmap" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -193,7 +194,7 @@ local function vtam_test( host, port, commands, macros) tn:get_screen_debug(2) -- prints TN3270 screen to debug if commands ~= nil then - local run = stdnse.strsplit(";%s*", commands) + local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s) or %s", i, #run ,run[i]) tn:send_cursor(run[i]) diff --git a/scripts/whois-ip.nse b/scripts/whois-ip.nse index 8e236e371..c53790277 100644 --- a/scripts/whois-ip.nse +++ b/scripts/whois-ip.nse @@ -6,6 +6,7 @@ local nmap = require "nmap" local os = require "os" local stdnse = require "stdnse" local string = require "string" +local stringaux = require "stringaux" local table = require "table" description = [[ @@ -692,7 +693,7 @@ function analyse_response( tracking, ip, response, data ) -- fetch an object immediately in front of inetnum stdnse.debug5("%s Searching for an object group immediately before this range.", this_db) -- split objects from the record, up to offset. Last object should be the one we want. - local obj_sel = stdnse.strsplit( "\r?\n\r?\n", response:sub( 1, offset ) ) + local obj_sel = stringaux.strsplit( "\r?\n\r?\n", response:sub( 1, offset ) ) response_chunk = "\n" .. obj_sel[#obj_sel] .. "\n" -- check if any of the objects we like match this single object in response chunk for ob, t in pairs( meta.fieldreq ) do @@ -1806,7 +1807,7 @@ function get_local_assignments_data() elseif http_response.status == 200 then -- prepend our file header stdnse.debug2("Retrieved %s.", assignment_data_spec.remote_resource) - file_content = stdnse.strsplit( "\r?\n", http_response.body ) + file_content = stringaux.strsplit( "\r?\n", http_response.body ) table.insert( file_content, 1, "** Do Not Alter This Line or The Following Line **" ) local hline = {} hline[#hline+1] = "<" .. os.time() .. ">" diff --git a/scripts/xmlrpc-methods.nse b/scripts/xmlrpc-methods.nse index 94c7ac3c5..c518d00de 100644 --- a/scripts/xmlrpc-methods.nse +++ b/scripts/xmlrpc-methods.nse @@ -52,13 +52,13 @@ local function set_80_columns(t) table.insert(line, word) ll = ll + #word + 1 else - buffer = buffer .. stdnse.strjoin(" ", line) .. "\n" + buffer = buffer .. table.concat(line, " ") .. "\n" ll = #word + 1 line = {word} end end string.gsub(description, "(%S+)", add_word) - buffer = buffer .. stdnse.strjoin(" ", line) .. "\n\n" + buffer = buffer .. table.concat(line, " ") .. "\n\n" end return "\n" .. strbuf.dump(buffer) end