def worker_thread(id, uid, file, lock): global threads puid = uid + 200 while uid < puid: try: url = "%s/_layouts/userdisp.aspx?ID=%d" % (gurl, uid) passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, user, password) auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) opener = urllib2.build_opener(auth_NTLM) urllib2.install_opener(opener) response = urllib2.urlopen(url) # bug, need to handle errors here html = response.read() output = html.split("Object moved to <a href=\"") username = output[1].split("&") if username[1].find("https://extranet"): url = username[0] lock.acquire() file.write("%d %s found: %s\n" % (uid, gurl, urllib2.unquote(url))) print "%d %s found: %s" % (uid, gurl, urllib2.unquote(url)) lock.release() passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, user, password) auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) opener = urllib2.build_opener(auth_NTLM) urllib2.install_opener(opener) response = urllib2.urlopen(url) html = response.read() if html.find("mailto:"): output = html.split("mailto:") email = output[1].split("\">") lock.acquire() file.write("%d %s email: %s\n" % (uid, gurl, urllib2.unquote(email[0]))) print "%d %s email: %s" % (uid, gurl, urllib2.unquote(email[0])) lock.release() uid += 1 except: if verbose == True: lock.acquire() print "[-] BAD UID %d" % uid lock.release() uid += 1 lock.acquire() threads -= 1 print "thread %d complete %d threads left" % (id, threads) lock.release()
def __init__(self, **kwargs): HttpTransport.__init__(self, **kwargs) self.pm = urllib2.HTTPPasswordMgrWithDefaultRealm() self.handler =\ HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(self.pm) self.urlopener = urllib2.build_opener(self.handler) urllib2.install_opener(self.urlopener)
def login(username, password): """ Attempts to login to Exeter servers. Returns True if successful, False otherwise. """ resp = requests.get('https://www.outlook.com/owa/exeter.edu') url = resp.url if 'integrated' in url: req = urllib2.Request(url) password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm() password_manager.add_password(None, url, username, password) auth_manager = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler( password_manager) opener = urllib2.build_opener(auth_manager) urllib2.install_opener(opener) handler = urllib2.urlopen(req) return handler.getcode() == 200 else: # This case still seems a bit buggy? parser = FormParser() parser.feed(resp.text) parser.close() payload = parser._dict payload['ctl00$ContentPlaceHolder1$UsernameTextBox'] = unicode( username) payload['ctl00$ContentPlaceHolder1$PasswordTextBox'] = unicode( password) post = requests.post(parser.url, data=payload) return 'Working' in post.text
def __init__(self, **kwargs): from ntlm import HTTPNtlmAuthHandler https.HttpAuthenticated.__init__(self, **kwargs) self.pm = urllib2.HTTPPasswordMgrWithDefaultRealm() self.handler = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(self.pm) self.urlopener = urllib2.build_opener(self.handler)
def hplan(hpcode, opt): opt = request.cookies.get('opt').encode('utf-8') hpcode = request.cookies.get('hpcode').encode('utf-8') url = "http://portal/regalnet/DMHealthOptions.cfm" try: return render_template('BF/' + hpcode + '_' + opt + '.html') except: pass_manager = mechanize.HTTPPasswordMgrWithDefaultRealm() pass_manager.add_password(None, url, user, password) auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(pass_manager) browser = mechanize.Browser(factory=mechanize.RobustFactory()) browser.set_handle_robots(False) browser.add_handler(auth_NTLM) r = browser.open(url) browser.select_form(name="HPlanLookup") browser["txtSearch"] = hpcode browser["txtOPT"] = opt res = browser.submit() soup = BeautifulSoup(res.read()) if 'Sorry, No records' in soup.findAll('p')[-1].text: return redirect(url) else: for th in soup.findAll('th'): th.replaceWith('') tbl = soup.findAll("table")[2] tbl['class'] = "highlight" return render_template('bnfts.html', tbl=tbl)
def process(password, url): user = '******' % (os.environ["USERDOMAIN"], os.environ["USERNAME"]) # determine a base_uri for which the username and password can be used parsed_url = urlparse(url) base_uri = urlunparse((parsed_url[0], parsed_url[1], "", "", "", "")) passman = urllib.request.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, base_uri, user, password) # create the NTLM authentication handler auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) # other authentication handlers auth_basic = urllib.request.HTTPBasicAuthHandler(passman) auth_digest = urllib.request.HTTPDigestAuthHandler(passman) # disable proxies (if you want to stay within the corporate network) proxy_handler = urllib.request.ProxyHandler({}) # create and install the opener ## # Using auth_digest results in: ## # ValueError: AbstractDigestAuthHandler does not support the following scheme: 'NTLM' ## # See http://bugs.python.org/issue21413 urllib.request.install_opener( urllib.request.build_opener( proxy_handler, auth_NTLM, ## auth_digest, auth_basic, )) # retrieve the result response = urllib.request.urlopen(url) print((response.read()))
def process(password, url): user = '******' % ( os.environ["USERDOMAIN"], os.environ["USERNAME"] ) # determine a base_uri for which the username and password can be used parsed_url = urlparse(url) base_uri = urlunparse((parsed_url[0],parsed_url[1],"","","","")) passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, base_uri, user, password) # create the NTLM authentication handler auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) # other authentication handlers auth_basic = urllib2.HTTPBasicAuthHandler(passman) auth_digest = urllib2.HTTPDigestAuthHandler(passman) # disable proxies (if you want to stay within the corporate network) proxy_handler = urllib2.ProxyHandler({}) # create and install the opener opener = urllib2.build_opener(proxy_handler, auth_NTLM, auth_digest, auth_basic) urllib2.install_opener(opener) # retrieve the result response = urllib2.urlopen(url) print(response.read())
def resetProxies(self, httpProxyTuple): # for ntlm user and password are required self.hasNTLM = False if isinstance(httpProxyTuple,(tuple,list)) and len(httpProxyTuple) == 5: useOsProxy, _urlAddr, _urlPort, user, password = httpProxyTuple _proxyDirFmt = proxyDirFmt(httpProxyTuple) # only try ntlm if user and password are provided because passman is needed if user and not useOsProxy: for pluginXbrlMethod in pluginClassMethods("Proxy.HTTPNtlmAuthHandler"): HTTPNtlmAuthHandler = pluginXbrlMethod() if HTTPNtlmAuthHandler is not None: self.hasNTLM = True if not self.hasNTLM: # try for python site-packages ntlm try: from ntlm import HTTPNtlmAuthHandler self.hasNTLM = True except ImportError: pass if self.hasNTLM: pwrdmgr = proxyhandlers.HTTPPasswordMgrWithDefaultRealm() pwrdmgr.add_password(None, _proxyDirFmt["http"], user, password) self.proxy_handler = proxyhandlers.ProxyHandler({}) self.proxy_auth_handler = proxyhandlers.ProxyBasicAuthHandler(pwrdmgr) self.http_auth_handler = proxyhandlers.HTTPBasicAuthHandler(pwrdmgr) self.ntlm_auth_handler = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(pwrdmgr) self.opener = proxyhandlers.build_opener(self.proxy_handler, self.ntlm_auth_handler, self.proxy_auth_handler, self.http_auth_handler) if not self.hasNTLM: self.proxy_handler = proxyhandlers.ProxyHandler(proxyDirFmt(httpProxyTuple)) self.proxy_auth_handler = proxyhandlers.ProxyBasicAuthHandler() self.http_auth_handler = proxyhandlers.HTTPBasicAuthHandler() self.opener = proxyhandlers.build_opener(self.proxy_handler, self.proxy_auth_handler, self.http_auth_handler)
def __init__(self, username="******", password="******"): self.username = "******" + username self.password = password self.password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm() ntlm_auth = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler( self.password_manager) opener = mechanize.build_opener(ntlm_auth) mechanize.install_opener(opener)
def u2handlers(self): try: from ntlm import HTTPNtlmAuthHandler except ImportError: raise Exception("Cannot import python-ntlm module") handlers = HttpTransport.u2handlers(self) handlers.append(HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(self.pm)) return handlers
def setSecurity (url, username, password): print 'test' passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, username, password) auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) opener = urllib2.build_opener(auth_NTLM) urllib2.install_opener(opener) print 'test2'
def __init__(self, uri, login=None, password=None): if login and password: passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, uri, login, password) auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) self.opener = urllib2.build_opener(auth_NTLM) else: self.opener = urllib2.build_opener()
def init(self): self.AUTH_MGR = urllib3.HTTPPasswordMgrWithDefaultRealm() self.AUTH_MGR.add_password(None, "https://%s/" % (self.hostname), r'%s\%s' % (self.domain, self.username), self.password) self.AUTH = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(self.AUTH_MGR) self._handler = urllib3.HTTPHandler(debuglevel=self.debug) self._opener = urllib3.build_opener(self.AUTH) urllib3.install_opener(self._opener)
def Login(self, url): passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, self.username, self.password) # create the NTLM authentication handler authNTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) # create and install the opener opener = urllib2.build_opener(authNTLM) urllib2.install_opener(opener) return opener
def u2handlers(self): # try to import ntlm support try: from ntlm import HTTPNtlmAuthHandler except ImportError: raise Exception("Cannot import python-ntlm module") handlers = HttpAuthenticated.u2handlers(self) handlers.append(HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(self.pm)) return handlers
def resetProxies(self, httpProxyTuple): # for ntlm user and password are required self.hasNTLM = False self._httpProxyTuple = httpProxyTuple # save for resetting in noCertificateCheck setter if isinstance(httpProxyTuple, (tuple, list)) and len(httpProxyTuple) == 5: useOsProxy, _urlAddr, _urlPort, user, password = httpProxyTuple _proxyDirFmt = proxyDirFmt(httpProxyTuple) # only try ntlm if user and password are provided because passman is needed if user and not useOsProxy: for pluginXbrlMethod in pluginClassMethods( "Proxy.HTTPAuthenticate"): pluginXbrlMethod(self.cntlr) for pluginXbrlMethod in pluginClassMethods( "Proxy.HTTPNtlmAuthHandler"): HTTPNtlmAuthHandler = pluginXbrlMethod() if HTTPNtlmAuthHandler is not None: self.hasNTLM = True if not self.hasNTLM: # try for python site-packages ntlm try: from ntlm import HTTPNtlmAuthHandler self.hasNTLM = True except ImportError: pass if self.hasNTLM: pwrdmgr = proxyhandlers.HTTPPasswordMgrWithDefaultRealm() pwrdmgr.add_password(None, _proxyDirFmt["http"], user, password) self.proxy_handler = proxyhandlers.ProxyHandler({}) self.proxy_auth_handler = proxyhandlers.ProxyBasicAuthHandler( pwrdmgr) self.http_auth_handler = proxyhandlers.HTTPBasicAuthHandler( pwrdmgr) self.ntlm_auth_handler = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler( pwrdmgr) proxyHandlers = [ self.proxy_handler, self.ntlm_auth_handler, self.proxy_auth_handler, self.http_auth_handler ] if not self.hasNTLM: self.proxy_handler = proxyhandlers.ProxyHandler( proxyDirFmt(httpProxyTuple)) self.proxy_auth_handler = proxyhandlers.ProxyBasicAuthHandler() self.http_auth_handler = proxyhandlers.HTTPBasicAuthHandler() proxyHandlers = [ self.proxy_handler, self.proxy_auth_handler, self.http_auth_handler ] if ssl and self.noCertificateCheck: # this is required in some Akamai environments, such as sec.gov context = ssl.create_default_context() context.check_hostname = False context.verify_mode = ssl.CERT_NONE proxyHandlers.append(proxyhandlers.HTTPSHandler(context=context)) self.opener = proxyhandlers.build_opener(*proxyHandlers) self.opener.addheaders = [('User-Agent', self.httpUserAgent), ('Accept-Encoding', 'gzip, deflate')]
def main(): usage = """ Usage: zbxjson -u <url> -p <path> [-U <username>] [-P <password>] [-m <GET|POST>] [-d <data>] [-a <basic|ntlm>] Options: -u, --url <url> The URL to the web service endpoint -p, --path <path> The path to the JSON element to get. Expects /element1, /array1 or /array1/2/element3... -U, --username <username> The username if authentication is required -P, --password <password> The password if authentication is required -m, --method <GET|POST> The HTTP method to use (GET|POST). [default: get] -d, --data <data> The POST data to send, if required. Expects --data "key1=value1,key2=value2,..." -a, --authentication <basic|ntlm> The authentication method to use (basic, ntml) [default: ntlm] """ args = docopt(usage, version="0.1") # Set authentication if required if args["--authentication"]: authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm() authinfo.add_password(None, args["--url"], args["--username"], args["--password"]) if args["--authentication"] == "basic": auth = urllib2.HTTPBasicAuthHandler(authinfo) elif args["--authentication"] == "ntlm": auth = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(authinfo) opener = urllib2.build_opener(auth) urllib2.install_opener(opener) # Handle POST data if args["--data"]: data = urllib.urlencode( dict([arg.split('=') for arg in args["--data"].split(',')])) else: data = "None" # Create HTTP request req = urllib2.Request(args["--url"], data=data) req.add_header('User-Agent', 'Zabbix Monitoring') req.add_header('Content-Type', 'application/json') # Handle the HTTP method if args["--method"]: method = args["--method"] req.get_method = lambda: method try: connection = opener.open(req) except urllib2.HTTPError, e: print e sys.exit(1)
def build_handler(self): if self.handler: return self.handler log.debug(u'Constructing handler') self.password_manager = self.build_password_manager() self.handler = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler( self.password_manager) return self.handler
def ntlm_opener(url, email, password): """ Returns a urllib2.OpenDirector for the given url, that requires NTLM authentication. """ # the ntlm library requires Domain\user format user = get_domain_uname(email) pass_mangr = urllib2.HTTPPasswordMgrWithDefaultRealm() pass_mangr.add_password(None, url, user, password) auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(pass_mangr) return urllib2.build_opener(auth_NTLM)
def GET(self): passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, self.url, self.user, self.password) # create the NTLM authentication handler auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) # create and install the opener opener = urllib2.build_opener(auth_NTLM) urllib2.install_opener(opener) # retrieve the result response = urllib2.urlopen(self.url) return response
def __init__(self, username, password, ags_admin_url, tool=None, basic=False, allowunverifiedssl=False): """Class initialization procedure Args: self: The reserved object 'self' username: ArcGIS Server administrator username password: ArcGIS Server administrator password ags_admin_url: ArcGIS server rest admin url Tool: GISPython tool (optional) basic: bool indicating that Basic autentification will be used instead of NTLM """ self.username = username self.password = password self.ags_admin_url = ags_admin_url self.serverurl = ags_admin_url if self.ags_admin_url.endswith("/"): self.ags_admin_url = self.ags_admin_url[:-1] self.Tool = tool self.ags_admin_url = self.ags_admin_url + '/arcgis/admin' if allowunverifiedssl: try: _create_unverified_https_context = ssl._create_unverified_context except AttributeError: # Legacy Python that doesn't verify HTTPS certificates by default pass else: # Handle target environment that doesn't support HTTPS verification ssl._create_default_https_context = _create_unverified_https_context passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, self.ags_admin_url, self.username, self.password) if basic == False: # create the NTLM authentication handler AuthHandler = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) else: # create the NTLM authentication handler AuthHandler = urllib2.HTTPBasicAuthHandler(passman) # create and install the opener opener = urllib2.build_opener(AuthHandler) urllib2.install_opener(opener)
def POST(self): passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, self.url, self.user, self.password) # create the NTLM authentication handler auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) # create and install the opener opener = urllib2.build_opener(auth_NTLM) req = urllib2.Request(self.url, urlsplit(self.url).query) req.add_header('Content-Type', 'text/json') req.get_method = lambda: 'POST' res = opener.open(req) return res
def login(url, username, password): parsed_url = urlparse(url) base_uri = urlunparse((parsed_url[0], parsed_url[1], "", "", "", "")) passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, base_uri, username, password) auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) auth_basic = urllib2.HTTPBasicAuthHandler(passman) auth_digest = urllib2.HTTPDigestAuthHandler(passman) proxy_handler = urllib2.ProxyHandler({}) opener = urllib2.build_opener(proxy_handler, auth_NTLM, auth_digest, auth_basic) urllib2.install_opener(opener) response = urllib2.urlopen(url) return response.read()
def enable_ntlm_authentication(user="", password="", url=""): print "[+][devalias.net] Enabling NTLM authentication support" # Import ntlm library try: # import ntlm from ntlm import HTTPNtlmAuthHandler print "[+][devalias.net][NTLM Authentication] NTLM Support Library Loaded!" except ImportError: print "[-][devalias.net][NTLM Authentication] Program could not find module : ntlm (Is the ntlm library installed/available locally?" sys.exit(1) try: from urlparse import urlparse, urlunparse except ImportError: print "[-][devalias.net][NTLM Authentication] Program could not find module : urlparse" sys.exit(1) if user == "": user = raw_input( "[+][devalias.net][NTLM Authentication] Enter username (DOMAIN\username): " ) if password == "": password = raw_input( "[+][devalias.net][NTLM Authentication] Enter password: "******"", "", "", "")) passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, base_uri, user, password) # create the NTLM authentication handler auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) # other authentication handlers auth_basic = urllib2.HTTPBasicAuthHandler(passman) auth_digest = urllib2.HTTPDigestAuthHandler(passman) # disable proxies (if you want to stay within the corporate network) # proxy_handler = urllib2.ProxyHandler({}) proxy_handler = urllib2.ProxyHandler() # create and install the opener opener = urllib2.build_opener(proxy_handler, auth_NTLM, auth_digest, auth_basic) urllib2.install_opener(opener) print "[+][devalias.net][NTLM authentication] Credentials enabled for " + user
def createNTLMRequest(self, user, pwd, url, domain): """ Create the NTLM authentication handler for Windows authentication. """ from ntlm import HTTPNtlmAuthHandler passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, domain + '\\' + user, pwd) # NTLM handler auth_ntlm = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) # Install opener opener = urllib2.build_opener(auth_ntlm) urllib2.install_opener(opener) rsp = urllib2.urlopen(url) if rsp.code == 200: return rsp else: raise antaresWrongCredentialsException(str(rsp.headers))
def urlopen(self, path, body=None, headers={}): url = "http://%s:%s%s" % (self.host, self.port, path) if self.basic_auth: headers['Authorization'] = 'Basic ' + base64.encodestring( '%s:%s' % (self.user, self.password)).strip() else: # create and install NTLM authentication handler + opener passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, self.user, self.password) auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) opener = urllib2.build_opener(auth_NTLM) urllib2.install_opener(opener) req = urllib2.Request(url, data=body, headers=headers) return urllib2.urlopen(req)
def get(self): usr = self.request.get('usr') password = self.request.get('pw') print usr + ' - ' + password url = "http://www.dogus.edu.tr/dusor/" user = '******' + usr passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, user, password) auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) br = mechanize.Browser() br.handlers = [ handler for handler in br.handlers if not isinstance(handler, (mechanize._http.HTTPRobotRulesProcessor)) ] br.add_handler(auth_NTLM) try: br.addheaders = [ ('Cookie', br.open(url).info().dict['set-cookie'].split(';')[0]) ] except KeyError: self.response.write('Hatali Sifre veya kullanici adi.') return response = br.open(url + 'FrmMain.aspx') response = br.open(url + 'FrmNot.aspx') rows = [ row.contents for row in BeautifulSoup(response.read()).find_all( 'table', id='dgnot')[-1].find_all('tr', align='left') ] dersler = [[i.string.strip() for i in row] for row in rows] if self.request.get('json') == 'true': resp = json.dumps([ders[1:] for ders in dersler]) else: resp = '\n<br><br>\n'.join([' - '.join(ders) for ders in dersler]) self.response.write(resp)
def reqPortalUrl(param): user = '******' password = "******" url = "http://portal/C12/Menu/Lists/List/EditForm.aspx?ID="+param print url passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, user, password) # create the NTLM authentication handler auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) # create and install the opener opener = urllib2.build_opener(auth_NTLM) urllib2.install_opener(opener) req = urllib2.Request(url) htmlbody = '' try: response = urllib2.urlopen(req) except HTTPError, e: print 'Error code:', e.code
def main(): assert len( sys.argv ) == 3, "Usage %s <password> <url>" % sys.argv[0] user = '******' % ( os.environ["USERDOMAIN"], os.environ["USERNAME"] ) password = sys.argv[1] url = sys.argv[2] passman = urllib2.HTTPPasswordMgrWithDefaultRealm() passman.add_password(None, url, user, password) # create the NTLM authentication handler auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman) # create and install the opener opener = urllib2.build_opener(auth_NTLM) urllib2.install_opener(opener) # retrieve the result response = urllib2.urlopen(url) print(response.read())
def resetProxies(self, httpProxyTuple): try: from ntlm import HTTPNtlmAuthHandler self.hasNTLM = True except ImportError: self.hasNTLM = False self.proxy_handler = proxyhandlers.ProxyHandler( proxyDirFmt(httpProxyTuple)) self.proxy_auth_handler = proxyhandlers.ProxyBasicAuthHandler() self.http_auth_handler = proxyhandlers.HTTPBasicAuthHandler() if self.hasNTLM: self.ntlm_auth_handler = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler() self.opener = proxyhandlers.build_opener(self.proxy_handler, self.ntlm_auth_handler, self.proxy_auth_handler, self.http_auth_handler) else: self.opener = proxyhandlers.build_opener(self.proxy_handler, self.proxy_auth_handler, self.http_auth_handler)