Ubuntu: free wifi with web html login page - auto login?



Question:

A place where I visit very regularly had open access free wifi with no password on the wifi SSID

However, it's one of the ones where you can connect to the wifi, but when you try to go to a webpage, it first redirects you to a login page, where you have to put in the username and password. The username and password very rarely change (i.e. it's not changed for at least a year).

Quite frequently my connection drops and I have to go through the logon process again, is there any way to automate this with a script in Linux?

Thanks


Solution:1

You can perform this with the command POST :

POST http://[ADRESS]:[PORT]/ <<< 'auth_user=ID&auth_pass=PASSWORD&accept=Continue'  

Then you just have to copy this script in the folder /etc/NetworkManager/dispatcher.d/. When your connect to a network with NetworkManager, it will pass the interface used in $1 and if this is a connect or disconnect in $2 to your script.

#!/bin/bash  if [ "$1 $2" = 'wlan0 up' ]  then      essid=$(iwconfig wlan0 | grep -o 'ESSID:".*$' | sed 's/^ESSID:"\(.*\)".*$/\1/')      case "$essid" in          'Freewifi')              POST http://[ADRESS]:[PORT]/ <<< 'auth_user=ID&auth_pass=PASSWORD&accept=Continue' ;;          'Other')              POST http://[ADRESS]:[PORT] <<< 'accept_cgu=1' ;;      esac  fi  

Be aware to fill all required input in your form (sometimes there is security input and that can be really complicated to automate the connexion in a script).

That was a long time ago that I perform an script to perform this and I didn't test it.

Hope this answer help.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »