Module: Rex::Post::Meterpreter::SocketAbstraction::SocketInterface

Includes:
Socket
Included in:
Datagram::SocketInterface, Rex::Post::Meterpreter::Stream::SocketInterface
Defined in:
lib/rex/post/meterpreter/channels/socket_abstraction.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#channelObject

Returns the value of attribute channel


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

def channel
  @channel
end

Instance Method Details

#closeObject


52
53
54
55
56
# File 'lib/rex/post/meterpreter/channels/socket_abstraction.rb', line 52

def close
  super
  channel.cleanup_abstraction
  channel.close
end

#getpeernameObject


39
40
41
42
43
# File 'lib/rex/post/meterpreter/channels/socket_abstraction.rb', line 39

def getpeername
  return super if not channel
  maddr,mport = [ channel.params.peerhost, channel.params.peerport ]
  ::Socket.sockaddr_in(mport, maddr)
end

#getsocknameObject


24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rex/post/meterpreter/channels/socket_abstraction.rb', line 24

def getsockname
  return super if not channel
  # Find the first host in our chain (our address)
  hops = 0
  csock = channel.client.sock
  while(csock.respond_to?('channel'))
    csock = csock.channel.client.sock
    hops += 1
  end
  _address_family,caddr,_cport = csock.getsockname
  address_family,raddr,_rport = csock.getpeername_as_array
  _maddr,mport = [ channel.params.localhost, channel.params.localport ]
  [ address_family, "#{caddr}#{(hops > 0) ? "-_#{hops}_" : ""}-#{raddr}", mport ]
end