扫描端口nc

2024-03-12

运维

不要把自己的信念悬挂在墙壁上。——巴尔扎克

分享一个端口扫描的小技巧

1
nc -z -v 127.0.0.1 8000-9000 2>&1 | grep succeeded

例如这里扫描到本机80009000的端口中哪些成功扫到

1
2
3
4
5
6
7
8
9
10
11
12
13
14
GithubIireAchao:blog achao$ nc -z -v 127.0.0.1 8000-9000 2>&1 | grep succeeded
Connection to 127.0.0.1 port 8000 [tcp/irdmi] succeeded!
Connection to 127.0.0.1 port 8001 [tcp/vcom-tunnel] succeeded!
Connection to 127.0.0.1 port 8002 [tcp/teradataordbms] succeeded!
Connection to 127.0.0.1 port 8003 [tcp/*] succeeded!
Connection to 127.0.0.1 port 8004 [tcp/*] succeeded!
Connection to 127.0.0.1 port 8005 [tcp/*] succeeded!
Connection to 127.0.0.1 port 8006 [tcp/*] succeeded!
Connection to 127.0.0.1 port 8021 [tcp/intu-ec-client] succeeded!
Connection to 127.0.0.1 port 8023 [tcp/*] succeeded!
Connection to 127.0.0.1 port 8055 [tcp/senomix04] succeeded!
Connection to 127.0.0.1 port 8686 [tcp/sun-as-jmxrmi] succeeded!
Connection to 127.0.0.1 port 8719 [tcp/*] succeeded!
Connection to 127.0.0.1 port 8766 [tcp/*] succeeded!

这里nc代表netcat

-z表示扫描模式不发送数据只检查链接

-v表示列出详情

127.0.0.1不谈

8000-9000是端口范围

2>&1也是在nohup老命令,表示将标准错误(2)输出到标准输出(1)

| grep succeeded筛选出成功连接的端口