# Automatic Login For Beam Cable

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"


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.