Reliance Wireless broadband auto-login (and logout) script(s)

The old “curl” based method stopped working yesterday when Reliance got a new login page as well as a new backend. It seems Reliance is now also looking at Cookies during authentication. Here’s a little Python script that you can execute to automate the process.

If you don’t know what Python is, you better stick to browser based authentication 🙂

Needless to say, you can schedule this script as a cron/ launchd job to run periodically and keep you logged in. That’s how I use it, which is why the script doesn’t output anything to prevent unnecessary log “pollution”.

Login Script for Python 2.x

#!/usr/bin/env python
# encoding: utf-8
"""
Reliance Login Script for Python 2.x v1.0

Created by Kunal Dua on 2009-12-18
Reliance Wireless broadband auto-login (and logout) script(s)
This program is free software; you may redistribute it and/or modify it under the same terms as Python itself. """ import urllib2, urllib, cookielib username = '1111111111111111' #replace the text within quotes with your username password = 'password' #replace the text within quotes with your password jar = cookielib.FileCookieJar("cookies") opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar)) response = opener.open("http://10.239.89.15/reliance/startportal_isg.do") login_data = urllib.urlencode({'userId' : username, 'password' : password, 'action' : 'doLoginSubmit'}) resp = opener.open('http://10.239.89.15/reliance/login.do', login_data)

Update: Logout Script for Python 2.x

#!/usr/bin/env python
# encoding: utf-8
"""
Reliance Logout Script v1.0

Created by Kunal Dua on 2009-12-22
http://www.kunaldua.com/blog/?p=323

This program is free software; you may redistribute it and/or
modify it under the same terms as Python itself.
"""

import urllib2, cookielib

jar = cookielib.FileCookieJar("cookies")
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))

response = opener.open("http://10.239.89.15/reliance/login.do", timeout=2)

resp = opener.open('http://10.239.89.15/reliance/logout.do')

Update: Login Script for Python 3.x

#!/usr/bin/env python
# encoding: utf-8
"""
Reliance Login Script for Python 3.0 v1.0

Created by Kunal Dua on 2009-12-30
http://www.kunaldua.com/blog/?p=323

This program is free software; you may redistribute it and/or
modify it under the same terms as Python itself.
"""

import urllib, http.cookiejar

username = '1111111111111111' #replace the text within quotes with your username
password = 'password'	#replace the text within quotes with your password

jar = http.cookiejar.FileCookieJar("cookies")
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))

response = opener.open("http://10.239.89.15/reliance/startportal_isg.do")

login_data = urllib.parse.urlencode({'userId' : username, 'password' : password, 'action' : 'doLoginSubmit'})
resp = opener.open('http://10.239.89.15/reliance/login.do', login_data)

