Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- import mechanize
- import time
- from optparse import OptionParser
- import getpass
- def Login(username,password):
- print ">>> trying to connect.."
- br = mechanize.Browser()
- response = br.open('https://login.tikona.in')
- print ">>> ok"
- print ">>> " + br.title()
- #print response.geturl()
- #print ">>>"
- print ">>> redirecting to login.do"
- br.select_form(nr=0)
- br.form.action = 'https://login.tikona.in/userportal/login.do?requesturi=http%3A%2F%2F1.254.254.254%2F&act=null'
- br.form.method = 'POST'
- print ">>> submitting.."
- response = br.submit()
- print ">>> got response"
- br.select_form(name="form1")
- br["username"] = username
- br["password"] = password
- br.find_control(name="type").value = ["2"]
- br.form.method="POST"
- print ">>> proceeding to login.."
- br.form.action="https://login.tikona.in/userportal/newlogin.do?phone=0"
- print ">>> loggin in..."
- print ">>> ok "
- print ">>> " + br.title()
- response = br.submit()
- #response.get_data()
- print ""
- print 50 * "*"
- print ""
- print response.info()
- print 50 * "*"
- print ""
- #print response.read()
- def Logout():
- print "Logging out.."
- br = mechanize.Browser()
- response = br.open('https://login.tikona.in/userportal/logout.do?svccat=1')
- print response.geturl()
- print response.info()
- print response.read()
- def main():
- parser = OptionParser()
- usage = "Usage: %prog -u <username>"
- parser = OptionParser(usage=usage, version="%prog 1.0")
- parser.add_option("-u", "--username", action="store", type="string",dest="user", help="Username to login")
- (options, args) = parser.parse_args()
- if options.user:
- password = getpass.getpass()
- Login(options.user,password)
- else:
- print "Fatal: Required arguments are missing!"
- print "Use: -h / --help to get help."
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment