mirror of
https://github.com/nmap/nmap.git
synced 2025-12-19 22:19:02 +00:00
fixed a bug in the pop3-capabilities script that would fail parsing the
response from some servers.
This commit is contained in:
@@ -27,29 +27,22 @@ categories = {"default","discovery","safe"}
|
||||
portrule = shortport.port_or_service({110,995},{"pop3","pop3s"})
|
||||
|
||||
action = function(host, port)
|
||||
local capa, err = pop3.capabilities(host, port)
|
||||
if type(capa) == "table" then
|
||||
-- Convert the capabilities table into an array of strings.
|
||||
local capstrings = {}
|
||||
local cap, args
|
||||
for cap, args in pairs(capa) do
|
||||
local capstr = cap
|
||||
if type(args) == "string" then capstr = capstr .. "(" .. args .. ")" end
|
||||
if type(args) == "table" then
|
||||
local arg
|
||||
capstr = capstr .. "("
|
||||
for i, arg in ipairs(args) do
|
||||
capstr = capstr .. arg .. " "
|
||||
end
|
||||
capstr = string.sub(capstr, 1, #capstr - 1) .. ")"
|
||||
local capa, err = pop3.capabilities(host, port)
|
||||
if type(capa) == "table" then
|
||||
-- Convert the capabilities table into an array of strings.
|
||||
local capstrings = {}
|
||||
for cap, args in pairs(capa) do
|
||||
if ( #args > 0 ) then
|
||||
table.insert(capstrings, ("%s(%s)"):format(cap, stdnse.strjoin(" ", args)))
|
||||
else
|
||||
table.insert(capstrings, cap)
|
||||
end
|
||||
end
|
||||
return stdnse.strjoin(" ", capstrings)
|
||||
elseif type(err) == "string" then
|
||||
stdnse.print_debug(1, "%s: '%s' for %s", SCRIPT_NAME, err, host.ip)
|
||||
return
|
||||
else
|
||||
return "server doesn't support CAPA"
|
||||
end
|
||||
table.insert(capstrings, capstr)
|
||||
end
|
||||
return stdnse.strjoin(" ", capstrings)
|
||||
elseif type(err) == "string" then
|
||||
stdnse.print_debug(1, "%s: '%s' for %s", SCRIPT_NAME, err, host.ip)
|
||||
return
|
||||
else
|
||||
return "server doesn't support CAPA"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user