-
-
Save BA0GE/577e9e37683e9a8b6fdc72b62f9ea878 to your computer and use it in GitHub Desktop.
Test which TCP ports are blocked by my ISP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment