适合小范围扫描,大范围扫描还是很慢的

123.png

#!/bin/bash
# Author:Meleuo
# Blog:www.ipython.run
yum install telnet  -y
read -p "起始端口 :" start
read -p "结束端口 :" stop
read -p "目标IP :" IP
echo $IP|grep "^[0-9]\{1,3\}\.\([0-9]\{1,3\}\.\)\{2\}[0-9]\{1,3\}$" &>/dev/null
if [ $? -eq 0 ]
  then
        echo 1 &> /dev/null
  else
        echo "ip不符合规则"
fi
if [ $stop -gt 65536 ]
  then
        echo "超出正常端口范围"
        exit
fi
if [ $start -lt 0 ]
  then
        echo "超出正常端口范围"
        exit
fi
if [ $start -ge $stop ];then
        echo "起始端口大于或等于结束端口"
        exit
fi
for((i=$start;i<=$stop;i++));
  do
        judge=`echo -e "\n" | telnet $IP $i 2>/dev/null | grep Connected | wc -l`
        if [ $judge == 1 ];then
                echo    "$IP:$i"
        fi
  done
Last modification:May 12th, 2019 at 12:22 am