当前位置: 首页>>代码示例>>Python>>正文


Python imaplib.CRLF属性代码示例

本文整理汇总了Python中imaplib.CRLF属性的典型用法代码示例。如果您正苦于以下问题:Python imaplib.CRLF属性的具体用法?Python imaplib.CRLF怎么用?Python imaplib.CRLF使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在imaplib的用法示例。


在下文中一共展示了imaplib.CRLF属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sendNegotiate

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def sendNegotiate(self,negotiateMessage):
        #Negotiate auth
        negotiate = base64.b64encode(negotiateMessage)
        self.session.send('%s AUTHENTICATE NTLM%s' % (self.authtag,imaplib.CRLF))
        resp = self.session.readline().strip()
        if resp != '+':
            logging.error('IMAP Client error, expected continuation (+), got %s ' % resp)
            return False
        else:
            self.session.send(negotiate + imaplib.CRLF)
        try:
            serverChallengeBase64 = self.session.readline().strip()[2:] #first two chars are the continuation and space char
            serverChallenge = base64.b64decode(serverChallengeBase64)
            return serverChallenge
        except (IndexError, KeyError, AttributeError):
            logging.error('No NTLM challenge returned from IMAP server') 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:18,代码来源:imaprelayclient.py

示例2: sieve

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def sieve(con, criteria, script):
    script = script.strip().encode()
    criteria = criteria.encode()
    with _cmd(con, 'FILTER') as (tag, start, complete):
        args = ' SIEVE SCRIPT {%s}' % len(script)
        start(args.encode() + CRLF)
        con.send(script)
        con.send(criteria + CRLF)
        typ, data = complete()
        log.debug('%s; %s', typ, data[0].decode())
        err = con.untagged_responses.pop('FILTER', None)
        if err:
            err = err[0][1]
            raise Error(err)
        if typ != 'OK':
            raise Error(typ, data)
        filtered = con.untagged_responses.pop('FILTERED', [])
        return filtered 
开发者ID:naspeh,项目名称:mailur,代码行数:20,代码来源:imap.py

示例3: _multiappend

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def _multiappend(con, box, msgs):
    with _cmd(con, 'APPEND') as (tag, start, complete):
        send = start
        for date_time, flags, msg in msgs:
            flags = clean_recent(flags)
            if date_time is None:
                date_time = Time2Internaldate(time.time())
            args = (' (%s) %s %s' % (flags, date_time, '{%s}' % len(msg)))
            if send == start:
                args = ' %s %s' % (box, args)
            send(args.encode() + CRLF)
            send = con.send
            while con._get_response():
                bad = con.tagged_commands[tag]
                if bad:
                    raise Error(bad)
            con.send(msg)
        con.send(CRLF)
        res = check(complete())
        log.debug('%s', res[0].decode())
        uids = con.untagged_responses.pop('APPENDUID')
        uids = uids[0].decode().split(' ', 1)[-1]
        return uids 
开发者ID:naspeh,项目名称:mailur,代码行数:25,代码来源:imap.py

示例4: sendNegotiate

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def sendNegotiate(self,negotiateMessage):
        negotiate = base64.b64encode(negotiateMessage)
        self.session.send('%s AUTHENTICATE NTLM%s' % (self.authTag,imaplib.CRLF))
        resp = self.session.readline().strip()
        if resp != '+':
            LOG.error('IMAP Client error, expected continuation (+), got %s ' % resp)
            return False
        else:
            self.session.send(negotiate + imaplib.CRLF)
        try:
            serverChallengeBase64 = self.session.readline().strip()[2:] #first two chars are the continuation and space char
            serverChallenge = base64.b64decode(serverChallengeBase64)
            challenge = NTLMAuthChallenge()
            challenge.fromString(serverChallenge)
            return challenge
        except (IndexError, KeyError, AttributeError):
            LOG.error('No NTLM challenge returned from IMAP server')
            raise 
开发者ID:Ridter,项目名称:Exchange2domain,代码行数:20,代码来源:imaprelayclient.py

