1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 21:21:31 +00:00
Files
nmap/scripts/pop3-capabilities.nse
jah c8442d3946 Fix error:
SCRIPT ENGINE (506.424s): ./scripts/pop3-capabilities.nse against a.b.1.47:995
ended with error: ./scripts/pop3-capabilities.nse:32: bad argument #1 to
'pairs' (table expected, got string)

which happens because pop3.lua returns a string error message instead of a table
of capabilities if it can't connect the socket or obtain a response from a
connected socket.
It now returns nil, err_message in these cases and the documentation now reflects
this - pop3-capabilities.nse silently returns and prints a debug message.

Added a 10s timeout for the socket in pop3.lua capabilities - 30s was a bit much.
2009-02-03 01:15:25 +00:00

53 lines
1.5 KiB
Lua

description = [[
Retrieves POP3 email server capabilities.
POP3 capabilities are defined in RFC 2449. The CAPA command allows a client to
ask a server what commands it supports and possibly any site-specific policy.
Besides the list of supported commands, the IMPLEMENTATION string giving the
server version may be available.
]]
---
-- @output
-- 110/tcp open pop3
-- |_ pop3-capabilities: USER CAPA RESP-CODES UIDL PIPELINING STLS TOP SASL(PLAIN)
author = "Philip Pickering <pgpickering@gmail.com>"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"default"}
require 'pop3'
require 'shortport'
require 'stdnse'
portrule = shortport.port_or_service({110}, "pop3")
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) .. ")"
end
table.insert(capstrings, capstr)
end
return stdnse.strjoin(" ", capstrings)
elseif type(err) == "string" then
stdnse.print_debug(1, "%s: '%s' for %s", filename, err, host.ip)
return
else
return "server doesn't support CAPA"
end
end