Hello all, I have been trying for a few days now and done quite a bit of reasearch on the internet and this website to find out how I can authenicate to a website. It could very well be that this particualar web server is picky I'm not to sure. It would be great if I could get some help with this, I would also recommend the site to anybody with some free time on their hands and that doesn't wanna sit around thinking of ideas for programs all day. They have a fun list of entertaining challenges. Here is the code that I have came up with so far but no success in logging in.
import urllib, urllib2, cookielib
username = 'username'
password = 'password'
host = 'www.hackthissite.org'
user_agent = 'Mozilla/4.0 (compatible; MSIE 6.0)'
referer = 'http://www.hackthissite.org/user/login'
content_type = 'application/x-www-form-urlencoded'
accept_encoding = 'gzip,deflate'
values = {'Host': 'www.hackthissite.org',
'User-Agent':'Mozilla/4.0 (compatible; MSIE 8.0)',
'Referer':'http://www.hackthissite.org/user/login',
'Content-Type':'application/x-www-form-urlencoded',
'Accept-Encoding':'gzip,deflate',
}
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
data = urllib.urlencode(values)
url = referer
req = urllib2.Request(url, data)
page = urllib2.urlopen(req)
req = urllib2.Request("http://www.hackthissite.org/missions/prog/1/", data)
page2 = urllib2.urlopen(req)
print page.info()
print page.geturl()
print page2.info()
print page2.geturl()
print page2.read()
Thanks a bunch ahead of time. :D