CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/post/meterpreter/pivot_container.rb
Views: 1904
1
# -*- coding: binary -*-
2
3
module Rex
4
module Post
5
module Meterpreter
6
7
###
8
#
9
# This interface is meant to be included by things that are meant to contain
10
# zero or more pivot instances in the form of a hash.
11
#
12
###
13
module PivotContainer
14
15
#
16
# Initializes the pivot association hash
17
#
18
def initialize_pivots
19
self.pivot_sessions = {}
20
self.pivot_listeners = {}
21
end
22
23
#
24
# Adds a pivot to the container that is indexed by the pivoted
25
# session guid.
26
#
27
def add_pivot_session(pivot)
28
self.pivot_sessions[pivot.pivoted_session.session_guid] = pivot
29
end
30
31
def add_pivot_listener(listener)
32
self.pivot_listeners[listener.id] = listener
33
end
34
35
#
36
# Looks up a pivot instance based on its pivoted session guid.
37
#
38
def find_pivot_session(pivot_session_guid)
39
return self.pivot_sessions[pivot_session_guid]
40
end
41
42
def find_pivot_listener(listener_id)
43
return self.pivot_listeners[listener_id]
44
end
45
46
#
47
# Removes a pivot based on its pivoted session guid.
48
#
49
def remove_pivot_session(pivot_session_guid)
50
return self.pivot_sessions.delete(pivot_session_guid)
51
end
52
53
def remove_pivot_listener(listener_id)
54
return self.pivot_listeners.delete(listener_id)
55
end
56
57
#
58
# The hash of pivot sessions.
59
#
60
attr_reader :pivot_sessions
61
62
attr_reader :pivot_listeners
63
64
protected
65
66
attr_writer :pivot_sessions # :nodoc:
67
68
attr_writer :pivot_listeners # :nodoc:
69
70
end
71
72
end; end; end
73
74