2024年10月28日 星期一

[研究]列出 Windows 10預設所有開放的 Port ? 用途 ? 服務名稱 ? 檔案名稱 ? 程序名稱 ?

[研究]列出 Windows 10預設所有開放的 Port ? 用途 ? 服務名稱 ? 檔案名稱 ? 程序名稱 ?

2024-10-28

[研究]列出 Windows Server 2022預設所有開放的 Port ? 用途 ? 服務名稱 ? 檔案名稱 ? 程序名稱 ?https://shaurong.blogspot.com/2024/10/windows-port.html

[研究]Windows Server 2022預設開啟那些 Port (nmap, netstat, tasklist, powershell)
https://shaurong.blogspot.com/2024/10/windows-server-2022-port-nmap-netstat.html

PowerShell

# 合併 Get-NetTCPConnection 和 Get-NetUDPEndpoint 結果
$connections = @()

# 處理 TCP 端口
$tcpConnections = Get-NetTCPConnection | ForEach-Object {
    $proc = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
    $service = Get-Service | Where-Object { $_.Id -eq $_.OwningProcess }
    [pscustomobject]@{
        Protocol      = "TCP"
        LocalAddress  = $_.LocalAddress
        LocalPort     = $_.LocalPort
        RemoteAddress = $_.RemoteAddress
        RemotePort    = $_.RemotePort
        State         = $_.State
        ProcessId     = $_.OwningProcess
        ProcessName   = $proc.ProcessName
        FileName      = $proc.Path
        ServiceName   = $service.Name
    }
}

# 處理 UDP 端口
$udpConnections = Get-NetUDPEndpoint | ForEach-Object {
    $proc = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
    $service = Get-Service | Where-Object { $_.Id -eq $_.OwningProcess }
    [pscustomobject]@{
        Protocol      = "UDP"
        LocalAddress  = $_.LocalAddress
        LocalPort     = $_.LocalPort
        RemoteAddress = "*"
        RemotePort    = "*"
        State         = "LISTENING"  # UDP 沒有 State,所有端口都類似 LISTENING
        ProcessId     = $_.OwningProcess
        ProcessName   = $proc.ProcessName
        FileName      = $proc.Path
        ServiceName   = $service.Name
    }
}

# 合併 TCP 和 UDP 結果
$connections = $tcpConnections + $udpConnections

# 輸出結果
$connections | Format-Table -AutoSize




結果

Windows PowerShell
Copyright (C) Microsoft Corporation. 著作權所有,並保留一切權利。

請嘗試新的跨平台 PowerShell https://aka.ms/pscore6

PS C:\Users\USER1> cd \
PS C:\> # 合併 Get-NetTCPConnection 和 Get-NetUDPEndpoint 結果
PS C:\> $connections = @()
PS C:\>
PS C:\> # 處理 TCP 端口
PS C:\> $tcpConnections = Get-NetTCPConnection | ForEach-Object {
>>     $proc = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
>>     $service = Get-Service | Where-Object { $_.Id -eq $_.OwningProcess }
>>     [pscustomobject]@{
>>         Protocol      = "TCP"
>>         LocalAddress  = $_.LocalAddress
>>         LocalPort     = $_.LocalPort
>>         RemoteAddress = $_.RemoteAddress
>>         RemotePort    = $_.RemotePort
>>         State         = $_.State
>>         ProcessId     = $_.OwningProcess
>>         ProcessName   = $proc.ProcessName
>>         FileName      = $proc.Path
>>         ServiceName   = $service.Name
>>     }
>> }
PS C:\>
PS C:\> # 處理 UDP 端口
PS C:\> $udpConnections = Get-NetUDPEndpoint | ForEach-Object {
>>     $proc = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
>>     $service = Get-Service | Where-Object { $_.Id -eq $_.OwningProcess }
>>     [pscustomobject]@{
>>         Protocol      = "UDP"
>>         LocalAddress  = $_.LocalAddress
>>         LocalPort     = $_.LocalPort
>>         RemoteAddress = "*"
>>         RemotePort    = "*"
>>         State         = "LISTENING"  # UDP 沒有 State,所有端口都類似 LISTENING
>>         ProcessId     = $_.OwningProcess
>>         ProcessName   = $proc.ProcessName
>>         FileName      = $proc.Path
>>         ServiceName   = $service.Name
>>     }
>> }
PS C:\>
PS C:\> # 合併 TCP 和 UDP 結果
PS C:\> $connections = $tcpConnections + $udpConnections
PS C:\>
PS C:\> # 輸出結果
PS C:\> $connections | Format-Table -AutoSize

