Class: WindowsPorts
Overview
TODO: Add UDP infromation Get-NetUDPEndpoint TODO: currently Windows only supports tcp ports TODO: Get-NetTCPConnection does not return PIDs TODO: double-check output with ‘netstat -ano’
Instance Attribute Summary
Attributes inherited from PortsInfo
Instance Method Summary collapse
Methods inherited from PortsInfo
Constructor Details
This class inherits a constructor from PortsInfo
Instance Method Details
#info ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/resources/port.rb', line 97 def info # get all port information cmd = inspec.command('Get-NetTCPConnection | Select-Object -Property State, Caption, Description, LocalAddress, LocalPort, RemoteAddress, RemotePort, DisplayName, Status | ConvertTo-Json') begin ports = JSON.parse(cmd.stdout) rescue JSON::ParserError => _e return nil end return nil if ports.nil? ports.map { |x| { port: x['LocalPort'], address: x['LocalAddress'], protocol: 'tcp', process: nil, pid: nil, } } end |