Move cache logic from statistics->module_manager, More modularization in ModuleManager
git-svn-id: file:///home/svn/framework3/trunk@11643 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
a2e6f0e96c
commit
53bba0bd54
|
@ -21,45 +21,35 @@ class Statistics
|
|||
# Returns the number of encoders in the framework.
|
||||
#
|
||||
def num_encoders
|
||||
framework.modules.using_cache ?
|
||||
framework.modules.cached_counts[MODULE_ENCODER] :
|
||||
framework.encoders.length
|
||||
framework.encoders.length
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the number of exploits in the framework.
|
||||
#
|
||||
def num_exploits
|
||||
framework.modules.using_cache ?
|
||||
framework.modules.cached_counts[MODULE_EXPLOIT] :
|
||||
framework.exploits.length
|
||||
framework.exploits.length
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the number of NOP generators in the framework.
|
||||
#
|
||||
def num_nops
|
||||
framework.modules.using_cache ?
|
||||
framework.modules.cached_counts[MODULE_NOP] :
|
||||
framework.nops.length
|
||||
framework.nops.length
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the number of payloads in the framework.
|
||||
#
|
||||
def num_payloads
|
||||
framework.modules.using_cache ?
|
||||
framework.modules.cached_counts[MODULE_PAYLOAD] :
|
||||
framework.payloads.length
|
||||
framework.payloads.length
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the number of auxiliary modules in the framework.
|
||||
#
|
||||
def num_auxiliary
|
||||
framework.modules.using_cache ?
|
||||
framework.modules.cached_counts[MODULE_AUX] :
|
||||
framework.auxiliary.length
|
||||
framework.auxiliary.length
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -336,18 +336,7 @@ class ModuleManager < ModuleSet
|
|||
self.framework = framework
|
||||
|
||||
types.each { |type|
|
||||
self.enabled_types[type] = true
|
||||
case type
|
||||
when MODULE_PAYLOAD
|
||||
instance = PayloadSet.new(self)
|
||||
else
|
||||
instance = ModuleSet.new(type)
|
||||
end
|
||||
|
||||
self.module_sets[type] = instance
|
||||
|
||||
# Set the module set's framework reference
|
||||
instance.framework = framework
|
||||
init_module_set(type)
|
||||
}
|
||||
|
||||
super(nil)
|
||||
|
@ -356,6 +345,21 @@ class ModuleManager < ModuleSet
|
|||
@cached_counts = false
|
||||
end
|
||||
|
||||
def init_module_set(type)
|
||||
self.enabled_types[type] = true
|
||||
case type
|
||||
when MODULE_PAYLOAD
|
||||
instance = PayloadSet.new(self)
|
||||
else
|
||||
instance = ModuleSet.new(type)
|
||||
end
|
||||
|
||||
self.module_sets[type] = instance
|
||||
|
||||
# Set the module set's framework reference
|
||||
instance.framework = self.framework
|
||||
end
|
||||
|
||||
#
|
||||
# Creates a module using the supplied name.
|
||||
#
|
||||
|
@ -374,46 +378,60 @@ class ModuleManager < ModuleSet
|
|||
# Accessors by module type
|
||||
#
|
||||
|
||||
#
|
||||
# Returns all of the modules of the specified type
|
||||
#
|
||||
def module_set(type)
|
||||
ret = nil
|
||||
if using_cache
|
||||
ret = self.cached_counts[type]
|
||||
else
|
||||
ret = module_sets[type]
|
||||
end
|
||||
ret || []
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the set of loaded encoder module classes.
|
||||
#
|
||||
def encoders
|
||||
return module_sets[MODULE_ENCODER]
|
||||
module_set(MODULE_ENCODER)
|
||||
end
|
||||
|
||||
|
||||
#
|
||||
# Returns the set of loaded exploit module classes.
|
||||
#
|
||||
def exploits
|
||||
return module_sets[MODULE_EXPLOIT]
|
||||
module_set(MODULE_EXPLOIT)
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the set of loaded nop module classes.
|
||||
#
|
||||
def nops
|
||||
return module_sets[MODULE_NOP]
|
||||
module_set(MODULE_NOP)
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the set of loaded payload module classes.
|
||||
#
|
||||
def payloads
|
||||
return module_sets[MODULE_PAYLOAD]
|
||||
module_set(MODULE_PAYLOAD)
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the set of loaded auxiliary module classes.
|
||||
#
|
||||
def auxiliary
|
||||
return module_sets[MODULE_AUX]
|
||||
module_set(MODULE_AUX)
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the set of loaded auxiliary module classes.
|
||||
#
|
||||
def post
|
||||
return module_sets[MODULE_POST]
|
||||
module_set(MODULE_POST)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue