tech_documents:windows:find_listening_ports_windows_powershell

https://gist.github.com/steelcm/2558512

This is useful to determine which ports need to be open between firewall zones if using very granular rules.

TCP
netstat -an | select-string -pattern "listening"
UDP
nothing so far....

You can also use Nmap to verify the listing

nmap -p 1-65535 -sS -sU -T4 -A -v IP.ADD.R.ESS

Output of Server 2019 Essentials with domain controller role, file and print sharing:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\Windows\system32> netstat -an | select-string -pattern "listening"

  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:88             0.0.0.0:0              LISTENING
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:389            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:464            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:593            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:636            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3268           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3269           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3389           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:5357           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:5985           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:9389           0.0.0.0:0              LISTENING
  TCP    0.0.0.0:47001          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49664          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49665          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49666          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49667          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49668          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49670          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49671          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49673          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49676          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49683          0.0.0.0:0              LISTENING
  TCP    0.0.0.0:49694          0.0.0.0:0              LISTENING
  TCP    10.49.0.10:53          0.0.0.0:0              LISTENING
  TCP    10.49.0.10:139         0.0.0.0:0              LISTENING
  TCP    127.0.0.1:53           0.0.0.0:0              LISTENING
  TCP    [::]:80                [::]:0                 LISTENING
  TCP    [::]:88                [::]:0                 LISTENING
  TCP    [::]:135               [::]:0                 LISTENING
  TCP    [::]:389               [::]:0                 LISTENING
  TCP    [::]:445               [::]:0                 LISTENING
  TCP    [::]:464               [::]:0                 LISTENING
  TCP    [::]:593               [::]:0                 LISTENING
  TCP    [::]:636               [::]:0                 LISTENING
  TCP    [::]:3268              [::]:0                 LISTENING
  TCP    [::]:3269              [::]:0                 LISTENING
  TCP    [::]:3389              [::]:0                 LISTENING
  TCP    [::]:5357              [::]:0                 LISTENING
  TCP    [::]:5985              [::]:0                 LISTENING
  TCP    [::]:9389              [::]:0                 LISTENING
  TCP    [::]:47001             [::]:0                 LISTENING
  TCP    [::]:49664             [::]:0                 LISTENING
  TCP    [::]:49665             [::]:0                 LISTENING
  TCP    [::]:49666             [::]:0                 LISTENING
  TCP    [::]:49667             [::]:0                 LISTENING
  TCP    [::]:49668             [::]:0                 LISTENING
  TCP    [::]:49670             [::]:0                 LISTENING
  TCP    [::]:49671             [::]:0                 LISTENING
  TCP    [::]:49673             [::]:0                 LISTENING
  TCP    [::]:49676             [::]:0                 LISTENING
  TCP    [::]:49683             [::]:0                 LISTENING
  TCP    [::]:49694             [::]:0                 LISTENING
  TCP    [::1]:53               [::]:0                 LISTENING
  TCP    [fe80::c565:177:aa7a:b629%10]:53  [::]:0                 LISTENING
NMAP Output
Starting Nmap 7.70 ( https://nmap.org ) at 2020-07-07 08:48 PDT
NSE: Loaded 148 scripts for scanning.
NSE: Script Pre-scanning.
Initiating NSE at 08:48
Completed NSE at 08:48, 0.00s elapsed
Initiating NSE at 08:48
Completed NSE at 08:48, 0.00s elapsed
Initiating Ping Scan at 08:48
Scanning 10.49.0.10 [4 ports]
Completed Ping Scan at 08:48, 0.23s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 08:48
Completed Parallel DNS resolution of 1 host. at 08:48, 0.02s elapsed
Initiating SYN Stealth Scan at 08:48
Scanning 10.49.0.10 [65535 ports]
Discovered open port 3389/tcp on 10.49.0.10
Discovered open port 135/tcp on 10.49.0.10
Discovered open port 53/tcp on 10.49.0.10
Discovered open port 139/tcp on 10.49.0.10
Discovered open port 445/tcp on 10.49.0.10
Discovered open port 49673/tcp on 10.49.0.10
Discovered open port 49671/tcp on 10.49.0.10
Discovered open port 3269/tcp on 10.49.0.10
Discovered open port 636/tcp on 10.49.0.10
Discovered open port 49694/tcp on 10.49.0.10
Discovered open port 9389/tcp on 10.49.0.10
Discovered open port 49667/tcp on 10.49.0.10
Discovered open port 49670/tcp on 10.49.0.10
Discovered open port 49683/tcp on 10.49.0.10
Discovered open port 5357/tcp on 10.49.0.10
Discovered open port 88/tcp on 10.49.0.10
Discovered open port 5985/tcp on 10.49.0.10
Discovered open port 593/tcp on 10.49.0.10
Discovered open port 3268/tcp on 10.49.0.10
Discovered open port 464/tcp on 10.49.0.10
Discovered open port 389/tcp on 10.49.0.10
Completed SYN Stealth Scan at 09:06, 1092.77s elapsed (65535 total ports)
Initiating UDP Scan at 09:06
Scanning 10.49.0.10 [65535 ports]
Discovered open port 389/udp on 10.49.0.10
Discovered open port 53/udp on 10.49.0.10
Discovered open port 123/udp on 10.49.0.10
Completed UDP Scan at 09:17, 644.04s elapsed (65535 total ports)
Initiating Service scan at 09:17
Scanning 65556 services on 10.49.0.10
Discovered open port 88/udp on 10.49.0.10
Discovered open|filtered port 88/udp on 10.49.0.10 is actually open
  • tech_documents/windows/find_listening_ports_windows_powershell.txt
  • Last modified: 2022/01/12 05:52
  • by jacob.hydeman