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