Protocol LocalAddress               LocalPort RemoteAddress   RemotePort       State ProcessId ProcessName        FileName
-------- ------------               --------- -------------   ----------       ----- --------- -----------        --------
TCP      ::                             49669 ::                       0      Listen       636 services
TCP      ::                             49668 ::                       0      Listen      2256 spoolsv
TCP      ::                             49667 ::                       0      Listen      1232 svchost
TCP      ::                             49666 ::                       0      Listen      1132 svchost
TCP      ::                             49665 ::                       0      Listen       496 wininit
TCP      ::                             49664 ::                       0      Listen       652 lsass
TCP      ::                              7680 ::                       0      Listen      9820 svchost
TCP      ::                               445 ::                       0      Listen         4 System
TCP      ::                               135 ::                       0      Listen       868 svchost
TCP      0.0.0.0                        50257 0.0.0.0                  0       Bound      3364 svchost
TCP      0.0.0.0                        50256 0.0.0.0                  0       Bound      3524 backgroundTaskHost C:\Windows\system32\backg...
TCP      0.0.0.0                        50255 0.0.0.0                  0       Bound      3524 backgroundTaskHost C:\Windows\system32\backg...
TCP      0.0.0.0                        50252 0.0.0.0                  0       Bound      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        50250 0.0.0.0                  0       Bound      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        50249 0.0.0.0                  0       Bound      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        50248 0.0.0.0                  0       Bound      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        50238 0.0.0.0                  0       Bound      3364 svchost
TCP      0.0.0.0                        50225 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50222 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50221 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50220 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50213 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50211 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50210 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50209 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50191 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50190 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50187 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50186 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50171 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50166 0.0.0.0                  0       Bound     10388 msedge             C:\Program Files (x86)\Mi...
TCP      0.0.0.0                        50163 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50162 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50152 0.0.0.0                  0       Bound      3796 SkypeApp           C:\Program Files\WindowsA...
TCP      0.0.0.0                        50149 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50148 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50142 0.0.0.0                  0       Bound      3796 SkypeApp           C:\Program Files\WindowsA...
TCP      0.0.0.0                        50140 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50138 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50137 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50136 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50134 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50133 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50129 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50128 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50122 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50121 0.0.0.0                  0       Bound      3796 SkypeApp           C:\Program Files\WindowsA...
TCP      0.0.0.0                        50118 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50117 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50116 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50115 0.0.0.0                  0       Bound      9820 svchost
TCP      0.0.0.0                        50114 0.0.0.0                  0       Bound      3796 SkypeApp           C:\Program Files\WindowsA...
TCP      0.0.0.0                        50074 0.0.0.0                  0       Bound      4280 explorer           C:\Windows\Explorer.EXE
TCP      0.0.0.0                        49865 0.0.0.0                  0       Bound      8584 svchost
TCP      0.0.0.0                        49859 0.0.0.0                  0       Bound      7304 msedgewebview2     C:\Program Files (x86)\Mi...
TCP      0.0.0.0                        49844 0.0.0.0                  0       Bound      3216 svchost
TCP      0.0.0.0                        49729 0.0.0.0                  0       Bound      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49728 0.0.0.0                  0       Bound      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49727 0.0.0.0                  0       Bound      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49726 0.0.0.0                  0       Bound      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49725 0.0.0.0                  0       Bound      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49724 0.0.0.0                  0       Bound      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49723 0.0.0.0                  0       Bound      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49722 0.0.0.0                  0       Bound      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49706 0.0.0.0                  0       Bound      6420 SearchApp          C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49705 0.0.0.0                  0       Bound      6420 SearchApp          C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49704 0.0.0.0                  0       Bound      7304 msedgewebview2     C:\Program Files (x86)\Mi...
TCP      0.0.0.0                        49696 0.0.0.0                  0       Bound      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      0.0.0.0                        49688 0.0.0.0                  0       Bound      3216 svchost
TCP      192.168.128.130                50257 20.190.166.131         443 Established      3364 svchost
TCP      192.168.128.130                50256 152.195.38.76           80 Established      3524 backgroundTaskHost C:\Windows\system32\backg...
TCP      192.168.128.130                50255 23.220.198.33          443 Established      3524 backgroundTaskHost C:\Windows\system32\backg...
TCP      192.168.128.130                50252 117.18.232.200         443 Established      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                50250 210.71.227.208         443 Established      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                50249 13.107.6.254           443 Established      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                50248 204.79.197.222         443 Established      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                50244 13.107.246.73          443    TimeWait         0 Idle
TCP      192.168.128.130                50238 20.190.166.131         443 Established      3364 svchost
TCP      192.168.128.130                50234 20.189.173.24          443    TimeWait         0 Idle
TCP      192.168.128.130                50225 13.74.187.43           443 Established      9820 svchost
TCP      192.168.128.130                50224 210.71.227.162          80    TimeWait         0 Idle
TCP      192.168.128.130                50223 210.71.227.114          80    TimeWait         0 Idle
TCP      192.168.128.130                50222 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50221 203.69.138.206          80 Established      9820 svchost
TCP      192.168.128.130                50220 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50219 146.75.114.172          80    TimeWait         0 Idle
TCP      192.168.128.130                50213 13.74.187.43           443 Established      9820 svchost
TCP      192.168.128.130                50212 146.75.114.172          80    TimeWait         0 Idle
TCP      192.168.128.130                50211 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50210 151.101.230.172         80 Established      9820 svchost
TCP      192.168.128.130                50209 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50207 52.165.164.15          443    TimeWait         0 Idle
TCP      192.168.128.130                50206 43.159.69.81            80    TimeWait         0 Idle
TCP      192.168.128.130                50205 210.71.227.97           80    TimeWait         0 Idle
TCP      192.168.128.130                50204 210.71.227.184          80    TimeWait         0 Idle
TCP      192.168.128.130                50202 43.159.69.106           80    TimeWait         0 Idle
TCP      192.168.128.130                50201 52.165.164.15          443    TimeWait         0 Idle
TCP      192.168.128.130                50200 210.71.227.162          80    TimeWait         0 Idle
TCP      192.168.128.130                50199 210.71.227.106          80    TimeWait         0 Idle
TCP      192.168.128.130                50198 43.159.69.111           80    TimeWait         0 Idle
TCP      192.168.128.130                50197 43.175.149.11           80    TimeWait         0 Idle
TCP      192.168.128.130                50196 210.71.227.186          80    TimeWait         0 Idle
TCP      192.168.128.130                50195 210.71.227.97           80    TimeWait         0 Idle
TCP      192.168.128.130                50194 43.159.69.81            80    TimeWait         0 Idle
TCP      192.168.128.130                50193 43.159.69.56            80    TimeWait         0 Idle
TCP      192.168.128.130                50191 151.101.230.172         80 Established      9820 svchost
TCP      192.168.128.130                50190 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50189 210.71.227.104          80    TimeWait         0 Idle
TCP      192.168.128.130                50188 210.71.227.184          80    TimeWait         0 Idle
TCP      192.168.128.130                50187 151.101.230.172         80 Established      9820 svchost
TCP      192.168.128.130                50186 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50185 210.71.227.186          80    TimeWait         0 Idle
TCP      192.168.128.130                50184 210.71.227.106          80    TimeWait         0 Idle
TCP      192.168.128.130                50183 52.182.143.211         443    TimeWait         0 Idle
TCP      192.168.128.130                50182 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50181 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50180 43.175.149.12           80    TimeWait         0 Idle
TCP      192.168.128.130                50179 43.159.69.81            80    TimeWait         0 Idle
TCP      192.168.128.130                50177 43.159.69.81            80    TimeWait         0 Idle
TCP      192.168.128.130                50176 146.75.114.172          80    TimeWait         0 Idle
TCP      192.168.128.130                50175 52.175.245.232         443    TimeWait         0 Idle
TCP      192.168.128.130                50174 210.71.227.186          80    TimeWait         0 Idle
TCP      192.168.128.130                50173 210.71.227.114          80    TimeWait         0 Idle
TCP      192.168.128.130                50172 203.77.190.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50171 23.47.5.117            443 Established      9820 svchost
TCP      192.168.128.130                50169 52.175.245.232         443    TimeWait         0 Idle
TCP      192.168.128.130                50167 52.175.245.232         443    TimeWait         0 Idle
TCP      192.168.128.130                50166 204.79.197.239         443 Established     10388 msedge             C:\Program Files (x86)\Mi...
TCP      192.168.128.130                50165 151.101.230.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50164 151.101.230.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50163 203.69.138.206          80 Established      9820 svchost
TCP      192.168.128.130                50162 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50152 20.189.173.6           443 Established      3796 SkypeApp           C:\Program Files\WindowsA...
TCP      192.168.128.130                50151 210.71.227.146          80    TimeWait         0 Idle
TCP      192.168.128.130                50150 210.71.227.114          80    TimeWait         0 Idle
TCP      192.168.128.130                50149 151.101.110.172         80 Established      9820 svchost
TCP      192.168.128.130                50148 104.116.17.179         443 Established      9820 svchost
TCP      192.168.128.130                50146 151.101.230.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50144 43.159.69.56            80    TimeWait         0 Idle
TCP      192.168.128.130                50143 111.119.27.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50142 203.69.81.58            80 Established      3796 SkypeApp           C:\Program Files\WindowsA...
TCP      192.168.128.130                50141 204.79.197.239         443    TimeWait         0 Idle
TCP      192.168.128.130                50140 40.69.76.172           443 Established      9820 svchost
TCP      192.168.128.130                50139 151.101.230.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50138 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50137 146.75.114.172          80 Established      9820 svchost
TCP      192.168.128.130                50136 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50135 111.119.27.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50134 146.75.114.172          80 Established      9820 svchost
TCP      192.168.128.130                50133 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50132 210.71.227.186          80    TimeWait         0 Idle
TCP      192.168.128.130                50131 210.71.227.104          80    TimeWait         0 Idle
TCP      192.168.128.130                50129 146.75.114.172          80 Established      9820 svchost
TCP      192.168.128.130                50128 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50127 20.3.187.198           443    TimeWait         0 Idle
TCP      192.168.128.130                50126 40.69.76.172           443    TimeWait         0 Idle
TCP      192.168.128.130                50125 151.101.230.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50122 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50121 152.195.38.76           80 Established      3796 SkypeApp           C:\Program Files\WindowsA...
TCP      192.168.128.130                50120 210.71.227.146          80    TimeWait         0 Idle
TCP      192.168.128.130                50119 210.71.227.104          80    TimeWait         0 Idle
TCP      192.168.128.130                50118 146.75.114.172          80 Established      9820 svchost
TCP      192.168.128.130                50117 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50116 23.47.5.179            443 Established      9820 svchost
TCP      192.168.128.130                50115 23.47.5.117            443 Established      9820 svchost
TCP      192.168.128.130                50114 13.107.42.16           443 Established      3796 SkypeApp           C:\Program Files\WindowsA...
TCP      192.168.128.130                50113 20.3.187.198           443    TimeWait         0 Idle
TCP      192.168.128.130                50104 43.175.149.12           80    TimeWait         0 Idle
TCP      192.168.128.130                50102 43.159.69.110           80    TimeWait         0 Idle
TCP      192.168.128.130                50101 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50100 203.77.190.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50095 20.190.166.131         443    TimeWait         0 Idle
TCP      192.168.128.130                50094 20.190.166.131         443    TimeWait         0 Idle
TCP      192.168.128.130                50093 20.190.166.131         443    TimeWait         0 Idle
TCP      192.168.128.130                50092 151.101.230.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50090 146.75.114.172          80    TimeWait         0 Idle
TCP      192.168.128.130                50087 210.71.227.106          80    TimeWait         0 Idle
TCP      192.168.128.130                50086 210.71.227.114          80    TimeWait         0 Idle
TCP      192.168.128.130                50084 210.71.227.106          80    TimeWait         0 Idle
TCP      192.168.128.130                50083 210.71.227.186          80    TimeWait         0 Idle
TCP      192.168.128.130                50082 151.101.230.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50080 151.101.230.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50078 203.77.191.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50077 203.77.190.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50076 210.71.227.162          80    TimeWait         0 Idle
TCP      192.168.128.130                50075 210.71.227.106          80    TimeWait         0 Idle
TCP      192.168.128.130                50074 210.61.249.24          443 Established      4280 explorer           C:\Windows\Explorer.EXE
TCP      192.168.128.130                50059 203.77.191.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50057 210.71.227.104          80    TimeWait         0 Idle
TCP      192.168.128.130                50056 210.71.227.146          80    TimeWait         0 Idle
TCP      192.168.128.130                50055 203.69.138.206          80    TimeWait         0 Idle
TCP      192.168.128.130                50051 203.77.191.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50045 20.190.166.131         443    TimeWait         0 Idle
TCP      192.168.128.130                50042 13.74.187.43           443    TimeWait         0 Idle
TCP      192.168.128.130                50038 111.119.27.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50026 111.119.27.0            80    TimeWait         0 Idle
TCP      192.168.128.130                50017 203.69.138.206          80    TimeWait         0 Idle
TCP      192.168.128.130                50013 203.69.138.206          80    TimeWait         0 Idle
TCP      192.168.128.130                50009 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50004 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                50001 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                49999 204.79.197.239         443    TimeWait         0 Idle
TCP      192.168.128.130                49996 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                49981 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                49977 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                49974 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                49971 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                49968 151.101.110.172         80    TimeWait         0 Idle
TCP      192.168.128.130                49865 151.101.230.172         80 Established      8584 svchost
TCP      192.168.128.130                49844 20.90.153.243          443 Established      3216 svchost
TCP      192.168.128.130                49729 152.195.38.76           80   CloseWait      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                49728 152.195.38.76           80   CloseWait      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                49727 210.71.227.200         443   CloseWait      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                49726 210.71.227.200         443   CloseWait      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                49725 210.71.227.200         443   CloseWait      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                49724 210.71.227.200         443   CloseWait      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                49723 203.69.138.32          443   CloseWait      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                49722 104.116.16.155         443   CloseWait      9036 LockApp            C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                49696 13.107.246.254         443   CloseWait      5968 SearchApp          C:\Windows\SystemApps\Mic...
TCP      192.168.128.130                49688 20.90.156.32           443 Established      3216 svchost
TCP      0.0.0.0                        49669 0.0.0.0                  0      Listen       636 services
TCP      0.0.0.0                        49668 0.0.0.0                  0      Listen      2256 spoolsv
TCP      0.0.0.0                        49667 0.0.0.0                  0      Listen      1232 svchost
TCP      0.0.0.0                        49666 0.0.0.0                  0      Listen      1132 svchost
TCP      0.0.0.0                        49665 0.0.0.0                  0      Listen       496 wininit
TCP      0.0.0.0                        49664 0.0.0.0                  0      Listen       652 lsass
TCP      0.0.0.0                         5040 0.0.0.0                  0      Listen      3692 svchost
TCP      192.168.128.130                  139 0.0.0.0                  0      Listen         4 System
TCP      0.0.0.0                          135 0.0.0.0                  0      Listen       868 svchost
UDP      ::                             55881 *                        *   LISTENING      3796 SkypeApp           C:\Program Files\WindowsA...
UDP      ::1                            54575 *                        *   LISTENING      8128 svchost
UDP      fe80::9618:b113:b69:61e8%5     54574 *                        *   LISTENING      8128 svchost
UDP      ::                              5355 *                        *   LISTENING      1996 svchost
UDP      ::                              5353 *                        *   LISTENING      1996 svchost
UDP      fe80::9618:b113:b69:61e8%5      1900 *                        *   LISTENING      8128 svchost
UDP      ::1                             1900 *                        *   LISTENING      8128 svchost
UDP      127.0.0.1                      60120 *                        *   LISTENING      3388 svchost
UDP      127.0.0.1                      54577 *                        *   LISTENING      8128 svchost
UDP      192.168.128.130                54576 *                        *   LISTENING      8128 svchost
UDP      0.0.0.0                         5355 *                        *   LISTENING      1996 svchost
UDP      0.0.0.0                         5353 *                        *   LISTENING      1996 svchost
UDP      0.0.0.0                         5050 *                        *   LISTENING      3692 svchost
UDP      192.168.128.130                 1900 *                        *   LISTENING      8128 svchost
UDP      127.0.0.1                       1900 *                        *   LISTENING      8128 svchost
UDP      192.168.128.130                  138 *                        *   LISTENING         4 System
UDP      192.168.128.130                  137 *                        *   LISTENING         4 System


