Sriram Krishnan (Moved to http://www.sriramkrishnan.com/blog)

Search. Usability. Virtual machines.Geek stuff

<December 2008>
SuMoTuWeThFrSa
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910


Navigation

Subscriptions

News

Link blog
Technorati Profile
The Blogs I read
Creative Commons Licence
This work is licensed under a Creative Commons License.


Monday, April 04, 2005 - Posts

Net4India connector on Windows and Linux

The only thing I don't like about my broadband connection (Net4India) is their horrible connector. It's a Win32 application which opens up an ad-page every time I connect.Also, there's no connector available for Linux. On Windows, that application makes me disable all my other ethernet cards as it picks the first one it finds.

 

This evening, I got really annoyed - so I pulled out Ethereal and after some hacking, wrote my own connector. It works on Windows and it *should* work on Linux though I haven't tested it yet. Replace the username, password, dns server and ethernet mac address with your own.

 

On Windows, save the code below as Connector.py and run it after installing Python from www.python.org (for the benefit of those who are new to Python). On most Linux distros, you should have Python installed, so executing it shouldn't be a problem. 

Of course, no guarantess and don't blame me if your computer explodes or Net4India sues you :-)

 

 

#!/usr/bin/env python


import sys
from socket import *
import time

# Simple Net4India Connector - fill in the values below and you're good to go.

#TODO:There's no explicit disconnection
# yet - you just have to kill the program.Net4India will disconnect you automatically within 5 minutes
#Not that it isn't possible - I'm just too lazy. If anyone is interested,
# all you have to do send  "reqType=logout##@@##sessionID="+ session_id + "##@@##dummy=dummyone" + chr(10)



# Replace the following values with your own
user_name = "your_user_name"
password = "your_password"

# Find the MAC address by ipconfig /all on Win2k and above and winipcfg on Win9x.
# See /sbin/ifconfig eth0 on Linux. Replace eth0 with the correct ethernet card

mac_address = "00-0B-2B-13-C3-27" # Your mac address

# Ask your local guy what your DNS server address is. Or find it from ipconfig /all if already configured
dns_server = "10.32.0.2"

port = 6699

server_message = ""

def make_connection():
    cli_sock = socket(AF_INET, SOCK_STREAM)

    if  cli_sock.connect( (dns_server,port)) == -1:
        print "Connection error"
        sys.exit(-1)
    return cli_sock
    
 
def send_command(command):

    global server_message
    
    cli_sock = make_connection()
    cli_sock.send(command)
    server_message = cli_sock.recv(400)

    cli_sock.close()
    
    return  server_message.startswith("YES")
    
  


def main():

    print "Sriram's Net4India Connector SRIRAMK@GMAIL.COM"

    mac_str = "reqType=init##@@##mac=" + mac_address + "##@@##dummy=dummy" + chr(10)

    connect_str = "reqType=login##@@##user=" + user_name + "##@@##password=" + password + "##@@##macAddress=" + mac_address + "##@@##version=1, 0, 0, 6##@@##dummy=dummy" + chr(10)

  
    if not send_command(mac_str):
        print "MAC Authentication error. Wrong ethernet card or card not recognized by local provider"
        sys.exit(-1)

        
    if not send_command(connect_str):
        print "Couldn't connect. Entire message is " + server_message
        sys.exit(-1)

       
    print "Connected!.Leave this program running to stay connected"

    
    session_id =  server_message.split("##@@##")[1] # See the other values of this list for things like
                                                    # data transferred, time left,etc.

    #Connection has to be refreshed every 5 minutes. To play it safe,I'm refreshing every 4 minutes.

    refresh_str = "reqType=refresh##@@##sessionID=" + session_id + "##@@##dummy=dummyone" + chr(10)

    while True:
        time.sleep(240)
        
        if not send_command(refresh_str):
            print "Couldn't refresh. Entire message is " + server_message
            sys.exit(-1)

 
if __name__ == '__main__':
    main()

posted Monday, April 04, 2005 8:49 PM by sriram

Outlook quote fix
For those among you who (like me) struggle with plain text mailing lists in Outlook, you might finally have an answer. Outlook QuoteFix (http://home.in.tum.de/~jain/software/outlook-quotefix/) let's you bottom post easily, with proper quoting and all without having to cut-paste large amounts of text.  It sits in the system tray and processes mails. I wish it were an add-in though - that would have been a lot easier to work with than having to launch Outlook from this application everytime.

posted Monday, April 04, 2005 1:01 AM by sriram




Powered by Dot Net Junkies, by Telligent Systems