PDA

View Full Version : Automated registration with a wireless network




chardin
Oct 23, 2010, 11:09 AM
The script:

http://www.naming-schemes.org/~chardin/register_with_network.pl

The explanation:

A lot of wireless venues require their users to open a browser and submit some information (email address, agree to terms of service, etc.). For example, I often work from Caribou Coffee (http://www.cariboucoffee.com/), which requires me to give my email address before I can use their network. This is an annoying hassle and I decided to cheat instead.

I have written a Perl script which automates this process; based on a passed-in wireless SSID, it will run an automated web client through a*specified sequence of actions to register with the network. The SSID can be obtained via the command line:

/usr/sbin/ioreg -l -n AirPortDriver | grep APCurrentSSID | sed 's/^.*= "\(.*\)".*$/\1/; s/ /_/g'

This should then be passed to the script as an argument:

perl register_with_network.pl <ssid>

Notes:

You will need to acquire the Perl modules WWW::Mechanize (http://search.cpan.org/perldoc?WWW::Mechanize), HTTP::Response (http://search.cpan.org/perldoc?HTTP::Response), and HTTP::Cookies (http://search.cpan.org/perldoc?HTTP::Cookies). You'll also probably want Crypt::SSLeay (http://search.cpan.org/perldoc?Crypt::SSLeay) if the registration sequence includes SSL-secured pages. For example, Caribou does.
You will need to specify the sequence of actions for the network you're on. I've included an example for Caribou which requires only that you fill in your email address in the obvious place, but different venues will require different procedures.
I run this script once a minute via cron. This minimizes the delay in registration.


Future improvements:


It'd be good to be able to specify a web field by its name alone; if that field name is unique on the page, and it usually is, one can select the form without knowing its placement within the form.
The option to specify a form by name would also be good.
The final_action flag is for debugging purposes. If the script is not working as you'd expect, run it in the Perl debugger with a breakpoint for that flag and you can see where you're at in the registration process.
In the specific case of the Caribou network, if you have not already registered your email address with them at a previous visit, you'll need to do that manually. This is probably true of other venues as well.


Other potential improvements:


Get rid of the username/password specificity in the code, in favor of a field name/value hash.
Allow for the possibility of more than one form on a page, and allow a flag to suppress form submission where appropriate.
Permit user-by-user population of %shops through the use of an initialization file, so that the script can be stored in one central location with user-by-user customization.