Class: Rex::Post::Meterpreter::Channels::Pools::StreamPool

Inherits:
Rex::Post::Meterpreter::Channels::Pool show all
Includes:
IO::StreamAbstraction
Defined in:
lib/rex/post/meterpreter/channels/pools/stream_pool.rb

Overview

StreamPool


This class represents a channel that is associated with a streaming pool that has no definite end-point. While this may seem a paradox given the stream class of channels, it’s in fact dinstinct because streams automatically forward traffic between the two ends of the channel whereas stream pools are always requested data in a single direction.

Instance Attribute Summary

Attributes inherited from Rex::Post::Meterpreter::Channels::Pool

#_eof

Attributes inherited from Rex::Post::Meterpreter::Channel

#cid, #client, #cls, #flags, #params, #type

Instance Method Summary collapse

Methods inherited from Rex::Post::Meterpreter::Channels::Pool

cls, #pos, #read

Methods inherited from Rex::Post::Meterpreter::Channel

_close, #_close, #_read, #_write, #close, #close_read, #close_write, #closed?, create, #dio_handler, #dio_map, #dio_read_handler, finalize, #flag?, #interactive, #read, request_handler, #synchronous?, #write

Methods included from InboundPacketHandler

#request_handler, #response_handler

Constructor Details

#initialize(client, cid, type, flags, packet, **_) ⇒ StreamPool

Initializes the file channel instance



37
38
39
40
41
# File 'lib/rex/post/meterpreter/channels/pools/stream_pool.rb', line 37

def initialize(client, cid, type, flags, packet, **_)
  super(client, cid, type, flags, packet)

  initialize_abstraction
end

Instance Method Details

#cleanupObject

Cleans up resources used by the channel.



95
96
97
98
99
# File 'lib/rex/post/meterpreter/channels/pools/stream_pool.rb', line 95

def cleanup
  super

  cleanup_abstraction
end

#dio_close_handler(packet) ⇒ Object

Closes the local half of the pool stream.



86
87
88
89
90
# File 'lib/rex/post/meterpreter/channels/pools/stream_pool.rb', line 86

def dio_close_handler(packet)
  rsock.close

  return super(packet)
end

#dio_write_handler(packet, data) ⇒ Object

Transfers data to the local half of the pool for reading.



73
74
75
76
77
78
79
80
81
# File 'lib/rex/post/meterpreter/channels/pools/stream_pool.rb', line 73

def dio_write_handler(packet, data)
  rv = Rex::ThreadSafe.select(nil, [rsock], nil, 0.01)
  if(rv)
    rsock.write(data)
    return true
  else
    return false
  end
end

#eofObject

This method returns whether or not eof has been returned.



66
67
68
# File 'lib/rex/post/meterpreter/channels/pools/stream_pool.rb', line 66

def eof
  return false
end

#seekObject

This method seeks to an offset in the pool.

Raises:

  • (NotImplementedError)


59
60
61
# File 'lib/rex/post/meterpreter/channels/pools/stream_pool.rb', line 59

def seek
  raise NotImplementedError
end

#tellObject

This method returns the current offset into the pool.

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/rex/post/meterpreter/channels/pools/stream_pool.rb', line 52

def tell
  raise NotImplementedError
end