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


Python Parser.get方法代码示例

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


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

示例1: test_get_with_too_few_bytes_left

# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
    def test_get_with_too_few_bytes_left(self):
        p = Parser(bytearray(b'\x02\x01'))

        p.get(1)

        with self.assertRaises(SyntaxError):
            p.get(2)
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:9,代码来源:test_tlslite_utils_codec.py

示例2: filter

# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
def filter(packetNo, data, source, target):
    bytes = stringToBytes(data)
    if packetNo == 0 and 'Client2Server' in str(source):
        p = Parser(bytes[5:])
        p.get(1)
        clientHello = ClientHello()
        clientHello.parse(p)
        print bcolors.OKGREEN + "Client supports TLS version: %s" % \
            str(clientHello.client_version)
        print "Client supports ciphersuites: %s" % \
            str([CIPHER_MAP.get(i,i) for i in clientHello.cipher_suites]) \
            + bcolors.ENDC
    elif packetNo == 0 and 'Client2Server' not in str(source):
        p = Parser(bytes[5:])
        p.get(1)
        serverHello = ServerHello()
        serverHello.parse(p)
        print bcolors.OKGREEN + "Server selected TLS version: %s" % \
            str(serverHello.server_version)
        print "Server selected ciphersuite: %s" % \
            str(CIPHER_MAP.get(serverHello.cipher_suite,
                               serverHello.cipher_suite)) + bcolors.ENDC

    target.write(data)        
    return data
开发者ID:adacapo21,项目名称:TwistedEve,代码行数:27,代码来源:tlsinfo.py

示例3: test_getRemainingLength

# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
    def test_getRemainingLength(self):
        p = Parser(bytearray(b"\x00\x01\x05"))

        self.assertEqual(1, p.get(2))
        self.assertEqual(1, p.getRemainingLength())
        self.assertEqual(5, p.get(1))
        self.assertEqual(0, p.getRemainingLength())
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:9,代码来源:test_tlslite_utils_codec.py

示例4: test_atLengthCheck

# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
    def test_atLengthCheck(self):
        p = Parser(bytearray(b"\x00\x06" + b"\x05" + b"\x01\xff" + b"\x07" + b"\x01\xf0"))

        p.startLengthCheck(2)
        while not p.atLengthCheck():
            p.get(1)
            p.getVarBytes(1)
        p.stopLengthCheck()
开发者ID:zeroleo12345,项目名称:tlslite,代码行数:10,代码来源:test_tlslite_utils_codec.py

示例5: process

# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
    def process(self, state, msg):
        """Analyse the error message"""
        assert msg.contentType == ContentType.handshake

        parser = Parser(msg.write())
        hs_type = parser.get(1)
        assert hs_type == SSL2HandshakeType.error

        if self.error is not None:
            assert self.error == parser.get(2)
开发者ID:akokare,项目名称:tlsfuzzer,代码行数:12,代码来源:expect.py

示例6: test_atLengthCheck

# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
    def test_atLengthCheck(self):
        p = Parser(bytearray(
            b'\x00\x06' +
            b'\x05' +
            b'\x01\xff' +
            b'\x07' +
            b'\x01\xf0'
            ))

        p.startLengthCheck(2)
        while not p.atLengthCheck():
            p.get(1)
            p.getVarBytes(1)
        p.stopLengthCheck()
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:16,代码来源:test_tlslite_utils_codec.py

示例7: process

# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
    def process(self, state, msg):
        """
        @type state: ConnectionState
        @type msg: Message
        """
        assert msg.contentType == ContentType.handshake
        parser = Parser(msg.write())
        hs_type = parser.get(1)
        assert hs_type == HandshakeType.finished
        if self.version is None:
            self.version = state.version

        finished = Finished(self.version)
        finished.parse(parser)

        verify_expected = calcFinished(state.version,
                                       state.master_secret,
                                       state.cipher,
                                       state.handshake_hashes,
                                       not state.client)

        assert finished.verify_data == verify_expected

        state.handshake_messages.append(finished)
        state.server_verify_data = finished.verify_data
        state.handshake_hashes.update(msg.write())
开发者ID:ZESecurity,项目名称:tlsfuzzer,代码行数:28,代码来源:expect.py

示例8: process

# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
    def process(self, state, msg):
        """
        @type state: ConnectionState
        """
        assert msg.contentType == ContentType.handshake

        parser = Parser(msg.write())
        hs_type = parser.get(1)
        assert hs_type == HandshakeType.certificate

        cert = Certificate(self.cert_type)
        cert.parse(parser)

        state.handshake_messages.append(cert)
        state.handshake_hashes.update(msg.write())
开发者ID:NetPainter,项目名称:tlsfuzzer,代码行数:17,代码来源:expect.py

示例9: test_get

# 需要导入模块: from tlslite.utils.codec import Parser [as 别名]
# 或者: from tlslite.utils.codec.Parser import get [as 别名]
    def test_get(self):
        p = Parser(bytearray(b'\x02\x01\x00'))

        self.assertEqual(2, p.get(1))
        self.assertEqual(256, p.get(2))
        self.assertEqual(3, p.index)
开发者ID:tomato42,项目名称:tlslite-ng,代码行数:8,代码来源:test_tlslite_utils_codec.py


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