Skip to content

Instantly share code, notes, and snippets.

@iamgroot42
Created January 7, 2017 10:40
Show Gist options
  • Save iamgroot42/57ba462fee914a81bf5c81650db87ac5 to your computer and use it in GitHub Desktop.
Save iamgroot42/57ba462fee914a81bf5c81650db87ac5 to your computer and use it in GitHub Desktop.
A simple Python script to log into IIITD's firewall
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