Skip to content

Instantly share code, notes, and snippets.

@thonixx
Created February 20, 2017 13:41
Show Gist options
  • Save thonixx/98c64ca5043d046f01ae53de2e21f496 to your computer and use it in GitHub Desktop.
Save thonixx/98c64ca5043d046f01ae53de2e21f496 to your computer and use it in GitHub Desktop.
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