Module: Msf::Sessions::Modem::ChannelSocketInterface

Overview

Shared socket name interface for modem channels.

Rex::Post::Channel::SocketAbstraction::SocketInterface#getsockname traverses a Meterpreter-style channel chain via channel.client.sock, which doesn’t apply here. Override it to return a synthetic local address from the channel params so callers (e.g. the SOCKS5 response builder) get a valid value rather than a NoMethodError. Both the TCP and UDP channel SocketInterfaces mix this in.

Instance Attribute Summary

Attributes included from Rex::Post::Channel::SocketAbstraction::SocketInterface

#channel

Instance Method Summary collapse

Methods included from Rex::Post::Channel::SocketAbstraction::SocketInterface

#getpeername

Instance Method Details

#close(*args) ⇒ Object



53
54
55
56
57
58
# File 'lib/msf/base/sessions/modem.rb', line 53

def close(*args)
  current_channel = channel if respond_to?(:channel)
  super
ensure
  current_channel.close if current_channel && !current_channel.closed?
end

#getsocknameObject



60
61
62
63
64
65
66
# File 'lib/msf/base/sessions/modem.rb', line 60

def getsockname
  return super unless channel

  [ ::Socket::AF_INET,
    channel.params.localhost || '0.0.0.0',
    channel.params.localport || 0 ]
end