Module: Msf::Simple::Framework::ModulePaths

Included in:
Msf::Simple::Framework
Defined in:
lib/msf/base/simple/framework/module_paths.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configured_module_pathsObject

Returns the value of attribute configured_module_paths.



8
9
10
# File 'lib/msf/base/simple/framework/module_paths.rb', line 8

def configured_module_paths
  @configured_module_paths
end

#module_paths_initedObject

Returns the value of attribute module_paths_inited.



9
10
11
# File 'lib/msf/base/simple/framework/module_paths.rb', line 9

def module_paths_inited
  @module_paths_inited
end

Instance Method Details

#init_module_paths(opts = {}) ⇒ void

This method returns an undefined value.

Initialize the module paths



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/msf/base/simple/framework/module_paths.rb', line 14

def init_module_paths(opts = {})
  if @module_paths_inited
    raise 'Module paths already initialized.  To add more module paths call `modules.add_module_path`'
  end

  @configured_module_paths = []
  extract_engine_module_paths(Rails.application).each do |path|
    @configured_module_paths << path
  end

  if Msf::Config.user_module_directory
    @configured_module_paths << Msf::Config.user_module_directory
  end

  ::Rails::Engine.subclasses.map(&:instance).each do |engine|
    extract_engine_module_paths(engine).each do |path|
      @configured_module_paths << path
    end
  end

  # If additional module paths have been defined globally, then load them.
  # They should be separated by semi-colons.
  self.datastore['MsfModulePaths'].to_s.split(";").each do |path|
    @configured_module_paths << path
  end

  # If the caller had additional paths to search, load them.
  # They should be separated by semi-colons.
  opts.delete(:module_paths).to_s.split(";").each do |path|
    @configured_module_paths << path
  end

  # Remove any duplicate paths
  @configured_module_paths.uniq!
  # return early if we're deferring module loading
  return if opts.delete(:defer_module_loads)

  # Update the module cache from the database
  self.modules.refresh_cache_from_database(@configured_module_paths)

  # Load each of the module paths
  @configured_module_paths.each do |path|
    self.modules.add_module_path(path, opts, recalculate: false)
  end

  @module_paths_inited = true
end