Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/post/meterpreter/extensions/stdapi/net/netstat.rb
Views: 11797
# -*- coding: binary -*-12require 'ipaddr'34module Rex5module Post6module Meterpreter7module Extensions8module Stdapi9module Net1011###12#13# This class represents a connection (listening, connected)14# on the remote machine.15#16###17class Netstat1819##20#21# Constructor22#23##2425#26# Returns a netstat entry and initializes it to the supplied27# parameters.28#29def initialize(opts={})30self.local_addr = IPAddr.new_ntoh(opts[:local_addr]).to_s31self.remote_addr = IPAddr.new_ntoh(opts[:remote_addr]).to_s32self.local_port = opts[:local_port]33self.remote_port = opts[:remote_port]34self.protocol = opts[:protocol]35self.state = opts[:state]36self.uid = opts[:uid] || 037self.inode = opts[:inode] || 038self.pid_name = opts[:pid_name]3940self.local_addr_str = sprintf("%s:%d",self.local_addr, self.local_port)41if self.remote_port == 042port = "*"43else44port = self.remote_port.to_s45end46self.remote_addr_str = sprintf("%s:%s",self.remote_addr, port)47end484950#51# The local address of the connection52#53attr_accessor :local_addr54#55# The remote address (peer) of the connection56#57attr_accessor :remote_addr58#59# The local port of the connection.60#61attr_accessor :local_port62#63# The remote port of the connection.64#65attr_accessor :remote_port66#67# The protocol type (tcp/tcp6/udp/udp6)68#69attr_accessor :protocol70#71# The state of the connection (close, listening, syn_sent...)72#73attr_accessor :state74#75# The uid of the user who started the process to which the connection belongs to76#77attr_accessor :uid78#79# The socket inode80#81attr_accessor :inode82#83# The name of the process to which the connection belongs to84#85attr_accessor :pid_name86#87# The local address of the connection plus the port88#89attr_accessor :local_addr_str90#91# The remote address (peer) of the connection plus the port or *92#93attr_accessor :remote_addr_str94end9596end; end; end; end; end; end979899