Created
January 7, 2017 10:40
-
-
Save iamgroot42/57ba462fee914a81bf5c81650db87ac5 to your computer and use it in GitHub Desktop.
A simple Python script to log into IIITD's firewall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
import time | |
time.sleep(1) | |
link = "http://www.gogole.com/" | |
req = urllib2.Request(link) | |
response = urllib2.urlopen(req) | |
a = response.read() | |
try: | |
c = a[a.find("magic"):] | |
e = c[:c.find(">")] | |
d = e.split("value=")[1].split("\"")[1] | |
except: | |
print "Already logged in" | |
exit() | |
username = raw_input("Username: ") | |
pwd = raw_input("Password: ") | |
k = {"magic":d,"username":username,"password":pwd} | |
url = response.url | |
data = urllib.urlencode(k) | |
req = urllib2.Request(url, data) | |
response = urllib2.urlopen(req) | |
print "Logged in" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment