Port check script

#!/bin/bash
RED=’\033[0;31m’
GREEN=”\033[0;32m”
NC=’\033[0m’ # No Color

function checkport {
if nc -zv -w30 $1 $2 <<< ” &> /dev/null
then
echo “${GREEN}[O]${NC} $1:$2”
else
echo “${RED}[C]${NC} $1:$2”
fi
}

printf “server list:”;
read server
printf “ports list[enter for default]:”
read ports_to_check

if [[ $ports_to_check = “” ]]; then
echo “using default port list”;
ports_to_check=”22 389 3306 8080″; #enter your default list of ports here
echo “$ports_to_check”;
fi

for i in $server;do
{
echo “==========================================”
for j in $ports_to_check ; do
checkport $i $j
done
}; done

Leave a Reply

Your email address will not be published. Required fields are marked *