PS C:\>

********************************************************************************
列出 Windows 10預設所有開放的下面 Port 用途 ? 服務名稱 ? 檔案名稱 ? 程序名稱 ?
TCP/135
TCP/445
TCP/7680
TCP/49664
TCP/49665
TCP/49666
TCP/49667
TCP/49668
TCP/49669

ChatGPT 說:

以下是 Windows 10 預設開放的指定 TCP Port 的用途、服務名稱、檔案名稱與程序名稱概覽:

TCP/135

用途:DCE/RPC (Distributed Computing Environment / Remote Procedure Calls)
服務名稱:RPC Endpoint Mapper
檔案名稱:svchost.exe
程序名稱:RpcSs
TCP/445

用途:SMB (Server Message Block),用於檔案與列印資源共享
服務名稱:Microsoft-DS (Microsoft Directory Services)
檔案名稱:System
程序名稱:SMB Server
TCP/7680

用途:Delivery Optimization,主要用於 Windows 更新的點對點分發
服務名稱:Delivery Optimization
檔案名稱:svchost.exe
程序名稱:DoSvc
TCP/49664 - TCP/49669(包含連續的動態埠範圍)

用途:RPC 動態埠,這些埠號會隨不同的應用程序需求動態指派,用於支援 RPC-based 的通訊(如 DCOM、WMI)
服務名稱:RPC 動態端點(Dynamic RPC Ports)
檔案名稱:svchost.exe
程序名稱:會依據需求不同,包含 RpcSs 等使用 RPC 的服務
這些端口可能會依據系統狀態或已安裝的應用程序有所變動或額外開啟。一般來說,若需要更高的安全性,可考慮關閉部分服務或僅允許特定應用程序使用。

