Module: Msf::Module::DataStore

Included in:
Msf::Module
Defined in:
lib/msf/core/module/data_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#datastoreObject

Returns the value of attribute datastore


10
11
12
# File 'lib/msf/core/module/data_store.rb', line 10

def datastore
  @datastore
end

Instance Method Details

#import_defaults(clear_datastore = true) ⇒ Object

Imports default options into the module's datastore, optionally clearing all of the values currently set in the datastore.


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/msf/core/module/data_store.rb', line 16

def import_defaults(clear_datastore = true)
  # Clear the datastore if the caller asked us to
  self.datastore.clear if clear_datastore

  self.datastore.import_options(self.options, 'self', true)

  # If there are default options, import their values into the datastore
  if (module_info['DefaultOptions'])
    self.datastore.import_options_from_hash(module_info['DefaultOptions'], true, 'self')
  end

  # Preference the defaults for the currently set target
  import_target_defaults
end

#import_target_defaultsObject

Import the target's DefaultOptions hash into the datastore.


34
35
36
37
38
# File 'lib/msf/core/module/data_store.rb', line 34

def import_target_defaults
  return unless defined?(targets) && targets && target && target.default_options

  datastore.import_options_from_hash(target.default_options, true, 'self')
end

#share_datastore(ds) ⇒ Object

Overrides the class' own datastore with the one supplied. This is used to allow modules to share datastores, such as a payload sharing an exploit module's datastore.


45
46
47
48
# File 'lib/msf/core/module/data_store.rb', line 45

def share_datastore(ds)
  self.datastore = ds
  self.datastore.import_options(self.options)
end