Server IP : 85.214.239.14 / Your IP : 18.188.212.54 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/root/proc/2/root/proc/2/cwd/srv/modoboa/env/lib64/python3.5/site-packages/sievelib/ |
Upload File : |
# coding: utf-8 """ Simple Digest-MD5 implementation (client side) Implementation based on RFC 2831 (http://www.ietf.org/rfc/rfc2831.txt) """ import base64 import hashlib import binascii import re import random class DigestMD5(object): def __init__(self, challenge, digesturi): self.__digesturi = digesturi self.__challenge = challenge self.__params = {} pexpr = re.compile(r'(\w+)="(.+)"') for elt in base64.b64decode(challenge).split(","): m = pexpr.match(elt) if m is None: continue self.__params[m.group(1)] = m.group(2) def __make_cnonce(self): ret = "" for i in xrange(12): ret += chr(random.randint(0, 0xff)) return base64.b64encode(ret) def __digest(self, value): return hashlib.md5(value).digest() def __hexdigest(self, value): return binascii.hexlify(hashlib.md5(value).digest()) def __make_response(self, username, password, check=False): a1 = "%s:%s:%s" % ( self.__digest("%s:%s:%s" % (username, self.realm, password)), self.__params["nonce"], self.cnonce ) if check: a2 = ":%s" % self.__digesturi else: a2 = "AUTHENTICATE:%s" % self.__digesturi resp = "%s:%s:00000001:%s:auth:%s" \ % (self.__hexdigest(a1), self.__params["nonce"], self.cnonce, self.__hexdigest(a2)) return self.__hexdigest(resp) def response(self, username, password, authz_id=''): self.realm = self.__params["realm"] \ if self.__params.has_key("realm") else "" self.cnonce = self.__make_cnonce() respvalue = self.__make_response(username, password) dgres = 'username="%s",%snonce="%s",cnonce="%s",nc=00000001,qop=auth,' \ 'digest-uri="%s",response=%s' \ % (username, ('realm="%s",' % self.realm) if len(self.realm) else "", self.__params["nonce"], self.cnonce, self.__digesturi, respvalue) if authz_id: if type(authz_id) is unicode: authz_id = authz_id.encode("utf-8") dgres += ',authzid="%s"' % authz_id return base64.b64encode(dgres) def check_last_challenge(self, username, password, value): challenge = base64.b64decode(value.strip('"')) return challenge == \ ("rspauth=%s" % self.__make_response(username, password, True))