engineering and stuff

Auto Login WiFi – University, Hotels Etc

| Comments

When using the University WiFi I found it annoying that I always had to login through a browser using my university username and password. Using the simple scripts below, this bothersome procedure can be done automatically each time the computer discovers a network. I am using Wicd Network Manager, which has a nice feature where one can include scripts that you want to run when the computer connects and disconnects to a network ( see wicd documentation). Using this feature I made a short script to run different tasks when the computer discovered different Wifi’s. I have a file called in the directory /etc/wicd/scripts/postconnect on my linux machine with the following code:



if 	[ "${essid}" == "Foo network" ]; then
	# do something when logging into 'Foo network'
elif [ "${essid}" == "Bar network" ]; then
	# do something else when connecting to 'Bar network'

I then use a python script called that performs the nessecary login procedure. If I am not mistaken, with Wicd one has to have this in a directory with only root access. The source for

import requests
import sys


print "This is an automatic login to Foo network"
URL='<login url>' 
EMAIL = '<your email>'
PASSWORD = '<your password>'

def main():
   # Start a session so we can have persistant cookies
   session = requests.session(config={'verbose': sys.stderr})
   # use headers that is posted in the HTML POSt method
   # use data originally in your html-login
   login_data = {
        'username': EMAIL,
        'password': PASSWORD,
    r =, data=login_data, headers=headers, timeout=10.00)

if __name__ == '__main__':

When using the code above one has to use the headers and data used in the post method. The way I got the data from a login to the university was through using a Firefox Extension called Live HTTP Headers, as I found that chrome would not show HTTP traffic for HTTPS sites.

After monitoring a login using Live HTTP headers one can fill in the headers and data. Im sure there is a way of automating this task So feel free to share.