Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/payloads/win32/kernel.rb
Views: 11655
# -*- coding: binary -*-1module Rex2module Payloads3module Win32456module Kernel78#9# Constructs a kernel-mode payload using the supplied options. The options10# can be:11#12# Recovery : The recovery method to use, such as 'spin'.13# Stager : The stager method to use, such as 'sud_syscall_hook'.14# RecoveryStub : The recovery stub that should be used, if any.15# UserModeStub : The user-mode payload to execute, if any.16# KernelModeStub: The kernel-mode payload to execute, if any.17#18def self.construct(opts = {})19payload = nil2021# Generate the recovery stub22if opts['Recovery'] and Kernel::Recovery.respond_to?(opts['Recovery'], true)23opts['RecoveryStub'] = Kernel::Recovery.send(opts['Recovery'], opts)24end2526# Append supplied recovery stub information in case there is some27# context specific recovery that must be done.28if opts['AppendRecoveryStub']29opts['RecoveryStub'] = (opts['RecoveryStub'] || '') + opts['AppendRecoveryStub']30end3132# Generate the stager33if opts['Stager'] and Kernel::Stager.respond_to?(opts['Stager'], true)34payload = Kernel::Stager.send(opts['Stager'], opts)35# Or, generate the migrator36elsif opts['Migrator'] and Kernel::Migration.respond_to?(opts['Migrator'], true)37payload = Kernel::Migration.send(opts['Migrator'], opts)38else39raise ArgumentError, "A stager or a migrator must be specified."40end4142payload43end4445end4647end48end49end505152