Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check a website with custom IP and ports
#!/bin/bash
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
bold="$(tput bold)"
reset="$(tput sgr0)"
test -z $1 && read -p "Which IP to test on? " apg || apg=$1
test -z $2 && read -p "Which port is behind NAT for HTTP? " nat_http || nat_http=$2
test -z $3 && read -p "Which port is behind NAT for HTTP${red}${bold}S${reset}? " nat_https || nat_https=$3
echo
echo ${yellow}Checking websites on $apg \(http $nat_http / https $nat_https\)...$reset
unset http_host
unset request_uri
while true
do
echo
echo ++++++++++++++++
echo
old_http_host=$http_host
read -p "Which HTTP_HOST? $(test $old_http_host && echo "(default: $http_host) ")" http_host && test -z $http_host && http_host=$old_http_host
old_request=$request_uri
read -p "Which REQUEST_URI? $(test $old_request && echo "(default: $request_uri) ")" request_uri && test -z $request_uri && request_uri=$old_request
echo
echo Trying with$green $http_host/$request_uri http$reset
echo +++
curl --connect-timeout 5 -Isk http://$apg:$nat_http/$request_uri -H Host:$http_host | sed -En '/(HTTP|Location)/p'
echo
echo
echo Trying with$green $http_host/$request_uri https$reset
echo +++
curl --connect-timeout 5 -Isk https://$apg:$nat_https/$request_uri -H Host:$http_host | sed -En '/(HTTP|Location)/p'
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment