#!/bin/bash for port in {1..9999}; do echo -n "TCP $port: " result=$(nc "$1" "$port" -w 1 2>&1 < /dev/null) if [ "$?" -eq 0 ]; then echo "Open" continue fi if [[ "$result" == *refused* ]]; then echo "Closed" fi if [[ "$result" == *time* ]]; then echo "$port" >> block_list.txt echo "BLOCKED" fi done