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