今天來學習如何使用Nmap進行基本的網路掃描!
掃描一台電腦或設備的 IP 位址,檢查哪些埠是開啟狀態。今天以 IP 位址 10.0.0.66 為範例。
使用 Nmap 的 -sn
(Ping 掃描)選項來確認目標主機是否在線。
nmap -sn 10.0.0.66
說明:-sn
:表示只進行 Ping 掃描,不進行端口掃描。
輸出範例:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-09-18 18:00 CST
Nmap scan report for 10.0.0.66
Host is up (0.0032s latency).
Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds
使用 Nmap 的預設選項,可以掃描目標主機的 1000 個常用端口。
nmap 10.0.0.66
說明:
無需特別選擇選項,Nmap 預設會掃描 1000 個常用端口。
輸出範例:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-09-18 18:05 CST
Nmap scan report for 10.0.0.66
Host is up (0.0020s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 6.45 seconds
如果只需掃描特定端口,可以使用 -p
選項指定端口號。
nmap -p 22,80,443 10.0.0.66
說明:-p
:指定要掃描的端口,可以是單一端口、端口範圍或多個端口的組合。
輸出範例:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-09-18 18:10 CST
Nmap scan report for 10.0.0.66
Host is up (0.0025s latency).
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 3.20 seconds
要獲取開放端口上運行的服務及其版本資訊,可以使用 -sV
選項。
nmap -sV 10.0.0.66
說明:-sV
:啟用服務版本偵測。
輸出範例:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-09-18 18:15 CST
Nmap scan report for 10.0.0.66
Host is up (0.0021s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
443/tcp open https Apache httpd 2.4.29 ((Ubuntu))
Nmap done: 1 IP address (1 host up) scanned in 10.75 seconds
要偵測目標主機的作業系統,可以使用 -O
選項。
nmap -O 10.0.0.66
說明:-O
:啟用作業系統偵測。
輸出範例:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-09-18 18:20 CST
Nmap scan report for 10.0.0.66
Host is up (0.0023s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.2 - 3.16
Network Distance: 1 hop
OS detection performed. Please report any incorrect results at https://nmap.org/submit/.
Nmap done: 1 IP address (1 host up) scanned in 12.30 seconds
SYN 掃描是一種常用的掃描技術,通常被視為較為隱蔽的掃描方法。使用 -sS
選項進行 SYN 掃描。
nmap -sS 10.0.0.66
說明:-sS
:啟用 SYN 掃描(也稱為半開掃描)。
輸出範例:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-09-18 18:25 CST
Nmap scan report for 10.0.0.66
Host is up (0.0020s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 5.50 seconds