mirror of
https://github.com/nmap/nmap.git
synced 2025-12-30 19:39:07 +00:00
Lua 5.2 fixed from Daniel Miller.
http://seclists.org/nmap-dev/2012/q2/525
This commit is contained in:
@@ -69,7 +69,7 @@ action = function()
|
||||
status, data = socket:receive()
|
||||
if( not(status) ) then break end
|
||||
|
||||
local version, srvname = data:match("DB2RETADDR.(SQL%d+).(.-)%z")
|
||||
local version, srvname = data:match("DB2RETADDR.(SQL%d+).(.-)\0")
|
||||
local _, ip
|
||||
status, _, _, ip, _ = socket:get_info()
|
||||
if ( not(status) ) then return end
|
||||
|
||||
@@ -79,7 +79,7 @@ action = function(host, port)
|
||||
return
|
||||
end
|
||||
|
||||
local version, srvname = data:match("DB2RETADDR.(SQL%d+).(.-)%z")
|
||||
local version, srvname = data:match("DB2RETADDR.(SQL%d+).(.-)\0")
|
||||
|
||||
if ( status ) then
|
||||
table.insert( result, ("Host: %s"):format(srvname) )
|
||||
|
||||
@@ -108,7 +108,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 = unpack(stdnse.strsplit("%s", line))
|
||||
local mount, prefix, fstype, size, free, used, bs = table.unpack(stdnse.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))
|
||||
@@ -133,7 +133,7 @@ local function decodeTag(tag, lines)
|
||||
elseif ( "uptime" == tag ) then
|
||||
return ("%s: %s"):format(long_names[tag], minutesToUptime(lines[1]))
|
||||
elseif ( "mem" == tag ) then
|
||||
local total, used = unpack(stdnse.strsplit("%s", lines[1]))
|
||||
local total, used = table.unpack(stdnse.strsplit("%s", lines[1]))
|
||||
if ( not(total) or not(used) ) then
|
||||
return
|
||||
end
|
||||
@@ -141,7 +141,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 = unpack(stdnse.strsplit("%s", lines[1]))
|
||||
local procs, _, forks, load, users = table.unpack(stdnse.strsplit("%s", lines[1]))
|
||||
if ( not(procs) or not(forks) or not(load) or not(users) ) then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -109,7 +109,7 @@ end
|
||||
|
||||
-- Escape some potentially unsafe characters in a string meant to be a filename.
|
||||
function filename_escape(s)
|
||||
return string.gsub(s, "[%z/=]", function(c)
|
||||
return string.gsub(s, "[\0/=]", function(c)
|
||||
return string.format("=%02X", string.byte(c))
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -70,7 +70,7 @@ end
|
||||
-- @return Table containing the names and paths of the available services
|
||||
local function get_available_services(body)
|
||||
local services = {}
|
||||
for service in string.gfind(body, '<h4>Service%sDescription%s:%s<font%scolor="black">(.-)</font></h4>') do
|
||||
for service in string.gmatch(body, '<h4>Service%sDescription%s:%s<font%scolor="black">(.-)</font></h4>') do
|
||||
table.insert(services, service)
|
||||
end
|
||||
|
||||
|
||||
@@ -505,20 +505,20 @@ local GeoIP = {
|
||||
start_pos = start_pos + 1
|
||||
local end_pos = 0
|
||||
|
||||
end_pos = record_buf:find("%z",start_pos)
|
||||
end_pos = record_buf:find("\0",start_pos)
|
||||
if start_pos ~= end_pos then
|
||||
record.region_name = record_buf:sub(start_pos, end_pos-1)
|
||||
end
|
||||
start_pos = end_pos + 1
|
||||
|
||||
end_pos = record_buf:find("%z",start_pos)
|
||||
end_pos = record_buf:find("\0",start_pos)
|
||||
if start_pos ~= end_pos then
|
||||
record.city = record_buf:sub(start_pos, end_pos-1)
|
||||
end
|
||||
start_pos = end_pos + 1
|
||||
|
||||
|
||||
end_pos = record_buf:find("%z",start_pos)
|
||||
end_pos = record_buf:find("\0",start_pos)
|
||||
if start_pos ~= end_pos then
|
||||
record.postal_code = record_buf:sub(start_pos, end_pos-1)
|
||||
end
|
||||
|
||||
@@ -145,7 +145,7 @@ local function irc_compose_message(prefix, command, ...)
|
||||
|
||||
params = {...}
|
||||
for i, param in ipairs(params) do
|
||||
if not string.match(param, "^[^%z\r\n :][^%z\r\n ]*$") then
|
||||
if not string.match(param, "^[^\0\r\n :][^\0\r\n ]*$") then
|
||||
if i < #params then
|
||||
return nil, "Bad format for param."
|
||||
else
|
||||
|
||||
@@ -39,10 +39,10 @@ action = function(host, port)
|
||||
return
|
||||
end
|
||||
-- match jdwp m|JDWP-Handshake| p/$1/ v/$3/ i/$2\n$4/
|
||||
local match = {string.match(result, "^JDWP%-Handshake%z%z..%z%z%z\1\128%z%z%z%z..([^%z\n]*)\n([^%z]*)%z%z..%z%z..%z%z..([0-9._]+)%z%z..([^%z]*)")}
|
||||
local match = {string.match(result, "^JDWP%-Handshake\0\0..\0\0\0\1\128\0\0\0\0..([^\0\n]*)\n([^\0]*)\0\0..\0\0..\0\0..([0-9._]+)\0\0..([^\0]*)")}
|
||||
if match == nil or #match == 0 then
|
||||
-- if we have one \128 (reply marker), it is at least not echo because the request did not contain \128
|
||||
if (string.match(result,"^JDWP%-Handshake%z.*\128") ~= nil) then
|
||||
if (string.match(result,"^JDWP%-Handshake\0.*\128") ~= nil) then
|
||||
port.version.name="jdwp"
|
||||
port.version.product="unknown"
|
||||
nmap.set_port_version(host, port, "hardmatched")
|
||||
|
||||
@@ -33,7 +33,7 @@ categories = { "default", "discovery", "safe" }
|
||||
--@param orig Start of the string
|
||||
--@return The NUL-terminated string
|
||||
local getstring = function(orig)
|
||||
return orig:match("^([^%z]*)");
|
||||
return orig:match("^([^\0]*)");
|
||||
end
|
||||
|
||||
--- Converts two bytes into a number
|
||||
|
||||
@@ -54,7 +54,7 @@ action = function(host, port)
|
||||
local result
|
||||
|
||||
-- check to see if the packet we got back matches the beginning of a PPTP Start-Control-Connection-Reply packet
|
||||
result = string.match(response, "%z\156%z\001\026\043(.*)")
|
||||
result = string.match(response, "\0\156\0\001\026\043(.*)")
|
||||
local output
|
||||
|
||||
if result ~= nil then
|
||||
@@ -70,13 +70,13 @@ action = function(host, port)
|
||||
-- get the hostname (64 octets)
|
||||
local s3
|
||||
s3 = string.sub(result, 24, 87)
|
||||
hostname = string.match(s3, "(.-)%z")
|
||||
hostname = string.match(s3, "(.-)\0")
|
||||
|
||||
-- get the vendor (should be 64 octets, but capture to end of the string to be safe)
|
||||
local s4, length
|
||||
length = #result
|
||||
s4 = string.sub(result, 88, length)
|
||||
vendor = string.match(s4, "(.-)%z")
|
||||
vendor = string.match(s4, "(.-)\0")
|
||||
|
||||
port.version.name = "pptp"
|
||||
port.version.name_confidence = 10
|
||||
|
||||
@@ -60,7 +60,7 @@ action = function(host, port)
|
||||
return
|
||||
end
|
||||
|
||||
if not string.match(result, "^....[%z]+\002") then
|
||||
if not string.match(result, "^....[\0]+\002") then
|
||||
socket:close()
|
||||
return
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user