ACT Broadband Portal Auto Login [Python]

Folks,
As you know the default login page for ACT portal (only ACT Broadband subscribers) is quite pesky and it never saves the password which you issue always. So it becomes quite irritating process to issue the credentials each time you want to unlock your internet connection. Here is a script which would automate the process for you. You just need to pass your username and password in the appropriate places and the script is good to go.

Just notice how the HTTP request is crafted in the script. You just need to pass your userid and password in the appropriate places and you are all set. However, you need to have httplib2 module before running the script. You can download the Python script from this location. Otherwise you can navigate through my GitHub repository here.

Below is the same code if you want to refer:

#!/usr/bin/env python
def main():
    try:
        import time, re, sys, httplib2
    except ImportError:
        print '\xaf [Err] httplib2 Module not found!'
        print '\xaf [Inf] Please install httplib2 module and try again.'
        sys.exit(0)

    print '\xaf [Inf] Logging into ACT Portal...'
    time.sleep(2)

    url     = 'http://portal.acttv.in/newportal/Ajax.php?function=ExecuteLogin&user=<8-Digit-UserID>&pwd=<Your_Password>&remember=true&timestamp=1334843162800'
    headers = { 'Referer': 'http://portal.acttv.in/', \
                'Accept-Language': 'en-in', \
                'Accept-Encoding': 'gzip, deflate', \
                'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5', \
                'Connection': 'Keep-Alive', \
                'Host': 'portal.acttv.in', \
                'Cookie': 'remember=true; username=<8-Digit-UserID>; password=<Your_Password>; 555c12b67d7c4fc92c79875dd3d3a5b1=664ga1327500ispsuk5c62p4o2' }

    http = httplib2.Http()
    print '\xaf [Inf] Sending authentication request to ACT Gateway...'
    time.sleep(2)

    try:
        response, content = http.request(url, 'GET', headers=headers)
    except httplib2.ServerNotFoundError:
        print '\xaf [Err] Portal.ActTV.in server not reachable.\n\xaf [Inf] Please restart the router and try again.'
        sys.exit(0)

    if re.findall('[0-9]{8}\x20at\x20', content):
        print '\xaf [Inf] Connection unlocked.'
        print '\n\xaf [Chk] Validating if web resources are accessible. Please wait...'
        try:
            url = 'http://www.blackle.com/'
            headers = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5', \
                        'Host': 'blackle.com' }

            print '\xaf [Inf] Accessing Host:', url
            response, content = http.request(url, 'GET', headers=headers)
            if int(response['status']) == 200:
                print '\xaf [Inf] Everything looks perfect!'
                print '\xaf [Inf] Connection established successfully!'
                sys.exit(0)
            else:
                print '[Err]  Webpage not accessible.'
        except httplib2.ServerNotFoundError:
            print '\xaf [Err]  External websites inaccessible.'
            print '\xaf [Inf]  Please contact your ISP to troubleshoot the problem.'
            sys.exit(0)
    else:
        print '\xaf [Err]  Sorry, couldn\'t establish connection successfully with the server!'
        print '\xaf [Inf]  Please verify the passed Username//Password. '
        sys.exit(0)

def banner():
    print '''################################################################################
##     Name     :     ActLog                                                  ##
##     Purpose  :     Program to login to ACT Web Gateway                     ##
##     Author   :     Sujit Ghosal (xylux [at] wikisecure [dot] net)          ##
##     Created  :     19-04-2012                                              ##
################################################################################
    '''

if __name__ == '__main__':
    banner() ; main()

Hope it helps somebody in anyways! ;)

Enjoy!
XyluX

Apr 21st, 2012 | Posted in Programming
  1. Prasad
    Jun 22nd, 2014 at 19:02 | #1

    Hi,

    Its not working now.

    Looks like the URL got changed.

    Any updates ?

    Thanks in advance.

    • XyluX
      Aug 12th, 2014 at 15:48 | #2

      Prasad, could you please tell which one is not working exactly? The Python script file URL (the GitHub repo) or the ACT Portal Login URL? Please clarify. :)

    • XyluX
      Aug 12th, 2014 at 15:52 | #3

      I have fixed the GitHub Python code URL though. Let me know if it solved your problem anyways.

  2. Hemanth
    May 21st, 2014 at 23:03 | #4

    Hey Guys,

    Is this script still working? Can some one please help? I am on a MAC, i get the following error :-
    line 1

    ^
    SyntaxError: invalid syntax

    • XyluX
      Aug 12th, 2014 at 15:43 | #5

      Just check what is your Python version. It should be 2.x (2.7 preferred though).

  3. XyluX
    May 25th, 2012 at 12:16 | #6

    Joydeep,
    I am glad that the script helped you out!! :)

  4. Joydeep
    May 24th, 2012 at 08:06 | #7

    Joydeep :
    Hi XyluX
    As suggested I installed Python 2.7.3. But then while installing httplib2 module I got the following error
    SyntaxError: (‘invalid syntax’, (‘D:\\Python27\\Lib\\site-packages\\httplib2\\__init__.py’, 343, 31, ” print(‘%s:’ % h, end=’ ‘, file=self._fp)\n”))
    And while running the script I’m getting the error as below
    File “D:\Python27\lib\site-packages\httplib2\__init__.py”, line 343
    print(‘%s:’ % h, end=’ ‘, file=self._fp)
    Please advise.
    Thanks
    Joydeep

    hey found the solution here
    http://code.google.com/p/httplib2/issues/detail?id=172

    removed everything and reinstalled again and it seems to work now..thanks a lot for the script Sujit :)

  5. Joydeep
    May 24th, 2012 at 01:30 | #8

    Hi XyluX
    As suggested I installed Python 2.7.3. But then while installing httplib2 module I got the following error

    SyntaxError: (‘invalid syntax’, (‘D:\\Python27\\Lib\\site-packages\\httplib2\\__init__.py’, 343, 31, ” print(‘%s:’ % h, end=’ ‘, file=self._fp)\n”))

    And while running the script I’m getting the error as below

    File “D:\Python27\lib\site-packages\httplib2\__init__.py”, line 343
    print(‘%s:’ % h, end=’ ‘, file=self._fp)

    Please advise.

    Thanks
    Joydeep

  6. XyluX
    May 23rd, 2012 at 14:04 | #9

    Joydeep,
    For Python v3.x series *print* statement is considered as a function and you need to pass arguments to the print function otherwise it won’t work. But in Python v2.x versions the approach is slightly different. That’s why you are coming up with an Invalid syntax error.

    FYI, I have tested my program with Python v2.5 and Python v2.7 and it works without any issues.

    You better install Python v2.5 or Python v2.7, install httplib2 module and run this script. It should definitely work! :) Let me know if still you are having any issues.

    - XyluX

  7. Joydeep
    May 23rd, 2012 at 12:12 | #10

    This is giving me an invalid syntax at the following line.

    print ‘\xaf [Err] httplib2 Module not found!’

    I am using Python 3.2.3 64bit and have installed the httplib2 module 0.7.4. Please advise how to use this script or the python and httplib2 versions that you have tested this with.

    Thanks.
    Joydeep

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Current ye@r *