59 Comments

  1. Hi Kunal,
    The script works perfectly fine.
    Thanks a lot.

    Do you mind if I post your script(giving you due credits) on my site?

  2. I tried to run it with .html extension after filling in my user id and password.still its not working.Can u please provide with html based script

  3. hai kunal…

    i dont know anythin abt python…i early used a html based page to permanent login…could u plz give html based script for permanent login….

  4. Hey mate,

    I would like to thank you again for this wonderful script. I’m adding it [URL=”http://www.indiabroadband.net/reliance-broadband/5173-reliance-broadnet-permanent-login-system-download-3.html”]here[/URL] for the benefit of other users in the community. I’ve kept the whole script as-is. Hope you don’t mind. Thanks again. 🙂

    P.S. A script to logout would be just great to automate the whole process… but only if its not too much of a hassle. Thanks again

    1. Thanks for the python script, but you can use the curl as well. You need to make the following changes to the curl method as shown below:
      1. Add cookie support
      2. Add referrer (not necessary, but makes it spoof any smart ass looking out for people bypassing browsers at Reliance end)

      curl -A “User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 GTB6 (.NET CLR 3.5.30729)” -e http : / / w w w . reliancebroadband . co . in/reliance/login.do -b relcookie -d “userId=YOUR_USER_ID_HERE&password=YOUR_PASSWORD_HERE” “http : / / w w w . reliancebroadband . co . in / reliance/login.do?action=doLoginSubmit” –connect-timeout 15 –max-time 20 –retry 2 –retry-delay 5

      Remove the spaces in the URL above.

      Let me know if it worked for you. It works fine with me. 🙂

      1. Thanks Kumar. You can of course use curl/ wget – I used Python cause I am more familiar with it .

        I’ll add the curl + wget approaches to the post for anyone who’d prefer that.

        1. Just wanted to point out that there are a couple of small errors in the curl command above, specifically with the dashes in front of the 2 retrys. It should read:

          curl -A “User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 GTB6 (.NET CLR 3.5.30729)” -e http : / / www . reliancebroadband . co . in / reliance / login . do -b relcookie “http : / / www . reliancebroadband . co . in / reliance / logout.do” –connect-time 15 –max-time 20

          FYI, I’m on a MacBook Pro running Snow Leopard.

          1. Oops. I accidentally posted the logout script instead of the login script. Anyway, now I see what’s going on. The comments system here is converting 2 dashes (i.e. – -) into a single long dash (i.e. –). To get the curl command for login to work, put 2 dashes in front of ‘connect-timeout’, ‘max-time” and the 2 ‘retry’ s instead of the single long dashes that you see. To get the logout script to work, put 2 dashes instead of the single long dash in front of ‘connect-time’ and ‘max-time’.

  5. Kunal Can you please explain step by step procedure to run this script ..i have installed python software but i still cant make out how to execute your login and logout script…

    Please explain step by step so that other users can also follow it.

  6. Your Script works fine on Windows Xp, but its not working on Vista…can you please check the problem

  7. it says

    Traceback (most recent call last):
    File “C:reliance.py”, line 13, in
    import urllib2, urllib, cookielib
    ImportError: No module named urllib2

  8. can sum1 plz giv a step by step explanation of how this works. plz. wud b gr8 help.
    thanks in advance.

  9. Hey Kunal,

    urllib2 and cookielib don’t exist in latest python version.

    I figured out that urllib.request is to be used instead of urllib2 or urllib. Tried copying cookielib.py as well, but the dependency goes on increasing.
    Can you port this to 3.1.1 please

  10. great scripts.

    Minor modifications:

    better to use reliancebroadband.co.in instead of ip address.

    Also in logout script
    resp = opener.open(‘http://reliancebroadband.co.in/reliance/logout.do’)
    is sufficient

  11. @Karan
    The IP works better for people who use non Reliance DNS e.g. Open DNS – since the hostname won’t resolve in that case without logging in. Of course this means that the script will need to be updated in case Reliance makes any internal changes.

    As for the logout script, as per my testing, if there’s a long gap between login and logout scripts, just visiting the logout page doesn’t always work. Hence the extra step.

    Cheers.

  12. It worked for me thanks…
    🙂

    And here is the modified logout script for 3.x.
    Note: modified the above given logout script for 2.X.
    😀

    #!/usr/bin/env python
    # encoding: utf-8
    “””
    Reliance Logout Script v1.0

    Created by Kunal Dua on 2009-12-22
    http://www.kunaldua.com/blog/?p=323

    This program is free software; you may redistribute it and/or
    modify it under the same terms as Python itself.
    “””

    import urllib, http.cookiejar

    jar = http.cookiejar.FileCookieJar(“cookies”)
    opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))

    response = opener.open(“http://10.239.89.15/reliance/login.do”, timeout=2)

    resp = opener.open(‘http://10.239.89.15/reliance/logout.do’)

  13. Hi Kunal,
    First off, thanks for providing the Python scripts! My question is do you personally use the Logout script? Wouldn’t just running the Login python script every few minutes using cron work, without touching the Logout script at all?

    1. You are correct. I don’t really use the logout script since I have scheduled the login script as a launcd agent that runs periodically. That’s why I didn’t even write the logout script until someone requested for it.

      I do sometimes find myself using it now, to manually “refresh” the session via this shell script:

      logout.py
      sleep 10 # the logout takes some time to affect
      login.py

      1. What makes you choose to “refresh” the session?

        Also, how often does your launchd agent run? I’m using cron (only because I don’t know how to use launchd) and have it run every 3 minutes at the moment. Is there an advantage to using launchd over cron?

        Sorry if my questions seem obvious to you but I have very little UNIX knowledge, and whatever I’ve learnt has come from web research today, based on my need for autologin for Reliance Wimax. Having said that, I do have a bit of a geek background, and I love learning new stuff.

  14. Getting the Foll. error:

    root@ipcop:~ # ./reliance_connect.py
    Traceback (most recent call last):
    File “./reliance_connect.py”, line 13, in ?
    import urllib2, urllib, cookielib
    File “/usr/lib/python2.3/urllib2.py”, line 91, in ?
    ImportError: No module named ftplib
    root@ipcop:~ #

  15. kunal,
    it wud be great if u gave a step by step guide to ur python script.
    i am a ubuntu 9.10 newbie.

    thanks

  16. Does this type of authentication still work? I was trying it until the Reliance login server crashed at 11 PM yesterday and it didn’t seem to help.

  17. Don’t mind but……….
    How is a regular user with no scripting knowledge supposed to use this??????

    1. Don’t mind, but I mentioned that if you don’t have any knowledge of Python/ scripting, this probably isn’t for you. In any case, just google for this and you’ll find some kind folks with time to spare at Indian Broadband Forum, also give “noob friendly” instructions on how to set this up. Take a look.

  18. Yes I sure read that…..
    And never mind coz I somehow got it to work
    Thanks for the script.

  19. I install python 2.6.5 and paste the code in notepad and save it as vipin.py Now when i run python shell and type python vipin.py so it shows syntex error please tell me what should i do now

  20. Should I just the login script;
    Or first run the logout script and then run the login script after 1 minute (or the duration b/w logout and login should be even more??).

    Also the interval is pretty important, i.e. I should the run script for the intervals of 1 hr, 2 hr, 4 hr, 8 hr or 16 hr. Please shed some light on that!!

  21. Should I just the login script; Or first run the logout script and then run the login script after 1 minute.

    Also the interval is pretty important, i.e. I should the run script for the intervals of 1 hr, 2 hr, 4 hr, 8 hr or 16 hr. Please shed some light on that!!

      1. i did a slight modification to the code and included the waiting time of 20hrs each time the login id successful (since my session resets every 24hrs)

        import urllib, http.cookiejar, time, subprocess

        username = ‘1111111111111111’
        password = ‘password’
        host = “209.85.231.104”

        while True:
        out = subprocess.call(“ping -n 5 %s” % host,
        stdout=None,
        stderr=None
        )
        if out == 1:
        jar = http.cookiejar.FileCookieJar(“cookies”)
        opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(jar))
        login_data = urllib.parse.urlencode({‘userId’ : username, ‘password’ : password, ‘action’ : ‘doLoginSubmit’})
        resp = opener.open(‘http://10.239.89.15/reliance/login.do’, login_data)
        print(resp)
        time.sleep(5)
        check = subprocess.call(“ping -n 1 %s” % host,
        stdout=None,
        stderr=None
        )
        if check == 0:
        time.sleep(72000)
        time.sleep(60)

        fyi the 209.85.231.104 is ip of google. i used it to check if the login is successful.

  22. >>> Python Auto_login.py
    File “”, line 1
    Python Auto_login.py
    ^
    SyntaxError: invalid syntax

    I am getting an error like this when i try running this script…

  23. Hi Rahul. can you plz share how you soeted that out. i am also getting same error.

    Thanks in advance

  24. Hey…

    I am a new reliance broadband customer. I need this script to work but I keep facing this error:

    Traceback (most recent call last):
    File “C:Reliance-autologin.py”, line 24, in
    resp = opener.open(‘http://reliancebroadband.co.in/reliance/logout.do’, login_data)
    File “C:Python32liburllibrequest.py”, line 364, in open
    req = meth(req)
    File “C:Python32liburllibrequest.py”, line 1052, in do_request_
    raise TypeError(“POST data should be bytes”
    TypeError: POST data should be bytes or an iterable of bytes. It cannot be str.

    Please help. I am using Windows 7 with Python v3.2 (64 bit)

  25. Please could somebody upload a video somewhere with a link to show us how to use this wonderful script ??

  26. Hi kunal ,
    first of all congrats and thanks for the wonderful script . I would however like to suggest 1 change.
    why not use import time and run time.sleep( duration ) in an infinite loop..
    That way you dont need to schedule a cron job in the system , and it will run beautifully on windows systems too .
    Just a side suggestion , but you have done the hard part 😛
    cheers
    Ravi

  27. Hi Kunal,

    we have requirement to autologin into Workspace is this will work ??.

    if it works how it works for windows XP i dont know about pythonscript how can i run on this ?
    could u please let me know.

    Thanks,
    Sunitha

  28. dear
    can u tell me how to use this script.
    i am not from any backgroud of computer.
    pls help me
    thanks

  29. can someone help me here.. I am using apple imac and need some help with how to run this script

Leave a Reply to sunitha Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.