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
|
2010-12-17 18:35:23 +00:00
|
|
|
Minor = 6
|
|
|
|
Point = 0
|
|
|
|
Release = "-dev"
|
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
|
2010-12-27 17:46:42 +00:00
|
|
|
|
2010-10-04 03:07:58 +00:00
|
|
|
# EICAR canary
|
|
|
|
EICARCorrupted = ::Msf::Util::EXE.is_eicar_corrupted?
|
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
|
|
|
|
|
2010-11-12 06:19:49 +00:00
|
|
|
require 'msf/core/thread_manager'
|
2005-07-13 18:06:12 +00:00
|
|
|
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'
|
2010-01-15 00:32:48 +00:00
|
|
|
require 'msf/core/event_dispatcher'
|
2005-05-21 17:57:00 +00:00
|
|
|
|
2010-11-12 06:19:49 +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
|
|
|
|
|
2010-11-12 06:19:49 +00:00
|
|
|
self.threads = ThreadManager.new(self)
|
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)
|
2010-08-05 02:24:40 +00:00
|
|
|
self.db = DBManager.new(self, opts)
|
2010-12-27 17:46:42 +00:00
|
|
|
|
2010-11-12 06:19:49 +00:00
|
|
|
# Configure the thread factory
|
|
|
|
Rex::ThreadFactory.provider = self.threads
|
2010-01-28 00:00:00 +00:00
|
|
|
|
2010-01-15 00:32:48 +00:00
|
|
|
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)
|
2005-05-22 07:14:16 +00:00
|
|
|
end
|
|
|
|
|
2009-12-01 21:42:14 +00:00
|
|
|
def inspect
|
2010-01-14 18:57:54 +00:00
|
|
|
"#<Framework (#{sessions.length} sessions, #{jobs.length} jobs, #{plugins.length} plugins#{db.active ? ", #{db.driver} database active" : ""})>"
|
2009-12-01 21:42:14 +00:00
|
|
|
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
|
|
|
|
|
2010-12-27 17:46:42 +00:00
|
|
|
#
|
|
|
|
# Returns the module set for post modules
|
|
|
|
#
|
|
|
|
def post
|
|
|
|
return modules.post
|
|
|
|
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
|
2010-11-12 06:19:49 +00:00
|
|
|
#
|
|
|
|
# The framework instance's thread manager. The thread manager
|
|
|
|
# provides a cleaner way to manage spawned threads
|
|
|
|
#
|
|
|
|
attr_reader :threads
|
2010-12-27 17:46:42 +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:
|
2010-11-12 06:19:49 +00:00
|
|
|
attr_writer :threads # :nodoc:
|
2005-05-21 17:57:00 +00:00
|
|
|
end
|
|
|
|
|
2010-01-15 00:32:48 +00:00
|
|
|
class FrameworkEventSubscriber
|
|
|
|
include Framework::Offspring
|
|
|
|
def initialize(framework)
|
|
|
|
self.framework = framework
|
|
|
|
end
|
|
|
|
|
|
|
|
def report_event(data)
|
2010-01-15 04:34:12 +00:00
|
|
|
if framework.db.active
|
|
|
|
framework.db.report_event(data)
|
|
|
|
end
|
2010-01-15 00:32:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
include GeneralEventSubscriber
|
2010-03-16 19:32:54 +00:00
|
|
|
|
2010-03-17 14:07:45 +00:00
|
|
|
#
|
2010-03-16 19:32:54 +00:00
|
|
|
# Generic handler for module events
|
|
|
|
#
|
|
|
|
def module_event(name, instance, opts={})
|
2010-01-15 04:34:12 +00:00
|
|
|
if framework.db.active
|
2010-02-26 18:45:24 +00:00
|
|
|
event = {
|
2010-02-26 18:52:22 +00:00
|
|
|
:workspace => framework.db.find_workspace(instance.workspace),
|
2010-03-17 14:07:45 +00:00
|
|
|
:name => name,
|
|
|
|
:username => instance.owner,
|
2010-02-26 18:45:24 +00:00
|
|
|
:info => {
|
2010-03-11 14:33:48 +00:00
|
|
|
:module_name => instance.fullname,
|
2010-03-27 02:39:52 +00:00
|
|
|
:module_uuid => instance.uuid
|
2010-03-16 19:32:54 +00:00
|
|
|
}.merge(opts)
|
2010-02-26 18:45:24 +00:00
|
|
|
}
|
2010-03-17 14:07:45 +00:00
|
|
|
|
2010-02-26 18:45:24 +00:00
|
|
|
report_event(event)
|
2010-01-15 04:34:12 +00:00
|
|
|
end
|
2010-01-15 00:32:48 +00:00
|
|
|
end
|
2010-03-16 19:32:54 +00:00
|
|
|
def on_module_run(instance)
|
|
|
|
opts = { :datastore => instance.datastore.to_h }
|
|
|
|
module_event('module_run', instance, opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
def on_module_complete(instance)
|
|
|
|
module_event('module_complete', instance)
|
|
|
|
end
|
|
|
|
|
|
|
|
def on_module_error(instance, exception=nil)
|
|
|
|
module_event('module_error', instance, :exception => exception.to_s)
|
|
|
|
end
|
2010-01-15 00:32:48 +00:00
|
|
|
|
|
|
|
include ::Msf::UiEventSubscriber
|
|
|
|
def on_ui_command(command)
|
2010-01-15 04:34:12 +00:00
|
|
|
if framework.db.active
|
|
|
|
report_event(:name => "ui_command", :info => {:command => command})
|
|
|
|
end
|
2010-01-15 00:32:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def on_ui_stop()
|
2010-01-15 04:34:12 +00:00
|
|
|
if framework.db.active
|
|
|
|
report_event(:name => "ui_stop")
|
|
|
|
end
|
2010-01-15 00:32:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def on_ui_start(rev)
|
|
|
|
#
|
|
|
|
# The database is not active at startup time, so this event can never
|
|
|
|
# be saved to the db. Might look into storing it in a flat file or
|
|
|
|
# something later.
|
|
|
|
#
|
|
|
|
#info = { :revision => rev }
|
|
|
|
#report_event(:name => "ui_start", :info => info)
|
|
|
|
end
|
|
|
|
|
2010-03-16 19:32:54 +00:00
|
|
|
#
|
|
|
|
# Generic handler for session events
|
|
|
|
#
|
2010-01-28 02:17:57 +00:00
|
|
|
def session_event(name, session, opts={})
|
2010-12-18 03:37:27 +00:00
|
|
|
address = nil
|
2010-12-27 17:46:42 +00:00
|
|
|
|
2010-12-18 03:37:27 +00:00
|
|
|
if session.respond_to? :peerhost and session.peerhost.to_s.length > 0
|
2010-03-19 22:17:07 +00:00
|
|
|
address = session.peerhost
|
2010-12-18 03:37:27 +00:00
|
|
|
elsif session.respond_to? :tunnel_peer and session.tunnel_peer.to_s.length > 0
|
2010-03-19 22:17:07 +00:00
|
|
|
address = session.tunnel_peer[0, session.tunnel_peer.rindex(":") || session.tunnel_peer.length ]
|
2010-12-18 03:37:27 +00:00
|
|
|
elsif session.respond_to? :target_host and session.target_host.to_s.length > 0
|
2010-03-19 22:17:07 +00:00
|
|
|
address = session.target_host
|
|
|
|
else
|
|
|
|
elog("Session with no peerhost/tunnel_peer")
|
|
|
|
dlog("#{session.inspect}", LEV_3)
|
|
|
|
return
|
|
|
|
end
|
2010-01-28 02:17:57 +00:00
|
|
|
|
2010-01-28 00:00:00 +00:00
|
|
|
if framework.db.active
|
2010-03-19 22:17:07 +00:00
|
|
|
ws = framework.db.find_workspace(session.workspace)
|
2010-01-28 00:00:00 +00:00
|
|
|
event = {
|
2010-03-19 22:17:07 +00:00
|
|
|
:workspace => ws,
|
2010-03-17 14:07:45 +00:00
|
|
|
:username => session.username,
|
2010-01-28 00:00:00 +00:00
|
|
|
:name => name,
|
2010-01-28 02:17:57 +00:00
|
|
|
:host => address,
|
2010-01-28 00:00:00 +00:00
|
|
|
:info => {
|
2010-03-16 15:11:07 +00:00
|
|
|
:session_id => session.sid,
|
|
|
|
:session_info => session.info,
|
|
|
|
:session_uuid => session.uuid,
|
2010-03-20 18:40:41 +00:00
|
|
|
:session_type => session.type,
|
2010-03-16 15:11:07 +00:00
|
|
|
:username => session.username,
|
2010-06-25 18:33:41 +00:00
|
|
|
:target_host => address,
|
2010-03-16 15:11:07 +00:00
|
|
|
:via_exploit => session.via_exploit,
|
2010-03-22 23:24:08 +00:00
|
|
|
:via_payload => session.via_payload,
|
2010-03-27 02:39:52 +00:00
|
|
|
:tunnel_peer => session.tunnel_peer,
|
|
|
|
:exploit_uuid => session.exploit_uuid
|
2010-01-28 02:17:57 +00:00
|
|
|
}.merge(opts)
|
2010-01-28 00:00:00 +00:00
|
|
|
}
|
|
|
|
report_event(event)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-01-15 00:32:48 +00:00
|
|
|
require 'msf/core/session'
|
2010-12-27 17:46:42 +00:00
|
|
|
|
2010-01-15 00:32:48 +00:00
|
|
|
include ::Msf::SessionEvent
|
2010-12-27 17:46:42 +00:00
|
|
|
|
2010-01-15 00:32:48 +00:00
|
|
|
def on_session_open(session)
|
2010-03-20 18:40:41 +00:00
|
|
|
opts = { :datastore => session.exploit_datastore.to_h, :critical => true }
|
2010-02-26 01:09:23 +00:00
|
|
|
session_event('session_open', session, opts)
|
2010-03-19 22:17:07 +00:00
|
|
|
if framework.db.active
|
2010-05-02 16:25:52 +00:00
|
|
|
framework.db.sync
|
2010-12-27 17:46:42 +00:00
|
|
|
|
2010-12-18 03:37:27 +00:00
|
|
|
address = nil
|
2010-12-27 17:46:42 +00:00
|
|
|
|
2010-12-18 03:37:27 +00:00
|
|
|
if session.respond_to? :peerhost and session.peerhost.to_s.length > 0
|
2010-03-19 22:17:07 +00:00
|
|
|
address = session.peerhost
|
2010-12-18 03:37:27 +00:00
|
|
|
elsif session.respond_to? :tunnel_peer and session.tunnel_peer.to_s.length > 0
|
2010-03-19 22:17:07 +00:00
|
|
|
address = session.tunnel_peer[0, session.tunnel_peer.rindex(":") || session.tunnel_peer.length ]
|
2010-12-18 03:37:27 +00:00
|
|
|
elsif session.respond_to? :target_host and session.target_host.to_s.length > 0
|
2010-03-19 22:17:07 +00:00
|
|
|
address = session.target_host
|
|
|
|
else
|
|
|
|
elog("Session with no peerhost/tunnel_peer")
|
|
|
|
dlog("#{session.inspect}", LEV_3)
|
|
|
|
return
|
|
|
|
end
|
2010-12-18 03:37:27 +00:00
|
|
|
|
2010-03-19 22:17:07 +00:00
|
|
|
# Since we got a session, we know the host is vulnerable to something.
|
|
|
|
# If the exploit used was multi/handler, though, we don't know what
|
|
|
|
# it's vulnerable to, so it isn't really useful to save it.
|
|
|
|
if session.via_exploit and session.via_exploit != "exploit/multi/handler"
|
2010-08-24 21:57:04 +00:00
|
|
|
wspace = framework.db.find_workspace(session.workspace)
|
|
|
|
host = wspace.hosts.find_by_address(address)
|
2010-12-27 17:46:42 +00:00
|
|
|
return unless host
|
2010-08-24 21:57:04 +00:00
|
|
|
port = session.exploit_datastore["RPORT"]
|
|
|
|
service = (port ? host.services.find_by_port(port) : nil)
|
2010-03-21 23:12:37 +00:00
|
|
|
mod = framework.modules.create(session.via_exploit)
|
2010-08-24 21:57:04 +00:00
|
|
|
vuln_info = {
|
|
|
|
:host => host.address,
|
2010-03-19 22:17:07 +00:00
|
|
|
:name => session.via_exploit,
|
2010-03-21 23:12:37 +00:00
|
|
|
:refs => mod.references,
|
2010-08-24 21:57:04 +00:00
|
|
|
:workspace => wspace
|
2010-03-19 22:17:07 +00:00
|
|
|
}
|
2010-08-24 21:57:04 +00:00
|
|
|
framework.db.report_vuln(vuln_info)
|
|
|
|
# Exploit info is like vuln info, except it's /just/ for storing
|
|
|
|
# successful exploits in an unserialized way. Yes, there is
|
|
|
|
# duplication, but it makes exporting a score card about a
|
|
|
|
# million times easier. TODO: See if vuln/exploit can get fixed up
|
|
|
|
# to one useful table.
|
|
|
|
exploit_info = {
|
|
|
|
:name => session.via_exploit,
|
|
|
|
:payload => session.via_payload,
|
|
|
|
:workspace => wspace,
|
|
|
|
:host => host,
|
|
|
|
:service => service,
|
|
|
|
:session_uuid => session.uuid
|
|
|
|
}
|
|
|
|
ret = framework.db.report_exploit(exploit_info)
|
2010-03-19 22:17:07 +00:00
|
|
|
end
|
|
|
|
end
|
2010-01-15 00:32:48 +00:00
|
|
|
end
|
|
|
|
|
2010-03-22 01:13:58 +00:00
|
|
|
def on_session_upload(session, lpath, rpath)
|
|
|
|
session_event('session_upload', session, :local_path => lpath, :remote_path => rpath)
|
|
|
|
end
|
2010-03-22 20:56:22 +00:00
|
|
|
def on_session_download(session, rpath, lpath)
|
2010-03-22 01:13:58 +00:00
|
|
|
session_event('session_download', session, :local_path => lpath, :remote_path => rpath)
|
|
|
|
end
|
|
|
|
def on_session_filedelete(session, path)
|
|
|
|
session_event('session_filedelete', session, :path => path)
|
|
|
|
end
|
|
|
|
|
2010-02-23 05:59:30 +00:00
|
|
|
def on_session_close(session, reason='')
|
2010-01-28 00:00:00 +00:00
|
|
|
session_event('session_close', session)
|
2010-01-15 00:32:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def on_session_interact(session)
|
2010-01-28 00:00:00 +00:00
|
|
|
session_event('session_interact', session)
|
2010-01-15 00:32:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def on_session_command(session, command)
|
2010-01-28 02:43:54 +00:00
|
|
|
session_event('session_command', session, :command => command)
|
2010-01-15 00:32:48 +00:00
|
|
|
end
|
|
|
|
|
2010-02-26 21:55:30 +00:00
|
|
|
def on_session_output(session, output)
|
2010-03-11 19:18:39 +00:00
|
|
|
# Break up the output into chunks that will fit into the database.
|
|
|
|
buff = output.dup
|
|
|
|
chunks = []
|
|
|
|
if buff.length > 1024
|
|
|
|
while buff.length > 0
|
|
|
|
chunks << buff.slice!(0,1024)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
chunks << buff
|
|
|
|
end
|
|
|
|
chunks.each { |chunk|
|
|
|
|
session_event('session_output', session, :output => chunk)
|
|
|
|
}
|
2010-02-26 21:55:30 +00:00
|
|
|
end
|
|
|
|
|
2010-01-15 00:32:48 +00:00
|
|
|
|
2010-01-28 00:00:00 +00:00
|
|
|
#
|
2010-01-15 00:32:48 +00:00
|
|
|
# This is covered by on_module_run and on_session_open, so don't bother
|
|
|
|
#
|
|
|
|
#require 'msf/core/exploit'
|
|
|
|
#include ExploitEvent
|
|
|
|
#def on_exploit_success(exploit, session)
|
|
|
|
#end
|
|
|
|
|
|
|
|
end
|
2008-11-10 22:15:23 +00:00
|
|
|
end
|
2009-11-09 01:50:44 +00:00
|
|
|
|