Class: Rex::Post::Meterpreter::Extensions::Stdapi::Net::Netstat

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb

Overview

This class represents a connection (listening, connected) on the remote machine.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Netstat

Returns a netstat entry and initializes it to the supplied parameters.


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 30

def initialize(opts={})
  self.local_addr   = IPAddr.new_ntoh(opts[:local_addr]).to_s
  self.remote_addr  = IPAddr.new_ntoh(opts[:remote_addr]).to_s
  self.local_port   = opts[:local_port]
  self.remote_port  = opts[:remote_port]
  self.protocol     = opts[:protocol]
  self.state        = opts[:state]
  self.uid          = opts[:uid] || 0
  self.inode        = opts[:inode] || 0
  self.pid_name     = opts[:pid_name]

  self.local_addr_str  = sprintf("%s:%d",self.local_addr, self.local_port)
  if self.remote_port == 0
    port = "*"
  else
    port = self.remote_port.to_s
  end
  self.remote_addr_str = sprintf("%s:%s",self.remote_addr, port)
end

Instance Attribute Details

#inodeObject

The socket inode


82
83
84
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 82

def inode
  @inode
end

#local_addrObject

The local address of the connection


54
55
56
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 54

def local_addr
  @local_addr
end

#local_addr_strObject

The local address of the connection plus the port


90
91
92
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 90

def local_addr_str
  @local_addr_str
end

#local_portObject

The local port of the connection.


62
63
64
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 62

def local_port
  @local_port
end

#pid_nameObject

The name of the process to which the connection belongs to


86
87
88
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 86

def pid_name
  @pid_name
end

#protocolObject

The protocol type (tcp/tcp6/udp/udp6)


70
71
72
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 70

def protocol
  @protocol
end

#remote_addrObject

The remote address (peer) of the connection


58
59
60
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 58

def remote_addr
  @remote_addr
end

#remote_addr_strObject

The remote address (peer) of the connection plus the port or *


94
95
96
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 94

def remote_addr_str
  @remote_addr_str
end

#remote_portObject

The remote port of the connection.


66
67
68
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 66

def remote_port
  @remote_port
end

#stateObject

The state of the connection (close, listening, syn_sent…)


74
75
76
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 74

def state
  @state
end

#uidObject

The uid of the user who started the process to which the connection belongs to


78
79
80
# File 'lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb', line 78

def uid
  @uid
end