Module: Rex::Post::Channel
- Defined in:
- lib/rex/post/channel/container.rb,
lib/rex/post/channel/socket_abstraction.rb,
lib/rex/post/channel/stream_abstraction.rb
Defined Under Namespace
Modules: Container, SocketAbstraction, StreamAbstraction
Class Method Summary collapse
-
.create(client, type = nil, klass = nil, flags = CHANNEL_FLAG_SYNCHRONOUS, addends = nil, **klass_kwargs) ⇒ Object
Creates a logical channel between the client and the server based on a given type.
Class Method Details
.create(client, type = nil, klass = nil, flags = CHANNEL_FLAG_SYNCHRONOUS, addends = nil, **klass_kwargs) ⇒ Object
Creates a logical channel between the client and the server based on a given type.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/rex/post/meterpreter/channel.rb', line 95 def Channel.create(client, type = nil, klass = nil, flags = CHANNEL_FLAG_SYNCHRONOUS, addends = nil, **klass_kwargs) request = Packet.create_request(COMMAND_ID_CORE_CHANNEL_OPEN) # Set the type of channel that we're allocating if !type.nil? request.add_tlv(TLV_TYPE_CHANNEL_TYPE, type) end # If no factory class was provided, use the default native class if klass.nil? klass = self end request.add_tlv(TLV_TYPE_CHANNEL_CLASS, klass.cls) request.add_tlv(TLV_TYPE_FLAGS, flags) request.add_tlvs(addends) # Transmit the request and wait for the response cid = nil begin response = client.send_request(request) cid = response.get_tlv_value(TLV_TYPE_CHANNEL_ID) if cid.nil? raise Rex::Post::Meterpreter::RequestError end end # Create the channel instance klass.new(client, cid, type, flags, response, **klass_kwargs) end |