********************************************************************************
TCP/5040 用途 ? 服務名稱 ? 檔案名稱 ? 程序名稱 ?

ChatGPT 說:

在 Windows 10 中,TCP/5040 預設開放端口的詳細資訊如下:

用途:TCP/5040 主要用於 Windows 的 Microsoft Direct Push Notification Service (WNS),該服務提供即時推送通知功能,例如應用程式通知和系統通知。
服務名稱:Microsoft-Windows-User-PushNotification
檔案名稱:svchost.exe
程序名稱:WpnService
此服務允許 Windows 應用程式和系統接收通知。若不需要推送通知,可考慮停用該服務來減少網路風險。

********************************************************************************

PowerShell 僅列出 Listen 或 Listening 狀態的 TCP 和 UDP 連接

# 合併 Listen 或 Listening 狀態的 Get-NetTCPConnection 和 Get-NetUDPEndpoint 結果
$connections = @()

# 處理 TCP 端口,只列出 State 為 Listen 的
$tcpConnections = Get-NetTCPConnection | Where-Object { $_.State -eq "Listen" } | ForEach-Object {
    $proc = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
    $service = Get-Service | Where-Object { $_.Id -eq $_.OwningProcess }
    [pscustomobject]@{
        Protocol      = "TCP"
        LocalAddress  = $_.LocalAddress
        LocalPort     = $_.LocalPort
        RemoteAddress = $_.RemoteAddress
        RemotePort    = $_.RemotePort
        State         = $_.State
        ProcessId     = $_.OwningProcess
        ProcessName   = $proc.ProcessName
        FileName      = $proc.Path
        ServiceName   = $service.Name
    }
}

