Class: Msf::Framework

Inherits:
Object
  • Object
show all
Includes:
MonitorMixin
Defined in:
lib/msf/core/framework.rb

Overview

This class is the primary context that modules, scripts, and user interfaces interact with. It ties everything together.

Defined Under Namespace

Modules: Offspring

Constant Summary collapse

Major =

Versioning information

Metasploit::Framework::Version::MAJOR
Minor =
Metasploit::Framework::Version::MINOR
Point =
Metasploit::Framework::Version::PATCH
Release =
"-#{Metasploit::Framework::Version::PRERELEASE}"
Version =
Metasploit::Framework::VERSION
Revision =
"$Revision$"
EICARCorrupted =

EICAR canary

::Msf::Util::EXE.is_eicar_corrupted?

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Framework

Creates an instance of the framework context.


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/msf/core/framework.rb', line 69

def initialize(options={})
  self.options = options
  # call super to initialize MonitorMixin.  #synchronize won't work without this.
  super()

  # Allow specific module types to be loaded
  types = options[:module_types] || Msf::MODULE_TYPES

  self.events    = EventDispatcher.new(self)
  self.modules   = ModuleManager.new(self,types)
  self.datastore = DataStore.new
  self.jobs      = Rex::JobContainer.new
  self.analyze   = Analyze.new(self)
  self.plugins   = PluginManager.new(self)
  self.browser_profiles = Hash.new
  self.features = FeatureManager.instance

  # Configure the thread factory
  Rex::ThreadFactory.provider = Metasploit::Framework::ThreadFactoryProvider.new(framework: self)

  # Configure the SSL certificate generator
  Rex::Socket::Ssl.cert_provider = Msf::Ssl::CertProvider

  subscriber = FrameworkEventSubscriber.new(self)
  events.add_exploit_subscriber(subscriber)
  events.add_session_subscriber(subscriber)
  events.add_general_subscriber(subscriber)
  events.add_db_subscriber(subscriber)
  events.add_ui_subscriber(subscriber)
end

Instance Attribute Details

#analyzeObject

The framework instance's analysis utility. Provide method to analyze framework objects to offer related objects/actions available.


198
199
200
# File 'lib/msf/core/framework.rb', line 198

def analyze
  @analyze
end

#auxmgrObject

The framework instance's aux manager. The aux manager is responsible for collecting and cataloging all aux information that comes in from aux modules.


176
177
178
# File 'lib/msf/core/framework.rb', line 176

def auxmgr
  @auxmgr
end

#browser_profilesObject

The framework instance's browser profile store. These profiles are generated by client-side modules and need to be shared across different contexts.


193
194
195
# File 'lib/msf/core/framework.rb', line 193

def browser_profiles
  @browser_profiles
end

#datastoreObject

The global framework datastore that can be used by modules.


170
171
172
# File 'lib/msf/core/framework.rb', line 170

def datastore
  @datastore
end

#dbMetasploit::Framework::DataService::DataProxy

The framework instance's data service proxy


215
216
217
218
219
# File 'lib/msf/core/framework.rb', line 215

def db
  synchronize {
    @db ||= get_db
  }
end

#eventsObject

Event management interface for registering event handler subscribers and for interacting with the correlation engine.


161
162
163
# File 'lib/msf/core/framework.rb', line 161

def events
  @events
end

#featuresObject

The framework instance's feature manager. The feature manager is responsible for configuring feature flags that can change characteristics of framework.


203
204
205
# File 'lib/msf/core/framework.rb', line 203

def features
  @features
end

#has_mingwObject

The framework instance's dependency


209
210
211
# File 'lib/msf/core/framework.rb', line 209

def has_mingw
  @has_mingw
end

#jobsObject

Background job management specific to things spawned from this instance of the framework.


181
182
183
# File 'lib/msf/core/framework.rb', line 181

def jobs
  @jobs
end

#modulesObject

Module manager that contains information about all loaded modules, regardless of type.


166
167
168
# File 'lib/msf/core/framework.rb', line 166

def modules
  @modules
end

#optionsHash (protected)

Options passed to #initialize

Returns:

  • (Hash)

262
263
264
# File 'lib/msf/core/framework.rb', line 262

def options
  @options
end

#pluginsObject

The framework instance's plugin manager. The plugin manager is responsible for exposing an interface that allows for the loading and unloading of plugins.


187
188
189
# File 'lib/msf/core/framework.rb', line 187

def plugins
  @plugins
end

Instance Method Details

#auxiliaryObject

Returns the module set for auxiliary modules


135
136
137
# File 'lib/msf/core/framework.rb', line 135

def auxiliary
  return modules.auxiliary
end

#encodersObject

Returns the module set for encoders.


107
108
109
# File 'lib/msf/core/framework.rb', line 107

def encoders
  return modules.encoders
end

#evasionObject


146
147
148
# File 'lib/msf/core/framework.rb', line 146

def evasion
  return modules.evasion
end

#exploitsObject

Returns the module set for exploits.


114
115
116
# File 'lib/msf/core/framework.rb', line 114

def exploits
  return modules.exploits
end

#inspectObject


100
101
102
# File 'lib/msf/core/framework.rb', line 100

def inspect
  "#<Framework (#{sessions.length} sessions, #{jobs.length} jobs, #{plugins.length} plugins#{db.active ? ", #{db.driver} database active" : ""})>"
end

#nopsObject

Returns the module set for nops


121
122
123
# File 'lib/msf/core/framework.rb', line 121

def nops
  return modules.nops
end

#payloadsObject

Returns the module set for payloads


128
129
130
# File 'lib/msf/core/framework.rb', line 128

def payloads
  return modules.payloads
end

#postObject

Returns the module set for post modules


142
143
144
# File 'lib/msf/core/framework.rb', line 142

def post
  return modules.post
end

#search(search_string) ⇒ Object


251
252
253
254
# File 'lib/msf/core/framework.rb', line 251

def search(search_string)
  search_params = Msf::Modules::Metadata::Search.parse_search_string(search_string)
  Msf::Modules::Metadata::Cache.instance.find(search_params)
end

#sessionsMsf::SessionManager

Session manager that tracks sessions associated with this framework instance over the course of their lifetime.

Returns:


225
226
227
228
229
# File 'lib/msf/core/framework.rb', line 225

def sessions
  synchronize {
    @sessions ||= Msf::SessionManager.new(self)
  }
end

#threadsMsf::ThreadManager

The framework instance's thread manager. The thread manager provides a cleaner way to manage spawned threads

Returns:


235
236
237
238
239
# File 'lib/msf/core/framework.rb', line 235

def threads
  synchronize {
    @threads ||= Msf::ThreadManager.new(self)
  }
end

#threads?true, false

Whether #threads has been initialized

Returns:

  • (true)

    if #threads has been initialized

  • (false)

    otherwise


245
246
247
248
249
# File 'lib/msf/core/framework.rb', line 245

def threads?
  synchronize {
    instance_variable_defined? :@threads
  }
end

#versionObject

Returns the framework version in Major.Minor format.


153
154
155
# File 'lib/msf/core/framework.rb', line 153

def version
  Version
end