2005-11-26 02:34:39 +00:00
|
|
|
require 'rex/exploitation/egghunter'
|
|
|
|
|
|
|
|
module Msf
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This mixin provides a interface to generating egghunters for various
|
|
|
|
# platforms using the Rex::Exploitation::Egghunter class.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
module Exploit::Egghunter
|
|
|
|
|
|
|
|
#
|
|
|
|
# Creates an instance of an exploit that uses an Egghunter overwrite.
|
|
|
|
#
|
|
|
|
def initialize(info = {})
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generates an egghunter stub based on the current target's architecture
|
|
|
|
# and operating system.
|
|
|
|
#
|
|
|
|
def generate_egghunter
|
2007-02-18 12:08:11 +00:00
|
|
|
# Prefer the target's platform/architecture information, but use
|
|
|
|
# the module's if no target specific information exists
|
|
|
|
los = target_platform
|
|
|
|
larch = target_arch || ARCH_X86
|
2006-06-23 06:20:52 +00:00
|
|
|
|
2007-02-18 12:08:11 +00:00
|
|
|
# If we found a platform list, then take the first platform
|
|
|
|
los = los.names[0] if (los.kind_of?(Msf::Module::PlatformList))
|
|
|
|
|
2007-10-02 03:24:21 +00:00
|
|
|
# Use the first architecture if one was specified
|
|
|
|
larch = larch[0] if (larch.kind_of?(Array))
|
|
|
|
|
2007-02-18 12:08:11 +00:00
|
|
|
if los.nil?
|
|
|
|
raise RuntimeError, "No platform restrictions were specified -- cannot select egghunter"
|
|
|
|
end
|
2005-11-26 02:34:39 +00:00
|
|
|
|
2007-02-18 12:08:11 +00:00
|
|
|
egg = Rex::Exploitation::Egghunter.new(los, larch)
|
2005-11-26 02:34:39 +00:00
|
|
|
bunny = egg.generate(payload_badchars)
|
|
|
|
|
|
|
|
if (bunny.nil?)
|
|
|
|
print_error("The egghunter could not be generated")
|
|
|
|
raise ArgumentError
|
|
|
|
end
|
|
|
|
|
|
|
|
return bunny
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2008-10-19 21:03:39 +00:00
|
|
|
end
|