73 lines
1.3 KiB
Ruby
73 lines
1.3 KiB
Ruby
# -*- coding: binary -*-
|
|
|
|
module Rex
|
|
module Post
|
|
module Meterpreter
|
|
|
|
###
|
|
#
|
|
# 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
|
|
self.pivots = {}
|
|
self.pivot_listeners = {}
|
|
end
|
|
|
|
#
|
|
# Adds a pivot to the container that is indexed by the pivoted
|
|
# session guid.
|
|
#
|
|
def add_pivot(pivot)
|
|
self.pivots[pivot.pivoted_session.session_guid] = pivot
|
|
end
|
|
|
|
def add_pivot_listener(listener)
|
|
self.pivot_listeners[listener.id] = listener
|
|
end
|
|
|
|
#
|
|
# Looks up a pivot instance based on its pivoted session guid.
|
|
#
|
|
def find_pivot(pivot_session_guid)
|
|
return self.pivots[pivot_session_guid]
|
|
end
|
|
|
|
def find_pivot_listener(listener_id)
|
|
return self.pivot_listeners[listener_id]
|
|
end
|
|
|
|
#
|
|
# Removes a pivot based on its pivoted session guid.
|
|
#
|
|
def remove_pivot(pivot_session_guid)
|
|
return self.pivots.delete(pivot_session_guid)
|
|
end
|
|
|
|
def remove_pivot_listener(listener_id)
|
|
return self.pivot_listeners.delete(listener_id)
|
|
end
|
|
|
|
#
|
|
# The hash of pivots.
|
|
#
|
|
attr_reader :pivots
|
|
|
|
attr_reader :pivot_listeners
|
|
|
|
protected
|
|
|
|
attr_writer :pivots # :nodoc:
|
|
|
|
attr_writer :pivot_listeners # :nodoc:
|
|
|
|
end
|
|
|
|
end; end; end
|