class Rex::Post::Meterpreter::Stream

Stream


This class represents a channel that is streaming. This means that sequential data is flowing in either one or both directions.

Public Class Methods

cls() click to toggle source
# File lib/rex/post/meterpreter/channels/stream.rb, line 23
def cls
  return CHANNEL_CLASS_STREAM
end
new(client, cid, type, flags) click to toggle source

Passes the initialization information up to the base class

Calls superclass method Rex::Post::Meterpreter::Channel::new
# File lib/rex/post/meterpreter/channels/stream.rb, line 37
def initialize(client, cid, type, flags)
  # sf: initialize_abstraction() before super() as we can get a scenario where dio_write_handler() is called
  # with data to write to the rsock but rsock has not yet been initialized. This happens if the channel
  # is registered (client.add_channel(self) in Channel.initialize) to a session and a 'core_channel_write'
  # request comes in before we have called self.initialize_abstraction()
  initialize_abstraction
  super(client, cid, type, flags)
end

Public Instance Methods

cleanup() click to toggle source

Cleans up the stream abstraction.

Calls superclass method Rex::Post::Meterpreter::Channel#cleanup
# File lib/rex/post/meterpreter/channels/stream.rb, line 77
def cleanup
  super

  cleanup_abstraction
end
dio_close_handler(packet) click to toggle source

Performs a close operation on the right side of the local stream.

# File lib/rex/post/meterpreter/channels/stream.rb, line 68
def dio_close_handler(packet)
  rsock.close

  return super(packet)
end
dio_write_handler(packet, data) click to toggle source

Performs a write operation on the right side of the local stream.

# File lib/rex/post/meterpreter/channels/stream.rb, line 55
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