Created
March 20, 2019 10:28
-
-
Save krmnn/b8f7c72e120c869d308ef8fcbb09d91f to your computer and use it in GitHub Desktop.
Linux: Automatically accept Use Policy of Deutsche Bahn to use their WiFi when connecting
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 bash | |
# Put this script in "/etc/network/if-up.d/" and make it executable (chmod +x) | |
[ -z "$(iwconfig 2>/dev/null| grep 'WIFIonICE')" ] && exit | |
URL=http://www.wifionice.de/de/ | |
CSRF_TOKEN=$(curl http://www.wifionice.de/de/|grep -oE 'value="[0-9a-f]{32}"' | cut -d = -f2|sed 's/"//g') | |
POST_DATA=" | |
login=true&CSRFToken=${CSRF_TOKEN}&connect=" | |
curl -v -d "$(echo $POST_DATA |sed 's/ /%20/g')" curl -v -A "Mozilla/9000.0 (X11; Linux x86_64; rv:65.0) Gecko/20000000 Firefox/1337" -H "Cookie: csrf=${CSRF_TOKEN}" -d "${POST_DATA}" $URL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment