[20190213]测试服务端打开那些端口.txt

[20190213]测试服务端打开那些端口.txt

--//前几天测试使用发送信息到/dev/tcp/ip_address/port,测试端口是否打开.写简单写一个脚本验证看看.

$ seq 1 65000 | xargs -I{} echo "echo a > /dev/tcp/192.168.100.40/{} 2>/dev/null 2&>1 ; echo ok=\$?,{}" | bash 2>/dev/null | grep ok=0 | cut -d, -f2
22
80
111
113
443
1521
3306
32768
39063

--//在192.168.100.40验证看看打开那些tcp端口.
# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:32768               0.0.0.0:*                   LISTEN      2723/rpc.statd
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      3005/mysqld
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      2703/portmap
tcp        0      0 0.0.0.0:113                 0.0.0.0:*                   LISTEN      2913/xinetd
tcp        0      0 :::80                       :::*                        LISTEN      3033/httpd
tcp        0      0 :::1521                     :::*                        LISTEN      8513/tnslsnr
tcp        0      0 :::22                       :::*                        LISTEN      2898/sshd
tcp        0      0 :::39063                    :::*                        LISTEN      12661/ora_d000_book
tcp        0      0 :::443                      :::*                        LISTEN      3033/httpd

--//OK完全正确.

--//使用nc快许多.
$ echo a | nc -w 1 -n -v  192.168.100.40 1-65000 2>/dev/null | grep "succeeded"
Connection to 192.168.100.40 22 port [tcp/*] succeeded!
Connection to 192.168.100.40 80 port [tcp/*] succeeded!
Connection to 192.168.100.40 111 port [tcp/*] succeeded!
Connection to 192.168.100.40 113 port [tcp/*] succeeded!
Connection to 192.168.100.40 443 port [tcp/*] succeeded!
Connection to 192.168.100.40 1521 port [tcp/*] succeeded!
Connection to 192.168.100.40 3306 port [tcp/*] succeeded!
Connection to 192.168.100.40 32768 port [tcp/*] succeeded!
Connection to 192.168.100.40 39063 port [tcp/*] succeeded!

posted @ 2019-02-13 10:08  lfree  阅读(588)  评论(2编辑  收藏  举报