2005-07-09 21:18:49 +00:00
|
|
|
require 'msf/core'
|
2005-05-21 17:57:00 +00:00
|
|
|
|
|
|
|
module Msf
|
|
|
|
|
2005-05-22 07:14:16 +00:00
|
|
|
###
|
|
|
|
#
|
|
|
|
# SessionEvents
|
|
|
|
# -------------
|
|
|
|
#
|
|
|
|
# Event notifications that affect sessions.
|
|
|
|
#
|
|
|
|
###
|
2005-05-21 17:57:00 +00:00
|
|
|
module SessionEvents
|
|
|
|
|
2005-05-22 07:14:16 +00:00
|
|
|
# Called when a session is opened
|
2005-05-21 17:57:00 +00:00
|
|
|
def on_session_open(session)
|
|
|
|
end
|
|
|
|
|
2005-05-22 07:14:16 +00:00
|
|
|
# Called when a session is closed
|
2005-05-21 17:57:00 +00:00
|
|
|
def on_session_close(session)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# Session
|
|
|
|
# -------
|
|
|
|
#
|
2005-05-22 07:14:16 +00:00
|
|
|
# The session class represents a post-exploitation, uh, session.
|
2005-07-16 07:32:11 +00:00
|
|
|
# Sessions can be written to, read from, and interacted with. The
|
2005-05-22 07:14:16 +00:00
|
|
|
# underlying medium on which they are backed is arbitrary. For
|
|
|
|
# instance, when an exploit is provided with a command shell,
|
|
|
|
# either through a network connection or locally, the session's
|
|
|
|
# read and write operations end up reading from and writing to
|
|
|
|
# the shell that was spawned. The session object can be seen
|
|
|
|
# as a general means of interacting with various post-exploitation
|
|
|
|
# payloads through a common interface that is not necessarily
|
|
|
|
# tied to a network connection.
|
2005-05-21 17:57:00 +00:00
|
|
|
#
|
|
|
|
###
|
2005-07-16 07:32:11 +00:00
|
|
|
module Session
|
2005-05-22 07:14:16 +00:00
|
|
|
|
2005-07-16 07:32:11 +00:00
|
|
|
include Framework::Offspring
|
|
|
|
|
|
|
|
# Direct descendents
|
|
|
|
require 'msf/core/session/interactive'
|
|
|
|
require 'msf/core/session/basic'
|
|
|
|
|
|
|
|
# Provider interfaces
|
|
|
|
require 'msf/core/session/provider/single_command_execution'
|
|
|
|
require 'msf/core/session/provider/multi_command_execution'
|
|
|
|
require 'msf/core/session/provider/single_command_shell'
|
|
|
|
require 'msf/core/session/provider/multi_command_shell'
|
|
|
|
|
|
|
|
#
|
|
|
|
# By default, sessions are not interactive.
|
|
|
|
#
|
|
|
|
def interactive?
|
|
|
|
false
|
2005-05-22 07:14:16 +00:00
|
|
|
end
|
|
|
|
|
2005-05-25 05:07:22 +00:00
|
|
|
#
|
2005-05-26 06:35:37 +00:00
|
|
|
# Perform session-specific cleanup
|
2005-05-25 05:07:22 +00:00
|
|
|
#
|
2005-05-26 06:35:37 +00:00
|
|
|
def cleanup
|
2005-05-22 07:14:16 +00:00
|
|
|
end
|
|
|
|
|
2005-07-16 07:32:11 +00:00
|
|
|
#
|
|
|
|
# Returns the session's name if it's been assigned one, otherwise
|
|
|
|
# the sid is returned.
|
|
|
|
#
|
|
|
|
def sname
|
|
|
|
return name || sid
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Sets the session's name
|
|
|
|
#
|
|
|
|
def sname=(name)
|
|
|
|
self.name = name
|
|
|
|
end
|
|
|
|
|
|
|
|
attr_accessor :framework, :sid, :name
|
2005-05-22 07:14:16 +00:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
2005-05-21 17:57:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|