Created
November 21, 2016 15:05
-
-
Save chew-z/34e6dbb130970c32438cd840da9e3934 to your computer and use it in GitHub Desktop.
Check router connection hijacking (captive portal)
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
| #!/usr/bin/env zsh | |
| # adapted from Alterstep dnscrypt-proxy OSX client | |
| try_resolution() { | |
| exec alarmer 5 dig +tries=2 +time=3 +short github.com | egrep '^192[.]30[.]' > /dev/null 2>&1 | |
| } | |
| try_http_query() { | |
| exec alarmer 5 curl -L --max-redirs 5 -4 -m 5 --connect-timeout 5 -s \ | |
| http://icanhazip.com/ 2>/dev/null | \ | |
| fgrep -c '.' > /dev/null 2>&1 | |
| } | |
| try_everything() { | |
| try_resolution & | |
| resolution_pid=$! | |
| try_http_query & | |
| http_query_pid=$! | |
| wait $resolution_pid | |
| resolution_ret=$? | |
| if [ $resolution_ret != 0 ]; then | |
| return 1 | |
| fi | |
| wait $http_query_pid | |
| http_query_ret=$? | |
| [ $resolution_ret = 0 -a $http_query_ret = 0 ] | |
| } | |
| try_everything_with_retries() { | |
| try_everything || try_everything | |
| } | |
| try_everything_with_retries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment