Module: Msf::Simple::Framework
- Includes:
- GeneralEventSubscriber, ModulePaths
- Defined in:
- lib/msf/base/simple/framework.rb,
lib/msf/base/simple/framework/module_paths.rb
Overview
This class wraps the framework-core supplied Framework class and adds some helper methods for analyzing statistics as well as other potentially useful information that is directly necessary to drive the framework-core.
Defined Under Namespace
Modules: ModulePaths, PluginManager
Constant Summary collapse
- ModuleSimplifiers =
{ Msf::MODULE_ENCODER => Msf::Simple::Encoder, Msf::MODULE_EXPLOIT => Msf::Simple::Exploit, Msf::MODULE_NOP => Msf::Simple::Nop, Msf::MODULE_PAYLOAD => Msf::Simple::Payload, Msf::MODULE_AUX => Msf::Simple::Auxiliary, Msf::MODULE_POST => Msf::Simple::Post, Msf::MODULE_EVASION => Msf::Simple::Evasion }
Instance Attribute Summary collapse
-
#cache_initialized ⇒ Object
Boolean indicating whether the cache is initialized yet.
-
#cache_thread ⇒ Object
Thread of the running rebuild operation.
-
#stats ⇒ Object
Statistics.
Class Method Summary collapse
-
.create(opts = {}) ⇒ Msf::Simple::Frameworkt s
Create a simplified instance of the framework.
-
.simplify(framework, opts) ⇒ Msf::Simple::Framework
Extends a framework object that may already exist.
-
.simplify_module(instance, load_saved_config = true) ⇒ Object
Simplifies a module instance if the type is supported by extending it with the simplified module interface.
Instance Method Summary collapse
-
#init_simplified ⇒ Object
Initializes the simplified interface.
-
#load_config ⇒ Object
Loads configuration, populates the root datastore, etc.
-
#on_module_created(instance) ⇒ Object
Simplifies module instances when they're created.
-
#save_config ⇒ Object
Saves the module's datastore to the file.
Methods included from GeneralEventSubscriber
#on_module_complete, #on_module_error, #on_module_load, #on_module_run
Methods included from ModulePaths
Instance Attribute Details
#cache_initialized ⇒ Object
Boolean indicating whether the cache is initialized yet
179 180 181 |
# File 'lib/msf/base/simple/framework.rb', line 179 def cache_initialized @cache_initialized end |
#cache_thread ⇒ Object
Thread of the running rebuild operation
184 185 186 |
# File 'lib/msf/base/simple/framework.rb', line 184 def cache_thread @cache_thread end |
#stats ⇒ Object
Statistics.
173 174 175 |
# File 'lib/msf/base/simple/framework.rb', line 173 def stats @stats end |
Class Method Details
.create(opts = {}) ⇒ Msf::Simple::Frameworkt s
Create a simplified instance of the framework. This routine takes a hash of parameters as an argument. This hash can contain:
73 74 75 76 |
# File 'lib/msf/base/simple/framework.rb', line 73 def self.create(opts = {}) framework = Msf::Framework.new(opts) return simplify(framework, opts) end |
.simplify(framework, opts) ⇒ Msf::Simple::Framework
If `opts` is set, then `Msf::Config::Defaults` will be updated to `opts`.
Extends a framework object that may already exist.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/msf/base/simple/framework.rb', line 90 def self.simplify(framework, opts) # If the framework instance has not already been extended, do it now. if (framework.kind_of?(Msf::Simple::Framework) == false) framework.extend(Msf::Simple::Framework) framework.plugins.extend(Msf::Simple::Framework::PluginManager) end # Initialize the simplified framework framework.init_simplified() # Call the creation procedure if one was supplied if (opts['OnCreateProc']) opts['OnCreateProc'].call(framework) end # Change to a different configuration path if requested if opts['ConfigDirectory'] Msf::Config::Defaults['ConfigDirectory'] = opts['ConfigDirectory'] end # Initialize configuration and logging Msf::Config.init Msf::Logging.init unless opts['DisableLogging'] # Load the configuration framework.load_config # Register the framework as its own general event subscriber in this # instance framework.events.add_general_subscriber(framework) unless opts['DeferModuleLoads'] framework.init_module_paths end return framework end |
.simplify_module(instance, load_saved_config = true) ⇒ Object
Simplifies a module instance if the type is supported by extending it with the simplified module interface.
133 134 135 136 137 138 139 140 |
# File 'lib/msf/base/simple/framework.rb', line 133 def self.simplify_module(instance, load_saved_config = true) if ((ModuleSimplifiers[instance.type]) and (instance.class.include?(ModuleSimplifiers[instance.type]) == false)) instance.extend(ModuleSimplifiers[instance.type]) instance.init_simplified(load_saved_config) end end |
Instance Method Details
#init_simplified ⇒ Object
Initializes the simplified interface.
152 153 154 |
# File 'lib/msf/base/simple/framework.rb', line 152 def init_simplified self.stats = Statistics.new(self) end |
#load_config ⇒ Object
Loads configuration, populates the root datastore, etc.
159 160 161 |
# File 'lib/msf/base/simple/framework.rb', line 159 def load_config self.datastore.from_file(Msf::Config.config_file, 'framework/core') end |
#on_module_created(instance) ⇒ Object
Simplifies module instances when they're created.
52 53 54 |
# File 'lib/msf/base/simple/framework.rb', line 52 def on_module_created(instance) Msf::Simple::Framework.simplify_module(instance) end |
#save_config ⇒ Object
Saves the module's datastore to the file
166 167 168 |
# File 'lib/msf/base/simple/framework.rb', line 166 def save_config self.datastore.to_file(Msf::Config.config_file, 'framework/core') end |