Add a module_flavors method for all available flavors

bug/bundler_fix
Spencer McIntyre 2014-07-03 11:01:21 -04:00
parent faa9c11450
commit d93bf55435
1 changed files with 17 additions and 14 deletions

View File

@ -44,21 +44,10 @@ module Exploit::CmdStager
def initialize(info = {})
super
flavors = []
if module_info['CmdStagerFlavor']
flavors = Array(module_info['CmdStagerFlavor'])
else
targets.each do |target|
flavors += Array(target.opts['CmdStagerFlavor']) if target.opts['CmdStagerFlavor']
end
flavors.uniq!
end
if flavors.empty?
flavors = STAGERS.keys
end
flavors = flavors.map { |flavor| flavor.to_s }
flavors = module_flavors
flavors = STAGERS.keys if flavors.empty?
flavors.unshift('auto')
register_advanced_options(
[
OptEnum.new('CMDSTAGER::FLAVOR', [false, 'The CMD Stager to use.', 'auto', flavors]),
@ -261,6 +250,20 @@ module Exploit::CmdStager
end
end
# Returns all the compatible stager flavors specified by the module and each
# of it's targets.
#
# @return [Array] the list of all compatible cmd stager flavors.
def module_flavors
flavors = []
flavors += Array(module_info['CmdStagerFlavor']) if module_info['CmdStagerFlavor']
targets.each do |target|
flavors += Array(target.opts['CmdStagerFlavor']) if target.opts['CmdStagerFlavor']
end
flavors.uniq!
flavors.map { |flavor| flavor.to_s }
end
# Returns the compatible stager flavors for the current target or module.
#
# @return [Array] the list of compatible cmd stager flavors.