-
-
Save dicer/b21300fbbfdd8cf011756a8673b6f69c to your computer and use it in GitHub Desktop.
HowTo auto connect your Linux to the German Wifi on ICE trains
This file contains 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
#!/bin/bash | |
# change the next line to match your wifi device and put this file in /etc/NetworkManager/dispatcher.d/ and make it executable | |
WIFI_DEVICE=wlp3s0 | |
IF=$1 | |
STATUS=$2 | |
if [ "$IF" == "$WIFI_DEVICE" ] && [ "$STATUS" == "up" ] && [ $(iwconfig $WIFI_DEVICE | grep -c "ESSID:\"WIFIonICE\"") ] | |
then | |
curl 'http://www.wifionice.de/de/' -H 'Host: www.wifionice.de' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://www.wifionice.de/' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Cookie: csrf=42' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' --data 'login=true&CSRFToken=42&connect=' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First I wanted to get a valid CSRF token first by requesting the main page and extract it. Turns out this is not even necessary as long as the submitted token and the cookie are the same. Currently the captive portal server does not seem to remember the token it gives out.
In case that changes: