Skip to content

Instantly share code, notes, and snippets.

@itay-grudev
Last active March 19, 2021 19:53
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save itay-grudev/d3d4eb0dc4e239d96c84 to your computer and use it in GitHub Desktop.
Save itay-grudev/d3d4eb0dc4e239d96c84 to your computer and use it in GitHub Desktop.
BT WiFi Maintain Connectivity Script

BT WiFi Maintain Connectivity Script

Usage

btauth --user USER_OR_EMAIL --pass PASSWORD # To Authenticate with the BT WiFi
btmaintain --user USER_OR_EMAIL --pass PASSWORD # To maintain a connection and re-authenticate automatically
nohup btmaintain --user USER_OR_EMAIL --pass PASSWORD 2>&1 >/dev/null & # Same as above but ran in background

This will check whether you lost connectivity by pinging google.com every 1 second. If you are not it will check whether the SSL certificate of google.com had been replaced with a BT WiFi certificate and re-authenticate you via btauth.

Installation

Download or copy both scripts to /usr/local/bin and give them execute permissions:

mkdir -p /usr/local/bin
curl -sSL https://goo.gl/2gto0U > /usr/local/bin/btauth
chmod +x /usr/local/bin/btauth
curl -sSL https://goo.gl/07sNF1 > /usr/local/bin/btmaintain
chmod +x /usr/local/bin/btmaintain

License

BTAuth Copyright (C) 2015 Itay Grudev

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

See http://www.gnu.org/licenses/ for the full text of the GNU General Public License.

#!/bin/bash
# BTAuth Copyright (C) 2015 Itay Grudev
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# See http://www.gnu.org/licenses/ for the full text of the GNU
# General Public License.
function usage {
echo 'Usage:' $(basename $0) '--user USER --pass PASS [-h] [--help]'
exit 2
}
userset=0
passset=0
for i
do
parsed=0
case "$i"
in
-h|--help)
usage;;
--user)
userset=1
BTUSER="$2"; shift;
shift;;
--pass)
passset=1
BTPASS="$2"; shift;
shift;;
--)
shift;
break;;
esac
done
if [ $userset == 0 ]; then usage; fi
if [ $passset == 0 ]; then usage; fi
curl --data "username=$BTUSER&password=$BTPASS&submit=Login" https://www.btopenzone.com:8443/tbbLogon
#!/bin/bash
# BTAuth Copyright (C) 2015 Itay Grudev
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# See http://www.gnu.org/licenses/ for the full text of the GNU
# General Public License.
while true; do
ping -c 1 -t 1 google.com 2>/dev/null >/dev/null
if [ $? == 2 ]; then
echo | openssl s_client -showcerts -status -connect google.com:443 2>/dev/null | openssl x509 -inform pem -noout -subject | grep CN=www.btwifi.com 2>/dev/null >/dev/null
if [ $? == 0 ]; then
echo 'Logging in'
btauth $@
fi
fi
sleep 1
done
@itay-grudev
Copy link
Author

itay-grudev commented Aug 18, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment