class Rex::Post::Meterpreter::Extensions::Stdapi::Net::SocketSubsystem::TcpClientChannel
This class represents a logical TCP client connection that is established from the remote machine and tunnelled through the established meterpreter connection, similar to an SSH port forward.
Public Class Methods
cls()
click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb, line 26 def cls return CHANNEL_CLASS_STREAM end
new( client, cid, type, flags )
click to toggle source
Passes the channel initialization information up to the base class.
Calls superclass method
Rex::Post::Meterpreter::Stream::new
# File lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb, line 126 def initialize( client, cid, type, flags ) super( client, cid, type, flags ) lsock.extend( SocketInterface ) lsock.extend( DirectChannelWrite ) lsock.channel = self rsock.extend( SocketInterface ) rsock.channel = self end
open(client, params)
click to toggle source
Opens a TCP client channel using the supplied parameters.
# File lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb, line 89 def TcpClientChannel.open(client, params) c = Channel.create(client, 'stdapi_net_tcp_client', self, CHANNEL_FLAG_SYNCHRONOUS, [ { 'type' => TLV_TYPE_PEER_HOST, 'value' => params.peerhost }, { 'type' => TLV_TYPE_PEER_PORT, 'value' => params.peerport }, { 'type' => TLV_TYPE_LOCAL_HOST, 'value' => params.localhost }, { 'type' => TLV_TYPE_LOCAL_PORT, 'value' => params.localport }, { 'type' => TLV_TYPE_CONNECT_RETRIES, 'value' => params.retries } ]) c.params = params c end
Public Instance Methods
_write(*args)
click to toggle source
Wrap the _write() call in order to catch some common, but harmless Windows exceptions
Calls superclass method
Rex::Post::Meterpreter::Channel#_write
# File lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb, line 166 def _write(*args) begin super(*args) rescue ::Rex::Post::Meterpreter::RequestError => e case e.code when 10000 .. 10100 raise ::Rex::ConnectionError.new end end end
close_write()
click to toggle source
Closes the write half of the connection.
# File lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb, line 141 def close_write return shutdown(1) end
shutdown(how = 1)
click to toggle source
Shutdown the connection
0 -> future reads 1 -> future sends 2 -> both
# File lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_client_channel.rb, line 152 def shutdown(how = 1) request = Packet.create_request('stdapi_net_socket_tcp_shutdown') request.add_tlv(TLV_TYPE_SHUTDOWN_HOW, how) request.add_tlv(TLV_TYPE_CHANNEL_ID, self.cid) response = client.send_request(request) return true end