Skip to content

Instantly share code, notes, and snippets.

@yhvhnl
Forked from vfreex/scan_isp_blocklist.sh
Created April 11, 2024 12:27
Show Gist options
  • Select an option

  • Save yhvhnl/5a44c67eca1794c463c260a9fc105278 to your computer and use it in GitHub Desktop.

Select an option

Save yhvhnl/5a44c67eca1794c463c260a9fc105278 to your computer and use it in GitHub Desktop.
Test which TCP ports are blocked by my ISP
#!/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