天天看点

shell 端口扫描

#!/bin/bash

ipfile=$1

port=$2

tempfile=temp

cat << -EOF- > scan.sh

/usr/bin/telnet \$1 \$2 << ! >temp

quit

!

-EOF-

while  read ip

do

        sh scan.sh $ip $port > /dev/null 2>&1

        if  grep -c Escape temp > /dev/null 2>&1

        then

            echo "$ip $port is open"

        else

            echo "$ip $port is closed"

        fi

done<$ipfile

rm -f ./scan.sh

rm -f ./temp

继续阅读