Created
May 5, 2022 21:51
-
-
Save atucom/60c34f3ac5b686373ac6db7295309cbd to your computer and use it in GitHub Desktop.
Check if IP/IP:Port is web port
This file contains 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
#!/usr/bin/env bash | |
if [[ "$1" = '-h' ]] || [[ "$1" = '--help' ]] || [[ -z "$1" ]]; then | |
echo "Specify an IP:port to check if it's web and what protocol" | |
echo "this first checks https then http" | |
echo | |
echo "Example: $0 1.1.1.1:3040" | |
echo "or" | |
echo "Example: $0 1.1.1.1" | |
exit 1 | |
else | |
TARGET_IP_PORT=${1} | |
if curl -m 3 -v -k https://${TARGET_IP_PORT} &> /dev/null; then | |
echo https://${TARGET_IP_PORT} is good | |
exit | |
fi | |
if curl -m 3 -v -k http://${TARGET_IP_PORT} &> /dev/null; then | |
echo http://${TARGET_IP_PORT} is good | |
exit | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment