
我正在我的系統上運行簡單的連接埠掃描,我不知道我是否感到困惑。
運行後lsof -i
,我的結果是:
指令 PID 使用者 FD 類型 設備大小/關閉 節點名稱 firefox-e 8008 Legion 43u IPv4 96999 0t0 TCP KryptL0c:44376->ec2-34-212-188-196.us-west-2.compute.amazonaws.com:https(已建立) firefox-e 8008 Legion 67u IPv4 84170 0t0 TCP KryptL0c:52778->ord37s09-in-f10.1e100.net:https(已建立) firefox-e 8008 Legion 94u IPv4 93549 0t0 TCP KryptL0c:56526->ord37s35-in-f1.1e100.net:https(已建立) firefox-e 8008 Legion 98u IPv4 89869 0t0 TCP KryptL0c:47874->ec2-52-86-133-10.compute-1.amazonaws.com:https(已建立) firefox-e 8008 Legion 126u IPv4 98838 0t0 TCP KryptL0c:40792->ord38s28-in-f10.1e100.net:https(已建立) firefox-e 8008 Legion 131u IPv4 98839 0t0 TCP KryptL0c:41878->ord38s01-in-f10.1e100.net:https(已建立) firefox-e 8008 Legion 133u IPv4 88016 0t0 TCP KryptL0c:44998->server-99-84-167-136.ord52.r.cloudfront.net:https(已建立) firefox-e 8008 Legion 176u IPv4 88018 0t0 TCP KryptL0c:51574->ord37s18-in-f2.1e100.net:https(已建立) firefox-e 8008 Legion 179u IPv4 86297 0t0 TCP KryptL0c:46752->142.250.123.157:https(已建立) firefox-e 8008 Legion 184u IPv4 84401 0t0 TCP KryptL0c:40262->ord38s08-in-f2.1e100.net:https(已建立) firefox-e 8008 Legion 187u IPv4 92092 0t0 TCP KryptL0c:38700->ord38s28-in-f1.1e100.net:https(已建立) firefox-e 8008 Legion 193u IPv4 89558 0t0 TCP KryptL0c:40714->ord37s09-in-f2.1e100.net:https(已建立) firefox-e 8008 Legion 199u IPv4 90795 0t0 TCP KryptL0c:47760->136.144.59.88:https(建立) firefox-e 8008 Legion 201u IPv4 90789 0t0 TCP KryptL0c:40586->server-99-84-253-65.ord50.r.cloudfront.net:https(已建立) firefox-e 8008 Legion 210u IPv4 90803 0t0 TCP KryptL0c:41732->lga15s49-in-f4.1e100.net:https(已建立) firefox-e 8008 Legion 214u IPv4 90805 0t0 TCP KryptL0c:45540->rio01s25-in-f3.1e100.net:https(已建立) firefox-e 8008 Legion 221u IPv4 97886 0t0 TCP KryptL0c:41752->ord37s07-in-f14.1e100.net:https(已建立) firefox-e 8008 Legion 301u IPv4 92423 0t0 TCP KryptL0c:59832->ord38s04-in-f2.1e100.net:https(已建立)
第一行,連接埠是44376,對嗎?
如果這是正確的並且這些服務已在我的系統上建立,為什麼當我運行連接埠掃描時nmap -p 1-65535 xxx.xxx.x.xxx
會得到沒有開放連接埠的結果?
答案1
第一行,連接埠是44376,對嗎?
是的,本機連接埠是 44376。在某個連接埠上有連線並不表示該連接埠上有偵聽套接字。
在這裡,由於本機連接埠較高(>40,000)而遠端連接埠為 443 (HTTPS),因此我們可以高度確信這是對 Internet 上某些 HTTPS 服務的傳出連線。
我假設您使用的是 macOS 或 BSD。
考慮以下實際偵聽器的範例(這樣連接-P
埠就不會解析為「已知連接埠名稱」):
$ lsof -i udp -P
…
syncthing 16758 fuzzy 7u IPv6 0xd2b0d06f6f1a443d 0t0 UDP *:22000
…
$ lsof -i tcp -P
…
syncthing 16758 fuzzy 17u IPv6 0xd2b0d06f70a57bfd 0t0 TCP *:22000 (LISTEN)
…
正如您所看到的,它們很容易區分:它們沒有遠端端點。因為 TCP 上有適當的「監聽」狀態,所以也明確列出了這一點。對於UDP,事情就沒那麼容易了。
如果我針對 TCP 連接埠 22000 執行 NMAP,它將報告為開啟。
答案2
KryptL0c:44376->ec2-34-212-188-196.us-west-2.compute.amazonaws.com:https
在這種情況下我們可以推論連接從客戶端主機:來源連接埠指向KryptL0c:44376
目標->
伺服器主機:端口ec2-34-212-188-196.us-west-2.compute.amazonaws.com:https
,因為 https 是已知服務。
來源連接埠用於出站、客戶端連接,並且沒有服務偵聽它們,這就是它們不顯示為開啟的原因。例如,與 Web 伺服器的每個 Web 瀏覽器連線都將使用不同的用戶端/來源連接埠來開啟網路連線。當連線關閉時,該連接埠會自動關閉,下次連線時將使用新的連接埠。來源連接埠通常較高,高於 32768。
此外,常見的服務連接埠號碼使用 /etc/services 檔案解析為類似名稱https
(連接埠 443),通常可能不會像這樣在輸出中顯示為數字。