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/msf/core/exploit/seh.rb
Views: 11784
# -*- coding: binary -*-1require 'rex/exploitation/seh'23module Msf45###6#7# This mixin provides an interface to generating SEH registration records in a8# robust fashion using the Rex::Exploitation::Seh class.9#10###11module Exploit::Seh1213#14# Creates an instance of an exploit that uses an SEH overwrite.15#16def initialize(info = {})17super1819# Register an advanced option that allows users to specify whether or20# not a dynamic SEH record should be used.21register_advanced_options(22[23OptBool.new('DynamicSehRecord', [ false, "Generate a dynamic SEH record (more stealthy)", false ])24], Msf::Exploit::Seh)25end2627#28# Generates an SEH record with zero or more options. The supported options29# are:30#31# NopGenerator32#33# The NOP generator instance to use, if any.34#35# Space36#37# The amount of room the SEH record generator has to play with for38# random padding. This should be derived from the maximum amount of39# space available to the exploit for payloads minus the current payload40# size.41#42def generate_seh_record(handler, opts = {})43seh = Rex::Exploitation::Seh.new(44payload_badchars,45opts['Space'] || payload_space,46opts['NopGenerator'] || nop_generator)4748# Generate the record49seh.generate_seh_record(handler, datastore['DynamicSehRecord'])50end5152def generate_seh_payload(handler, opts = {})5354# The boilerplate this replaces always has 8 bytes for seh + addr55seh_space = 8 + payload.nop_sled_size5657seh = Rex::Exploitation::Seh.new(58payload_badchars,59seh_space,60opts['NopGenerator'] || nop_generator)6162# Generate the record63rec = seh.generate_seh_record(handler, datastore['DynamicSehRecord'])6465# Append the payload, minus the nop sled that we replaced66rec << payload.encoded.slice(payload.nop_sled_size, payload.encoded.length)67end6869end7071end727374