~couchNerd ~serialOutrager ~puts2In42 ~makesPigsFly

Automatic Login For Beam Cable

This article will tell you a simple way to login automatically to beam cable (Beam-Telecom) internet connection instead of using the web login manually. Not only that, I’ll also tell you how to do this auto-login through your router if you have one with a custom linux firmware. I took a beam cable connection a few days ago. The price is excellent and speeds are good but the only thing that bothered me was the web based login. You need to open up a browser and login through their online portal before you can access the internet. Now, if you don’t log off, then the login may persist even across PC/router reboots but many times it doesn’t. But in these times, it becomes a pain in the wrong place when I am just looking to play online on my PS3 or one of my various net-capable devices, scattered around the house, are trying to pull data and this forces me to open up my laptop just to login. Even for people who use the internet only on their PC, they might not be using the browser all the time and find it a hassle, minor one but still a hassle, to open a browser and login. Hence, I set out to find a way to do this automatically. (BTW, I’ll also be listing out how I came onto the solution in case you are in interested. If you are not, feel free to skip some paragraphs below to move to the solution)

First off, I came to know that Beam cable supports PPPoE logins, but for the life of me, I (and any of my friends) couldn’t get it working. So, I thought of an alternative approach. Since, this was just a login through a web page, there was a good chance that I could automate it through perl/wget/curl etc. I immediately opened up their portal and took a look at the source code in the hopes of finding out the login form, which I could use to find the POST data that they want and submit it through wget. But what I found was that they are using javascript to do the login process, so no direct way of finding this out. And on top of that, the functions are not embedded in the page but loaded through an external script.

Hmm, a setback but a minor one. Javascript is still a client-side executed environment so all hope wasn’t lost. I could have waded through the browser cache to find the js files loaded by the portal and went through the functions to reconstruct the data that I need but I chose an easier way. There is this excellent addon for firefox called “Live Headers”. It shows you all the transactions happening between your browser and the server. So, I just fired it up, filled in my login details in the portal and hit “Login”. On seeing the live headers log, I found out the exact url as well as the POST data that they were sending to do the actual login and from there it was a piece of cake. With “wget”, it is as simple as executing

wget <url> --post-data=<data>

So, by substituting the information that I got, this is the command that you need to execute on your PC (For linux/mac it is already installed generally and for windows, you will need to download from here)

wget http://123.176.37.2/newportal/Ajax.php --post-data="function=ExecuteLogin&user=YOURBEAMUSERNAME&pwd=YOURBEAMPASSWORD&remember=false&timestamp=1271186686298" 

Please remember to replace YOURBEAMUSERNAME and YOURBEAMPASSWORD with your actual username and password respectively. Also, please note that the above command is all one single line (it might appear in multiple lines in your browser).

So, everytime you need to login just run this command. Now, how to do this automatically? For linux, just put it inside a shell script for linux and set it to run automatically on bootup. For windows, paste the command in a text file, and save it as beam_login.bat and put it in your start up folder so that it runs everytime on boot. (You might want to put some delays in there as it might take some time to get connected to the network or you can query the network interface to run it when the network is up. Let me know if you want to know how to do this for your platform and I can help you).

So, this is for the PC, now how about if I need to use non-browser capable devices. This is easy if you have a router with a custom linux firmware (because they generally have wget installed or allow you to install it). I have an Asus wl-500w with oleg’s custom firmware installed and it was a piece of cake with it. I just created the following shell script

#!/bin/sh 
if [ -e Ajax.php ]       
then        
rm Ajax.php        
fi 
#Limit the number of retries to prevent the router from going into continuous loop       
num_retries=10 
while [ $num_retries -gt 0 ]       
do        
wget http://123.176.37.2/newportal/Ajax.php --post-data="function=ExecuteLogin&user=YOURBEAMUSERNAME&pwd=YOURBEAMPASSWORD&remember=false&timestamp=1271186686298"        
if [ -e Ajax.php ]        
then        
rm Ajax.php        
break        
else        
sleep 2s        
num_retries=`expr $num_retries - 1`        
fi        
done

Then I set it to run on boot and voila!! A tip for other users of any of the asus routers with oleg’s firmware (like wl-500g, wl-520gu, wl-500gp etc). The firmware has some scripts in the /local/sbin folder that are run at various times. I suggest you put the above code inside the post-firewall script. (Do not forget to run “flashfs save && flasfs commit && flashfs enable” to save your changes). Now, every time my router reboots, it automatically logs in to the connection :)

Hope I have been clear in the isntructions. If you are unclear about anything or need any help in implementing it for your specific platform, do let me know.

Comments