Class: Rex::Post::Meterpreter::Pivot
- Inherits:
-
Object
- Object
- Rex::Post::Meterpreter::Pivot
- Extended by:
- InboundPacketHandler
- Defined in:
- lib/rex/post/meterpreter/pivot.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
The associated meterpreter client instance.
-
#pivoted_session ⇒ Object
Returns the value of attribute pivoted_session.
Class Method Summary collapse
-
.request_handler(client, packet) ⇒ Object
Class request handler for all channels that dispatches requests to the appropriate class instance's DIO handler.
Instance Method Summary collapse
-
#cleanup ⇒ Object
protected
Cleans up any lingering resources.
-
#initialize(client, session_guid, listener_id) ⇒ Pivot
constructor
A new instance of Pivot.
Methods included from InboundPacketHandler
request_handler, response_handler
Constructor Details
#initialize(client, session_guid, listener_id) ⇒ Pivot
Returns a new instance of Pivot.
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/rex/post/meterpreter/pivot.rb', line 138 def initialize(client, session_guid, listener_id) self.client = client opts = { pivot_session: client, session_guid: session_guid } listener = client.find_pivot_listener(listener_id) self.pivoted_session = listener.session_class.new(nil, opts) self.pivoted_session.framework = self.client.framework registration = Proc.new do self.pivoted_session.bootstrap({'AutoVerifySessionTimeout' => 30}) self.client.framework.sessions.register(self.pivoted_session) begin self.client.framework.events.on_session_open(self.pivoted_session) rescue ::Exception => e wlog("Exception in on_session_open event handler: #{e.class}: #{e}") wlog("Call Stack\n#{e.backtrace.join("\n")}") end end self.client.framework.sessions.schedule registration end |
Instance Attribute Details
#client ⇒ Object
The associated meterpreter client instance
36 37 38 |
# File 'lib/rex/post/meterpreter/pivot.rb', line 36 def client @client end |
#pivoted_session ⇒ Object
Returns the value of attribute pivoted_session.
38 39 40 |
# File 'lib/rex/post/meterpreter/pivot.rb', line 38 def pivoted_session @pivoted_session end |
Class Method Details
.request_handler(client, packet) ⇒ Object
Class request handler for all channels that dispatches requests to the appropriate class instance's DIO handler
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rex/post/meterpreter/pivot.rb', line 47 def request_handler(client, packet) handled = false if packet.method == COMMAND_ID_CORE_PIVOT_SESSION_NEW handled = true session_guid = packet.get_tlv_value(TLV_TYPE_SESSION_GUID) listener_id = packet.get_tlv_value(TLV_TYPE_PIVOT_ID) client.add_pivot_session(Pivot.new(client, session_guid, listener_id)) elsif packet.method == COMMAND_ID_CORE_PIVOT_SESSION_DIED handled = true session_guid = packet.get_tlv_value(TLV_TYPE_SESSION_GUID) pivot = client.find_pivot_session(session_guid) if pivot pivot.pivoted_session.kill('Died') client.remove_pivot_session(session_guid) end end handled end |
Instance Method Details
#cleanup ⇒ Object (protected)
Cleans up any lingering resources
169 170 |
# File 'lib/rex/post/meterpreter/pivot.rb', line 169 def cleanup end |