# 處理 UDP 端口,所有端口都類似 LISTENING 狀態
$udpConnections = Get-NetUDPEndpoint | ForEach-Object {
    $proc = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
    $service = Get-Service | Where-Object { $_.Id -eq $_.OwningProcess }
    [pscustomobject]@{
        Protocol      = "UDP"
        LocalAddress  = $_.LocalAddress
        LocalPort     = $_.LocalPort
        RemoteAddress = "*"
        RemotePort    = "*"
        State         = "LISTENING"
        ProcessId     = $_.OwningProcess
        ProcessName   = $proc.ProcessName
        FileName      = $proc.Path
        ServiceName   = $service.Name
    }
}

# 合併 TCP 和 UDP 結果
$connections = $tcpConnections + $udpConnections

# 輸出結果
$connections | Format-Table -AutoSize

結果

Protocol LocalAddress               LocalPort RemoteAddress RemotePort     State ProcessId ProcessName FileName ServiceName
-------- ------------               --------- ------------- ----------     ----- --------- ----------- -------- -----------
TCP      ::                             49669 ::                     0    Listen       636 services             {AarSvc_20e00, AJRouter, AL...
TCP      ::                             49668 ::                     0    Listen      2256 spoolsv              {AarSvc_20e00, AJRouter, AL...
TCP      ::                             49667 ::                     0    Listen      1232 svchost              {AarSvc_20e00, AJRouter, AL...
TCP      ::                             49666 ::                     0    Listen      1132 svchost              {AarSvc_20e00, AJRouter, AL...
TCP      ::                             49665 ::                     0    Listen       496 wininit              {AarSvc_20e00, AJRouter, AL...
TCP      ::                             49664 ::                     0    Listen       652 lsass                {AarSvc_20e00, AJRouter, AL...
TCP      ::                              7680 ::                     0    Listen      9820 svchost              {AarSvc_20e00, AJRouter, AL...
TCP      ::                               445 ::                     0    Listen         4 System               {AarSvc_20e00, AJRouter, AL...
TCP      ::                               135 ::                     0    Listen       868 svchost              {AarSvc_20e00, AJRouter, AL...
TCP      0.0.0.0                        49669 0.0.0.0                0    Listen       636 services             {AarSvc_20e00, AJRouter, AL...
TCP      0.0.0.0                        49668 0.0.0.0                0    Listen      2256 spoolsv              {AarSvc_20e00, AJRouter, AL...
TCP      0.0.0.0                        49667 0.0.0.0                0    Listen      1232 svchost              {AarSvc_20e00, AJRouter, AL...
TCP      0.0.0.0                        49666 0.0.0.0                0    Listen      1132 svchost              {AarSvc_20e00, AJRouter, AL...
TCP      0.0.0.0                        49665 0.0.0.0                0    Listen       496 wininit              {AarSvc_20e00, AJRouter, AL...
TCP      0.0.0.0                        49664 0.0.0.0                0    Listen       652 lsass                {AarSvc_20e00, AJRouter, AL...
TCP      0.0.0.0                         5040 0.0.0.0                0    Listen      3692 svchost              {AarSvc_20e00, AJRouter, AL...
TCP      192.168.128.130                  139 0.0.0.0                0    Listen         4 System               {AarSvc_20e00, AJRouter, AL...
TCP      0.0.0.0                          135 0.0.0.0                0    Listen       868 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      ::1                            54575 *                      * LISTENING      8128 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      fe80::9618:b113:b69:61e8%5     54574 *                      * LISTENING      8128 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      ::                              5355 *                      * LISTENING      1996 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      ::                              5353 *                      * LISTENING      1996 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      fe80::9618:b113:b69:61e8%5      1900 *                      * LISTENING      8128 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      ::1                             1900 *                      * LISTENING      8128 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      127.0.0.1                      60120 *                      * LISTENING      3388 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      127.0.0.1                      54577 *                      * LISTENING      8128 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      192.168.128.130                54576 *                      * LISTENING      8128 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      0.0.0.0                         5355 *                      * LISTENING      1996 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      0.0.0.0                         5353 *                      * LISTENING      1996 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      0.0.0.0                         5050 *                      * LISTENING      3692 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      192.168.128.130                 1900 *                      * LISTENING      8128 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      127.0.0.1                       1900 *                      * LISTENING      8128 svchost              {AarSvc_20e00, AJRouter, AL...
UDP      192.168.128.130                  138 *                      * LISTENING         4 System               {AarSvc_20e00, AJRouter, AL...
UDP      192.168.128.130                  137 *                      * LISTENING         4 System               {AarSvc_20e00, AJRouter, AL...


PS C:\>

(完)

相關

[研究]列出 Windows 10預設所有開放的 Port ? 用途 ? 服務名稱 ? 檔案名稱 ? 程序名稱 ?

[研究]列出 Windows Server 2022預設所有開放的 Port ? 用途 ? 服務名稱 ? 檔案名稱 ? 程序名稱 ?https://shaurong.blogspot.com/2024/10/windows-port.html

[研究]Windows Server 2022預設開啟那些 Port (nmap, netstat, tasklist, powershell)
https://shaurong.blogspot.com/2024/10/windows-server-2022-port-nmap-netstat.html


沒有留言:

張貼留言