> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/enum/windows-discovery/windows-network-enumeration.md).

# Windows Network Enumeration

## List Network Connections

### List Network Connections in PowerShell

To list TCP-connections in PowerShell together with their programs and listening ports

```powershell
Get-NetTCPConnection |  select-object LocalAddress,LocalPort,RemoteAddress,RemotePort,State,CreationTime,OwningProcess, @{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}} | ft -auto
```

To list TCP-connections together with their programs, state and creation times

```powershell
Get-NetTCPConnection |  select-object LocalAddress,LocalPort,RemoteAddress,RemotePort,State,CreationTime,OwningProcess, @{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}} | ft -auto
```

To list UDP-connections in PowerShell together with their programs and listening ports

```powershell
Get-NetUDPEndpoint  | select LocalAddress,LocalPort,CreationTime,OwningProcess,@{Name="Process";Expression={(Get-Process -Id $_.OwningProcess).ProcessName}} | ft -auto
```

### List Network Connections in cmd.exe

To list both TCP- and UDP-connections together with their programs and listening ports (requires elevation)

```batch
netstat.exe -naob
```

## Resources

Get-NetTCPConnection - Microsoft Learn: <https://learn.microsoft.com/en-us/powershell/module/nettcpip/get-nettcpconnection?view=windowsserver2019-ps>

Get-NetUDPEndpoint - Microsoft Learn: <https://learn.microsoft.com/en-us/powershell/module/nettcpip/get-netudpendpoint?view=windowsserver2019-ps>

netstat - Microsoft Learn: <https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netstat>
