Created
March 19, 2024 15:04
-
-
Save chadmando/cab12c76c210aeaeeb12816632930960 to your computer and use it in GitHub Desktop.
ns command written in powershell to include lifetime of established connections - TCP version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Full credit for this goes to a SANS ICS diary by Rob Vandenbrink | |
# https://isc.sans.edu/diary/30532?n | |
$now = get-date | |
Get-NetTCPConnection | | |
select-object LocalAddress,LocalPort,RemoteAddress,RemotePort,State,@{Name="LifetimeSec";Expression={($now-$_.CreationTime).seconds}},OwningProcess, @{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}} | | |
sort-object -property LifetimeSec | | |
select-object -last 10 | | |
ft -auto |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment