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 included from IO::StreamAbstraction

#lsock, #rsock

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

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

Instance Method Summary collapse

Methods included from IO::StreamAbstraction

#cleanup_abstraction, #close, #initialize_abstraction, #localinfo, #peerinfo, #shutdown, #sysread, #syswrite

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, 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) ⇒ StreamPool

Initializes the file channel instance


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

def initialize(client, cid, type, flags)
  super(client, cid, type, flags)

  initialize_abstraction
end

Instance Method Details

#cleanupObject

Cleans up resources used by the channel.


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

def cleanup
  super

  cleanup_abstraction
end

#dio_close_handler(packet) ⇒ Object

Closes the local half of the pool stream.


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

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.


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

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.


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

def eof
  return false
end

#seekObject

This method seeks to an offset in the pool.


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

def seek
  raise NotImplementedError
end

#tellObject

This method returns the current offset into the pool.


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

def tell
  raise NotImplementedError
end