Sha256: 6b96537948916cabba2cc8cc4748cb351dcff964af293becce31e88cc85e26ed

Contents?: true

Size: 1.62 KB

Versions: 7

Compression:

Stored size: 1.62 KB

Contents

# -*- coding: binary -*-
module Rex
module Payloads
module Win32

require 'rex/payloads/win32/kernel/common'
require 'rex/payloads/win32/kernel/recovery'
require 'rex/payloads/win32/kernel/stager'
require 'rex/payloads/win32/kernel/migration'

module Kernel

  #
  # Constructs a kernel-mode payload using the supplied options.  The options
  # can be:
  #
  # Recovery      : The recovery method to use, such as 'spin'.
  # Stager        : The stager method to use, such as 'sud_syscall_hook'.
  # RecoveryStub  : The recovery stub that should be used, if any.
  # UserModeStub  : The user-mode payload to execute, if any.
  # KernelModeStub: The kernel-mode payload to execute, if any.
  #
  def self.construct(opts = {})
    payload = nil

    # Generate the recovery stub
    if opts['Recovery'] and Kernel::Recovery.respond_to?(opts['Recovery'], true)
      opts['RecoveryStub'] = Kernel::Recovery.send(opts['Recovery'], opts)
    end

    # Append supplied recovery stub information in case there is some
    # context specific recovery that must be done.
    if opts['AppendRecoveryStub']
      opts['RecoveryStub'] = (opts['RecoveryStub'] || '') + opts['AppendRecoveryStub']
    end

    # Generate the stager
    if opts['Stager'] and Kernel::Stager.respond_to?(opts['Stager'], true)
      payload = Kernel::Stager.send(opts['Stager'], opts)
    # Or, generate the migrator
    elsif opts['Migrator'] and Kernel::Migration.respond_to?(opts['Migrator'], true)
      payload = Kernel::Migration.send(opts['Migrator'], opts)
    else
      raise ArgumentError, "A stager or a migrator must be specified."
    end

    payload
  end

end

end
end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rex-2.0.13 lib/rex/payloads/win32/kernel.rb
rex-2.0.12 lib/rex/payloads/win32/kernel.rb
rex-2.0.11 lib/rex/payloads/win32/kernel.rb
rex-2.0.10 lib/rex/payloads/win32/kernel.rb
rex-2.0.9 lib/rex/payloads/win32/kernel.rb
rex-2.0.8 lib/rex/payloads/win32/kernel.rb
rex-2.0.7 lib/rex/payloads/win32/kernel.rb