metasploit-framework/lib/rex/post/meterpreter/pivot_container.rb

73 lines
1.4 KiB
Ruby
Raw Normal View History

# -*- 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
self.pivot_sessions = {}
2017-07-11 09:42:56 +00:00
self.pivot_listeners = {}
end
2017-07-11 09:42:56 +00:00
#
# Adds a pivot to the container that is indexed by the pivoted
# session guid.
#
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
end
#
2017-07-11 09:42:56 +00:00
# Looks up a pivot instance based on its pivoted session guid.
#
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-11 09:42:56 +00:00
def find_pivot_listener(listener_id)
return self.pivot_listeners[listener_id]
end
#
2017-07-11 09:42:56 +00:00
# Removes a pivot based on its pivoted session guid.
#
def remove_pivot_session(pivot_session_guid)
return self.pivot_sessions.delete(pivot_session_guid)
end
def remove_pivot_listener(listener_id)
return self.pivot_listeners.delete(listener_id)
end
2017-07-11 09:42:56 +00:00
#
# The hash of pivot sessions.
2017-07-11 09:42:56 +00:00
#
attr_reader :pivot_sessions
2017-07-11 09:42:56 +00:00
attr_reader :pivot_listeners
protected
attr_writer :pivot_sessions # :nodoc:
2017-07-11 09:42:56 +00:00
attr_writer :pivot_listeners # :nodoc:
end
end; end; end