欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

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

程序员文章站 2022-05-11 14:22:52
[20190213]测试服务端打开那些端口.txt--//前几天测试使用发送信息到/dev/tcp/ip_address/port,测试端口是否打开.写简单写一个脚本验证看看.$ seq 1 65000 | xargs -I{} echo "echo a > /dev/tcp/192.168.100 ......

[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!