Files
metasploit-gs/lib/msf/core/exploit/egghunter.rb
T
Ramon de C Valle f124597a56 Code cleanups
git-svn-id: file:///home/svn/framework3/trunk@5773 4d416f70-5f16-0410-b530-b9f4589650da
2008-10-19 21:03:39 +00:00

54 lines
1.2 KiB
Ruby

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
# 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
# If we found a platform list, then take the first platform
los = los.names[0] if (los.kind_of?(Msf::Module::PlatformList))
# Use the first architecture if one was specified
larch = larch[0] if (larch.kind_of?(Array))
if los.nil?
raise RuntimeError, "No platform restrictions were specified -- cannot select egghunter"
end
egg = Rex::Exploitation::Egghunter.new(los, larch)
bunny = egg.generate(payload_badchars)
if (bunny.nil?)
print_error("The egghunter could not be generated")
raise ArgumentError
end
return bunny
end
end
end