#The code I have written Authentication, HTTP, Basic, Authentication, so far import urllib2 import base64 theurl = 'http://10.42.0.11/authentication/example2' request = urllib2.Request(theurl) try: handle = urllib2.urlopen(request) except IOError, e: if hasattr(e, 'code'): if e.code != 401: print 'Something is seriously wrong, you got a different error.' print e.code else: print e.headers print e.headers['www-authenticate'] #The credentials for login in are hacker:pentesterlab #Below you can see the base64 encoded version of the credentials request.add_header("Authorization", "Basic %s"%"aGFja2VyOnBlbnRlc3RlcmxhYgo=") print request.headers handle = urllib2.urlopen(request)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)