home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Networking / nmap-5.00-setup.exe / scripts / pop3-capabilities.nse < prev    next >
Text File  |  2009-07-06  |  2KB  |  53 lines

  1. description = [[
  2. Retrieves POP3 email server capabilities.
  3.  
  4. POP3 capabilities are defined in RFC 2449. The CAPA command allows a client to
  5. ask a server what commands it supports and possibly any site-specific policy.
  6. Besides the list of supported commands, the IMPLEMENTATION string giving the
  7. server version may be available.
  8. ]]
  9.  
  10. ---
  11. -- @output
  12. -- 110/tcp open  pop3
  13. -- |_ pop3-capabilities: USER CAPA RESP-CODES UIDL PIPELINING STLS TOP SASL(PLAIN)
  14.  
  15. author = "Philip Pickering <pgpickering@gmail.com>"
  16. license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
  17.  
  18. categories = {"default"}
  19.  
  20. require 'pop3'
  21. require 'shortport'
  22. require 'stdnse'
  23.  
  24. portrule = shortport.port_or_service({110}, "pop3")
  25.  
  26. action = function(host, port)
  27.   local capa, err = pop3.capabilities(host, port)
  28.   if type(capa) == "table" then
  29.      -- Convert the capabilities table into an array of strings.
  30.      local capstrings = {}
  31.      local cap, args
  32.      for cap, args in pairs(capa) do
  33.     local capstr = cap
  34.     if type(args) == "string" then capstr = capstr .. "(" .. args .. ")" end
  35.     if type(args) == "table" then
  36.        local arg
  37.        capstr = capstr .. "("
  38.        for i, arg in ipairs(args) do
  39.           capstr = capstr .. arg .. " "
  40.        end
  41.        capstr = string.sub(capstr, 1, #capstr - 1) .. ")"
  42.     end
  43.     table.insert(capstrings, capstr)
  44.      end
  45.      return stdnse.strjoin(" ", capstrings)
  46.   elseif type(err) == "string" then
  47.      stdnse.print_debug(1, "%s: '%s' for %s", filename, err, host.ip)
  48.      return
  49.   else
  50.      return "server doesn't support CAPA"
  51.   end
  52. end
  53.