nmap
網路
用法
nmap [-sV] -p <ports> <target>掃一台主機看哪些埠會回應;`-sS` 和 `-O` 需要 root,而掃描不屬於你的機器會在對方日誌裡被記成攻擊,在有些國家還違法,所以只在自己的網路裡用。
常用選項
| 選項 | 含義 |
|---|---|
| -p 22,80,443 / -p- | Specific ports / all 65535 of them. |
| --top-ports 100 | The hundred most common ports, a good first pass. |
| -sS | SYN scan: fast and quiet, but needs root. |
| -sT | Full TCP connect scan, the fallback when you are not root. |
| -sV | Ask each open port what software and version it is. |
| -sn | Host discovery only, no port scan. |
| -Pn | Assume the host is up, for targets that ignore ping. |
| -oN <file> / -oX <file> | Save plain-text / XML output. |
範例
nmap -p 22,80,443 192.168.1.10Check three ports on one machine.
nmap -sn 192.168.1.0/24List which addresses on the LAN are answering.
sudo nmap -sS -sV --top-ports 100 10.0.0.5Fast scan with service detection.
連不上的時候,這些能把範圍縮小——是名稱解析不了、沒有路由,還是連接埠被擋。
怎麼看
- 方括號 [ ] 表示這部分可以不寫。
- 省略號 … 表示可以寫多個。
- 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。
常見問題
Q. nmap 是做什麼的?
掃一台主機看哪些埠會回應;`-sS` 和 `-O` 需要 root,而掃描不屬於你的機器會在對方日誌裡被記成攻擊,在有些國家還違法,所以只在自己的網路裡用。
Q. 怎麼寫?
nmap [-sV] -p <ports> <target> —— 方括號表示可以省略的部分。
Q. 值得記的選項有幾個?
這裡列了 8 個,完整列表在 man nmap。這條命令屬於網路。
相關命令
man 手冊: man nmap