示例5: sendAuth

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def sendAuth(self,authenticateMessageBlob, serverChallenge=None):
        #Send auth
        auth = base64.b64encode(authenticateMessageBlob)
        self.session.send(auth + imaplib.CRLF)
        typ, data = self.session._get_tagged_response(self.authtag)
        if typ == 'OK':
            self.session.state = 'AUTH'
            return True
        else:
            logging.info('Auth failed - IMAP server said: %s' % ' '.join(data))
            return False

    #SMB Relay server needs this 
开发者ID:joxeankoret,项目名称:CVE-2017-7494,代码行数:15,代码来源:imaprelayclient.py

示例6: setmetadata

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def setmetadata(con, box, key, value):
    key = _mdkey(key)
    with _cmd(con, 'SETMETADATA') as (tag, start, complete):
        args = ' %s (%s %s)' % (box, key, json.dumps(value))
        start(args.encode() + CRLF)
        typ, data = complete()
        return check(con._untagged_response(typ, data, 'METADATA')) 
开发者ID:naspeh,项目名称:mailur,代码行数:9,代码来源:imap.py

示例7: getmetadata

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def getmetadata(con, box, key):
    key = _mdkey(key)
    with _cmd(con, 'GETMETADATA') as (tag, start, complete):
        args = ' %s (%s)' % (box, key)
        start(args.encode() + CRLF)
        typ, data = complete()
        return check(con._untagged_response(typ, data, 'METADATA')) 
开发者ID:naspeh,项目名称:mailur,代码行数:9,代码来源:imap.py

示例8: idle

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def idle(con, handlers, timeout=None):
    def match():
        for code, handler in handlers.items():
            typ, dat = con._untagged_response('OK', [None], code)
            if not dat[-1]:
                continue
            handler(dat)

    def inner(tag):
        with Timeout(timeout):
            res = con._get_response()
        if res:
            log.debug('received: %r', res.decode())
        bad = con.tagged_commands[tag]
        if bad:
            raise Error(bad)
        match()

    match()
    log.info('start idling %s...' % con)
    with _cmd(con, 'IDLE') as (tag, start, complete):
        clean_pool()
        start(CRLF)
        while 1:
            try:
                inner(tag)
            except Timeout:
                log.debug('timeout reached: %ss', timeout)
                return 
开发者ID:naspeh,项目名称:mailur,代码行数:31,代码来源:imap.py

示例9: sendAuth

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def sendAuth(self, authenticateMessageBlob, serverChallenge=None):
        if unpack('B', str(authenticateMessageBlob)[:1])[0] == SPNEGO_NegTokenResp.SPNEGO_NEG_TOKEN_RESP:
            respToken2 = SPNEGO_NegTokenResp(authenticateMessageBlob)
            token = respToken2['ResponseToken']
        else:
            token = authenticateMessageBlob
        auth = base64.b64encode(token)
        self.session.send(auth + imaplib.CRLF)
        typ, data = self.session._get_tagged_response(self.authTag)
        if typ == 'OK':
            self.session.state = 'AUTH'
            return None, STATUS_SUCCESS
        else:
            LOG.error('IMAP: %s' % ' '.join(data))
            return None, STATUS_ACCESS_DENIED 
开发者ID:Ridter,项目名称:Exchange2domain,代码行数:17,代码来源:imaprelayclient.py

示例10: sendAuth

# 需要导入模块: import imaplib [as 别名]
# 或者: from imaplib import CRLF [as 别名]
def sendAuth(self, authenticateMessageBlob, serverChallenge=None):
        if unpack('B', authenticateMessageBlob[:1])[0] == SPNEGO_NegTokenResp.SPNEGO_NEG_TOKEN_RESP:
            respToken2 = SPNEGO_NegTokenResp(authenticateMessageBlob)
            token = respToken2['ResponseToken']
        else:
            token = authenticateMessageBlob
        auth = base64.b64encode(token)
        self.session.send(auth + imaplib.CRLF)
        typ, data = self.session._get_tagged_response(self.authTag)
        if typ == 'OK':
            self.session.state = 'AUTH'
            return None, STATUS_SUCCESS
        else:
            LOG.error('IMAP: %s' % ' '.join(data))
            return None, STATUS_ACCESS_DENIED 
开发者ID:Coalfire-Research,项目名称:Slackor,代码行数:17,代码来源:imaprelayclient.py


注:本文中的imaplib.CRLF属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。