2005-07-09 21:18:49 +00:00
|
|
|
require 'msf/core'
|
2009-11-09 01:50:44 +00:00
|
|
|
require 'msf/util'
|
2005-05-21 17:57:00 +00:00
|
|
|
|
|
|
|
module Msf
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This class is the primary context that modules, scripts, and user
|
|
|
|
# interfaces interact with. It ties everything together.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
class Framework
|
2005-07-14 06:34:58 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Versioning information
|
|
|
|
#
|
2009-11-09 01:50:44 +00:00
|
|
|
|
2005-07-14 06:34:58 +00:00
|
|
|
Major = 3
|
2009-12-10 05:48:12 +00:00
|
|
|
Minor = 3
|
2009-12-10 22:32:36 +00:00
|
|
|
Point = 3
|
2009-12-23 06:03:57 +00:00
|
|
|
Release = "-release"
|
2009-11-30 20:17:55 +00:00
|
|
|
|
|
|
|
if(Point)
|
|
|
|
Version = "#{Major}.#{Minor}.#{Point}#{Release}"
|
|
|
|
else
|
|
|
|
Version = "#{Major}.#{Minor}#{Release}"
|
|
|
|
end
|
|
|
|
|
2009-11-09 03:22:24 +00:00
|
|
|
Revision = "$Revision$"
|
|
|
|
|
2009-11-09 01:50:44 +00:00
|
|
|
|
|
|
|
# Repository information
|
|
|
|
RepoRevision = ::Msf::Util::SVN.revision
|
|
|
|
RepoUpdated = ::Msf::Util::SVN.updated
|
|
|
|
RepoUpdatedDays = ::Msf::Util::SVN.days_since_update
|
|
|
|
RepoUpdatedDaysNote = ::Msf::Util::SVN.last_updated_friendly
|
2009-11-13 22:50:12 +00:00
|
|
|
RepoUpdatedDate = ::Msf::Util::SVN.last_updated_date
|
2009-11-09 01:50:44 +00:00
|
|
|
RepoRoot = ::Msf::Util::SVN.root
|
2009-09-15 13:50:32 +00:00
|
|
|
|
|
|
|
# API Version
|
|
|
|
APIMajor = 1
|
|
|
|
APIMinor = 0
|
2009-11-09 01:50:44 +00:00
|
|
|
|
2009-09-15 13:50:32 +00:00
|
|
|
# Base/API Version
|
|
|
|
VersionCore = Major + (Minor / 10.0)
|
|
|
|
VersionAPI = APIMajor + (APIMinor / 10.0)
|
2009-11-09 01:50:44 +00:00
|
|
|
|
2005-07-13 18:06:12 +00:00
|
|
|
#
|
|
|
|
# Mixin meant to be included into all classes that can have instances that
|
|
|
|
# should be tied to the framework, such as modules.
|
|
|
|
#
|
|
|
|
module Offspring
|
2005-10-19 03:37:22 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# A reference to the framework instance from which this offspring was
|
|
|
|
# derived.
|
|
|
|
#
|
2009-11-09 01:50:44 +00:00
|
|
|
attr_accessor :framework
|
2005-07-13 18:06:12 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
require 'msf/core/module_manager'
|
2005-07-16 08:12:58 +00:00
|
|
|
require 'msf/core/session_manager'
|
2006-03-21 04:37:48 +00:00
|
|
|
require 'msf/core/db_manager'
|
2005-05-21 17:57:00 +00:00
|
|
|
|
2005-10-19 03:37:22 +00:00
|
|
|
#
|
|
|
|
# Creates an instance of the framework context.
|
|
|
|
#
|
2009-01-02 07:29:56 +00:00
|
|
|
def initialize(opts={})
|
2009-11-09 01:50:44 +00:00
|
|
|
|
2009-01-02 07:29:56 +00:00
|
|
|
# Allow specific module types to be loaded
|
|
|
|
types = opts[:module_types] || MODULE_TYPES
|
|
|
|
|
2006-03-21 04:37:48 +00:00
|
|
|
self.events = EventDispatcher.new(self)
|
2009-01-02 07:29:56 +00:00
|
|
|
self.modules = ModuleManager.new(self,types)
|
2005-07-16 08:12:58 +00:00
|
|
|
self.sessions = SessionManager.new(self)
|
2005-07-14 06:34:58 +00:00
|
|
|
self.datastore = DataStore.new
|
2005-09-22 04:53:46 +00:00
|
|
|
self.jobs = Rex::JobContainer.new
|
2005-11-19 16:25:26 +00:00
|
|
|
self.plugins = PluginManager.new(self)
|
2006-03-21 04:37:48 +00:00
|
|
|
self.db = DBManager.new(self)
|
2005-05-22 07:14:16 +00:00
|
|
|
end
|
|
|
|
|
2009-12-01 21:42:14 +00:00
|
|
|
def inspect
|
|
|
|
"#<Framework (#{sessions.length} sessions, #{jobs.length} jobs, #{plugins.length} plugins#{db.active ? ", database active" : ""})>"
|
|
|
|
end
|
|
|
|
|
2005-07-12 14:32:44 +00:00
|
|
|
#
|
2005-10-19 03:37:22 +00:00
|
|
|
# Returns the module set for encoders.
|
2005-07-12 14:32:44 +00:00
|
|
|
#
|
2005-05-22 07:14:16 +00:00
|
|
|
def encoders
|
|
|
|
return modules.encoders
|
|
|
|
end
|
|
|
|
|
2005-07-12 14:32:44 +00:00
|
|
|
#
|
2005-10-19 03:37:22 +00:00
|
|
|
# Returns the module set for exploits.
|
2005-07-12 14:32:44 +00:00
|
|
|
#
|
2005-05-22 07:25:15 +00:00
|
|
|
def exploits
|
|
|
|
return modules.exploits
|
|
|
|
end
|
|
|
|
|
2005-07-12 14:32:44 +00:00
|
|
|
#
|
|
|
|
# Returns the module set for nops
|
|
|
|
#
|
2005-05-22 07:14:16 +00:00
|
|
|
def nops
|
|
|
|
return modules.nops
|
|
|
|
end
|
|
|
|
|
2005-07-12 14:32:44 +00:00
|
|
|
#
|
|
|
|
# Returns the module set for payloads
|
|
|
|
#
|
2005-05-22 07:25:15 +00:00
|
|
|
def payloads
|
|
|
|
return modules.payloads
|
2005-05-22 07:14:16 +00:00
|
|
|
end
|
2005-05-21 17:57:00 +00:00
|
|
|
|
2005-07-12 14:32:44 +00:00
|
|
|
#
|
2006-01-24 03:59:44 +00:00
|
|
|
# Returns the module set for auxiliary modules
|
2005-07-12 14:32:44 +00:00
|
|
|
#
|
2006-01-24 03:59:44 +00:00
|
|
|
def auxiliary
|
|
|
|
return modules.auxiliary
|
2005-05-21 17:57:00 +00:00
|
|
|
end
|
|
|
|
|
2005-11-24 03:31:23 +00:00
|
|
|
#
|
|
|
|
# Returns the framework version in Major.Minor format.
|
|
|
|
#
|
|
|
|
def version
|
2009-11-09 01:50:44 +00:00
|
|
|
Version
|
2005-11-24 03:31:23 +00:00
|
|
|
end
|
|
|
|
|
2005-10-19 03:37:22 +00:00
|
|
|
#
|
|
|
|
# Event management interface for registering event handler subscribers and
|
|
|
|
# for interacting with the correlation engine.
|
|
|
|
#
|
2005-05-21 17:57:00 +00:00
|
|
|
attr_reader :events
|
2005-10-19 03:37:22 +00:00
|
|
|
#
|
|
|
|
# Module manager that contains information about all loaded modules,
|
|
|
|
# regardless of type.
|
|
|
|
#
|
2005-05-22 07:14:16 +00:00
|
|
|
attr_reader :modules
|
2005-10-19 03:37:22 +00:00
|
|
|
#
|
|
|
|
# Session manager that tracks sessions associated with this framework
|
|
|
|
# instance over the course of their lifetime.
|
|
|
|
#
|
2005-07-16 08:12:58 +00:00
|
|
|
attr_reader :sessions
|
2005-10-19 03:37:22 +00:00
|
|
|
#
|
|
|
|
# The global framework datastore that can be used by modules.
|
|
|
|
#
|
2005-07-14 06:34:58 +00:00
|
|
|
attr_reader :datastore
|
2005-10-19 03:37:22 +00:00
|
|
|
#
|
2006-01-24 03:59:44 +00:00
|
|
|
# The framework instance's aux manager. The aux manager is responsible
|
|
|
|
# for collecting and catalogging all aux information that comes in from
|
|
|
|
# aux modules.
|
2005-10-29 13:47:07 +00:00
|
|
|
#
|
2006-01-24 03:59:44 +00:00
|
|
|
attr_reader :auxmgr
|
2005-10-29 13:47:07 +00:00
|
|
|
#
|
2005-10-19 03:37:22 +00:00
|
|
|
# Background job management specific to things spawned from this instance
|
|
|
|
# of the framework.
|
|
|
|
#
|
2005-09-22 04:53:46 +00:00
|
|
|
attr_reader :jobs
|
2005-11-19 16:25:26 +00:00
|
|
|
#
|
|
|
|
# The framework instance's plugin manager. The plugin manager is
|
|
|
|
# responsible for exposing an interface that allows for the loading and
|
|
|
|
# unloading of plugins.
|
|
|
|
#
|
|
|
|
attr_reader :plugins
|
2006-03-21 04:37:48 +00:00
|
|
|
#
|
|
|
|
# The framework instance's db manager. The db manager
|
|
|
|
# maintains the database db and handles db events
|
|
|
|
#
|
|
|
|
attr_reader :db
|
2007-01-30 04:48:35 +00:00
|
|
|
|
2005-05-21 17:57:00 +00:00
|
|
|
protected
|
|
|
|
|
2005-10-19 03:37:22 +00:00
|
|
|
attr_writer :events # :nodoc:
|
|
|
|
attr_writer :modules # :nodoc:
|
|
|
|
attr_writer :sessions # :nodoc:
|
|
|
|
attr_writer :datastore # :nodoc:
|
2006-01-24 03:59:44 +00:00
|
|
|
attr_writer :auxmgr # :nodoc:
|
2005-10-19 03:37:22 +00:00
|
|
|
attr_writer :jobs # :nodoc:
|
2005-11-19 16:25:26 +00:00
|
|
|
attr_writer :plugins # :nodoc:
|
2006-03-21 04:37:48 +00:00
|
|
|
attr_writer :db # :nodoc:
|
2005-05-21 17:57:00 +00:00
|
|
|
end
|
|
|
|
|
2008-11-10 22:15:23 +00:00
|
|
|
end
|
2009-11-09 01:50:44 +00:00
|
|
|
|