2017-07-10 09:59:41 +00:00
|
|
|
# -*- coding: binary -*-
|
|
|
|
|
|
|
|
module Rex
|
|
|
|
module Post
|
|
|
|
module Meterpreter
|
|
|
|
|
2017-07-11 09:42:56 +00:00
|
|
|
###
|
|
|
|
#
|
|
|
|
# This interface is meant to be included by things that are meant to contain
|
|
|
|
# zero or more pivot instances in the form of a hash.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
module PivotContainer
|
|
|
|
|
|
|
|
#
|
|
|
|
# Initializes the pivot association hash
|
|
|
|
#
|
|
|
|
def initialize_pivots
|
2017-08-01 09:02:14 +00:00
|
|
|
self.pivot_sessions = {}
|
2017-07-11 09:42:56 +00:00
|
|
|
self.pivot_listeners = {}
|
2017-07-10 09:59:41 +00:00
|
|
|
end
|
|
|
|
|
2017-07-11 09:42:56 +00:00
|
|
|
#
|
|
|
|
# Adds a pivot to the container that is indexed by the pivoted
|
|
|
|
# session guid.
|
|
|
|
#
|
2017-08-01 09:02:14 +00:00
|
|
|
def add_pivot_session(pivot)
|
|
|
|
self.pivot_sessions[pivot.pivoted_session.session_guid] = pivot
|
2017-07-11 09:42:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def add_pivot_listener(listener)
|
|
|
|
self.pivot_listeners[listener.id] = listener
|
2017-07-10 09:59:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
2017-07-11 09:42:56 +00:00
|
|
|
# Looks up a pivot instance based on its pivoted session guid.
|
2017-07-10 09:59:41 +00:00
|
|
|
#
|
2017-08-01 09:02:14 +00:00
|
|
|
def find_pivot_session(pivot_session_guid)
|
|
|
|
return self.pivot_sessions[pivot_session_guid]
|
2017-07-11 09:42:56 +00:00
|
|
|
end
|
2017-07-10 09:59:41 +00:00
|
|
|
|
2017-07-11 09:42:56 +00:00
|
|
|
def find_pivot_listener(listener_id)
|
|
|
|
return self.pivot_listeners[listener_id]
|
|
|
|
end
|
2017-07-10 09:59:41 +00:00
|
|
|
|
|
|
|
#
|
2017-07-11 09:42:56 +00:00
|
|
|
# Removes a pivot based on its pivoted session guid.
|
2017-07-10 09:59:41 +00:00
|
|
|
#
|
2017-08-01 09:02:14 +00:00
|
|
|
def remove_pivot_session(pivot_session_guid)
|
|
|
|
return self.pivot_sessions.delete(pivot_session_guid)
|
2017-07-10 09:59:41 +00:00
|
|
|
end
|
|
|
|
|
2017-07-18 10:57:46 +00:00
|
|
|
def remove_pivot_listener(listener_id)
|
|
|
|
return self.pivot_listeners.delete(listener_id)
|
|
|
|
end
|
|
|
|
|
2017-07-11 09:42:56 +00:00
|
|
|
#
|
2017-08-01 09:02:14 +00:00
|
|
|
# The hash of pivot sessions.
|
2017-07-11 09:42:56 +00:00
|
|
|
#
|
2017-08-01 09:02:14 +00:00
|
|
|
attr_reader :pivot_sessions
|
2017-07-11 09:42:56 +00:00
|
|
|
|
|
|
|
attr_reader :pivot_listeners
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
2017-08-01 09:02:14 +00:00
|
|
|
attr_writer :pivot_sessions # :nodoc:
|
2017-07-11 09:42:56 +00:00
|
|
|
|
|
|
|
attr_writer :pivot_listeners # :nodoc:
|
|
|
|
|
2017-07-10 09:59:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end; end; end
|