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

  1. description = [[
  2. Retrieves IMAP email server capabilities.
  3.  
  4. IMAP4rev1 capabilities are defined in RFC 3501. The CAPABILITY command
  5. allows a client to ask a server what commands it supports and possibly
  6. any site-specific policy.
  7. ]]
  8.  
  9. ---
  10. -- @output
  11. -- 143/tcp open  imap
  12. -- |_ imap-capabilities: LOGINDISABLED IDLE IMAP4 LITERAL+ STARTTLS NAMESPACE IMAP4rev1
  13.  
  14.  
  15. author = "Brandon Enright <bmenrigh@ucsd.edu>"
  16. license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
  17.  
  18. categories = {"default"}
  19.  
  20. require 'imap'
  21. require 'shortport'
  22. require 'stdnse'
  23.  
  24. portrule = shortport.port_or_service({143}, "imap")
  25.  
  26. action = function(host, port)
  27.   local capa, err = imap.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.     table.insert(capstrings, cap)
  34.      end
  35.      return stdnse.strjoin(" ", capstrings)
  36.   elseif type(err) == "string" then
  37.      stdnse.print_debug(1, "%s: '%s' for %s", filename, err, host.ip)
  38.      return
  39.   else
  40.      return "server doesn't support CAPABILITIES"
  41.   end
  42. end
  43.