Skip to content

Instantly share code, notes, and snippets.

@iamgroot42
Created January 7, 2017 10:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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