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

  1. description = [[
  2. Returns information about the SMB security level determined by SMB.
  3.  
  4. Here is how to interpret the output:
  5.  
  6. * User-level authentication: Each user has a separate username/password that is used to log into the system. This is the default setup of pretty much everything these days.
  7. * Share-level authentication: The anonymous account should be used to log in, then the password is given (in plaintext) when a share is accessed. All users who have access to the share use this password. This was the original way of doing things, but isn't commonly seen, now. If a server uses share-level security, it is vulnerable to sniffing.
  8. * Challenge/response passwords supported: If enabled, the server can accept any type of password (plaintext, LM and NTLM, and LMv2 and NTLMv2).  If it isn't set, the server can only accept plaintext passwords. Most servers are configured to use challenge/response these days. If a server is configured to accept plaintext passwords, it is vulnerable to sniffing. LM and NTLM are fairly secure, although there are some brute-force attacks against them. Additionally, LM and NTLM can fall victim to man-in-the-middle attacks or relay attacks (see MS08-068 or my writeup of it: <http://www.skullsecurity.org/blog/?p=110>. 
  9. * Message signing: If required, all messages between the client and server must be signed by a shared key, derived from the password and the server challenge. If supported and not required, message signing is negotiated between clients and servers and used if both support and request it. By default, Windows clients don't sign messages, so if message signing isn't required by the server, messages probably won't be signed; additionally, if performing a man-in-the-middle attack, an attacker can negotiate no message signing. If message signing isn't required, the server is vulnerable to man-in-the-middle attacks or SMB-relay attacks.
  10.  
  11. This script will allow you to use the <code>smb*</code> script arguments (to
  12. set the username and password, etc.), but it probably won't ever require them. 
  13. ]]
  14.  
  15. ---
  16. --@usage
  17. -- nmap --script smb-security-mode.nse -p445 127.0.0.1
  18. -- sudo nmap -sU -sS --script smb-security-mode.nse -p U:137,T:139 127.0.0.1
  19. --
  20. --@output
  21. -- |  smb-security-mode: User-level authentication
  22. -- |  smb-security-mode: Challenge/response passwords supported
  23. -- |_ smb-security-mode: Message signing supported
  24. -----------------------------------------------------------------------
  25.  
  26. author = "Ron Bowes"
  27. license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
  28. categories = {"discovery", "safe"}
  29.  
  30. require 'smb'
  31.  
  32. -- Check whether or not this script should be run.
  33. hostrule = function(host)
  34.     return smb.get_port(host) ~= nil
  35. end
  36.  
  37.  
  38. action = function(host)
  39.  
  40.     local state
  41.     local status, err
  42.  
  43.     status, state = smb.start(host)
  44.     if(status == false) then
  45.         if(nmap.debugging() > 0) then
  46.             return "ERROR: " .. state
  47.         else
  48.             return nil
  49.         end
  50.     end
  51.  
  52.     status, err = smb.negotiate_protocol(state)
  53.  
  54.     if(status == false) then
  55.         smb.stop(state)
  56.         if(nmap.debugging() > 0) then
  57.             return "ERROR: " .. err
  58.         else
  59.             return nil
  60.         end
  61.     end
  62.  
  63.     local security_mode = state['security_mode']
  64.  
  65.     local response = ""
  66.     
  67.     -- User-level authentication or share-level authentication
  68.     if(bit.band(security_mode, 1) == 1) then
  69.         response = response .. "User-level authentication\n"
  70.     else
  71.         response = response .. " Share-level authentication\n"
  72.     end
  73.  
  74.     -- Challenge/response supported?
  75.     if(bit.band(security_mode, 2) == 0) then
  76.         response = response .. "SMB Security: Plaintext only\n"
  77.     else
  78.         response = response .. "SMB Security: Challenge/response passwords supported\n"
  79.     end
  80.  
  81.     -- Message signing supported/required?
  82.     if(bit.band(security_mode, 8) == 8) then
  83.         response = response .. "SMB Security: Message signing required\n"
  84.     elseif(bit.band(security_mode, 4) == 4) then
  85.         response = response .. "SMB Security: Message signing supported\n"
  86.     else
  87.         response = response .. "SMB Security: Message signing not supported\n"
  88.     end
  89.  
  90.     smb.stop(state)
  91.     return response
  92. end
  93.  
  94.  
  95.