diff --git a/lib/msf/core/exploit/egghunter.rb b/lib/msf/core/exploit/egghunter.rb index 13697e9642..3e339118d6 100644 --- a/lib/msf/core/exploit/egghunter.rb +++ b/lib/msf/core/exploit/egghunter.rb @@ -23,13 +23,19 @@ module Exploit::Egghunter # and operating system. # def generate_egghunter - os = target['Platform'] - arch = target.arch + # 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 - arch ||= ARCH_X86 - os ||= 'win' + # If we found a platform list, then take the first platform + los = los.names[0] if (los.kind_of?(Msf::Module::PlatformList)) + + if los.nil? + raise RuntimeError, "No platform restrictions were specified -- cannot select egghunter" + end - egg = Rex::Exploitation::Egghunter.new(os, arch) + egg = Rex::Exploitation::Egghunter.new(los, larch) bunny = egg.generate(payload_badchars) if (bunny.nil?)