本文整理汇总了Python中tlsfuzzer.runner.ConnectionState.msg_sock方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectionState.msg_sock方法的具体用法?Python ConnectionState.msg_sock怎么用?Python ConnectionState.msg_sock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tlsfuzzer.runner.ConnectionState
的用法示例。
在下文中一共展示了ConnectionState.msg_sock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_process_with_ssl2
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_process_with_ssl2(self):
exp = ExpectFinished((2, 0))
state = ConnectionState()
state.msg_sock = mock.MagicMock()
msg = ServerFinished().create(bytearray(range(12)))
exp.process(state, msg)
示例2: test_process
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_process(self):
state = ConnectionState()
state.msg_sock = mock.MagicMock()
close = Close()
close.process(state)
state.msg_sock.sock.close.called_once_with()
示例3: test_process_with_size
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_process_with_size(self):
node = SetMaxRecordSize(2048)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
node.process(state)
self.assertEqual(2048, state.msg_sock.recordSize)
示例4: test_generate_with_export_cipher
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_generate_with_export_cipher(self):
cmk = ClientMasterKeyGenerator(
cipher=constants.CipherSuite.SSL_CK_RC2_128_CBC_EXPORT40_WITH_MD5)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
state.get_server_public_key = mock.MagicMock()
ret = cmk.generate(state)
self.assertEqual(len(ret.clear_key), 11)
示例5: test_post_send
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_post_send(self):
ccsg = ChangeCipherSpecGenerator()
ccsg.generate(None)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
ccsg.post_send(state)
self.assertTrue(state.msg_sock.calcPendingStates.called)
self.assertTrue(state.msg_sock.changeWriteState.called)
示例6: test_process
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_process(self):
exp = ExpectChangeCipherSpec()
state = ConnectionState()
state.msg_sock = mock.MagicMock()
msg = Message(ContentType.change_cipher_spec, bytearray(1))
exp.process(state, msg)
state.msg_sock.changeReadState.assert_called_once_with()
示例7: test_generate_with_ssl2
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_generate_with_ssl2(self):
fg = FinishedGenerator((0, 2))
state = ConnectionState()
state.msg_sock = mock.MagicMock()
state.session_id = bytearray(b'abba')
ret = fg.generate(state)
self.assertEqual(ret.verify_data, bytearray(b'abba'))
state.msg_sock.changeWriteState.assert_called_once_with()
state.msg_sock.changeReadState.assert_called_once_with()
示例8: test_generate_with_des_cipher
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_generate_with_des_cipher(self):
cmk = ClientMasterKeyGenerator(
cipher=constants.CipherSuite.SSL_CK_DES_64_CBC_WITH_MD5)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
state.get_server_public_key = mock.MagicMock()
ret = cmk.generate(state)
self.assertEqual(ret.encrypted_key,
state.get_server_public_key().encrypt())
示例9: test_process
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_process(self):
exp = ExpectServerHello2()
state = ConnectionState()
state.msg_sock = mock.MagicMock()
msg = ServerHello2()
msg.session_id_hit = 1
msg.session_id = bytearray(b'\x12')
msg.certificate = X509().parse(srv_raw_certificate).writeBytes()
ret = exp.process(state, msg)
self.assertEqual(state.session_id, msg.session_id)
示例10: test_post_send_with_extended_master_secret
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_post_send_with_extended_master_secret(self):
ccsg = ChangeCipherSpecGenerator()
ccsg.generate(None)
state = ConnectionState()
state.extended_master_secret = True
state.msg_sock = mock.MagicMock()
with mock.patch('tlsfuzzer.messages.calcExtendedMasterSecret') as mthd:
mthd.return_value = bytearray(48)
ccsg.post_send(state)
mthd.assert_called_once_with(state.version, state.cipher,
state.premaster_secret,
state.handshake_hashes)
self.assertTrue(state.msg_sock.calcPendingStates.called)
self.assertTrue(state.msg_sock.changeWriteState.called)
示例11: test_generate
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_generate(self):
cmk = ClientMasterKeyGenerator(
cipher=constants.CipherSuite.SSL_CK_DES_192_EDE3_CBC_WITH_MD5)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
state.get_server_public_key = mock.MagicMock()
ret = cmk.generate(state)
self.assertEqual(ret.cipher,
constants.CipherSuite.SSL_CK_DES_192_EDE3_CBC_WITH_MD5)
self.assertEqual(ret.clear_key, bytearray(0))
self.assertEqual(ret.encrypted_key,
state.get_server_public_key().encrypt())
self.assertEqual(ret.key_argument,
state.msg_sock.calcSSL2PendingStates())
示例12: test_generate_with_session_key
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_generate_with_session_key(self):
cmk = ClientMasterKeyGenerator(
cipher=constants.CipherSuite.SSL_CK_DES_192_EDE3_CBC_WITH_MD5)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
state.get_server_public_key = mock.MagicMock()
state.master_secret = bytearray(range(32))
ret = cmk.generate(state)
state.msg_sock.calcSSL2PendingStates.assert_called_once_with(
constants.CipherSuite.SSL_CK_DES_192_EDE3_CBC_WITH_MD5,
bytearray(range(32)),
bytearray(0),
bytearray(0),
None)
示例13: test_process_with_incorrect_version
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_process_with_incorrect_version(self):
extension_process = mock.MagicMock()
exp = ExpectServerHello(version=(3, 3))
state = ConnectionState()
state.msg_sock = mock.MagicMock()
ext = RenegotiationInfoExtension().create()
msg = ServerHello().create(version=(3, 2),
random=bytearray(32),
session_id=bytearray(0),
cipher_suite=4)
self.assertTrue(exp.is_match(msg))
with self.assertRaises(AssertionError):
exp.process(state, msg)
示例14: test_process_with_mandatory_resumption_but_wrong_id
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_process_with_mandatory_resumption_but_wrong_id(self):
exp = ExpectServerHello(resume=True)
state = ConnectionState()
state.msg_sock = mock.MagicMock()
state.session_id = bytearray(b'\xaa\xaa\xaa')
state.cipher = 4
self.assertFalse(state.resuming)
msg = ServerHello()
msg.create(version=(3, 3),
random=bytearray(32),
session_id=bytearray(b'\xbb\xbb\xbb'),
cipher_suite=4)
self.assertTrue(exp.is_match(msg))
with self.assertRaises(AssertionError):
exp.process(state, msg)
示例15: test_process_with_unexpected_extensions
# 需要导入模块: from tlsfuzzer.runner import ConnectionState [as 别名]
# 或者: from tlsfuzzer.runner.ConnectionState import msg_sock [as 别名]
def test_process_with_unexpected_extensions(self):
exp = ExpectServerHello(extensions={ExtensionType.renegotiation_info:
None})
state = ConnectionState()
state.msg_sock = mock.MagicMock()
exts = []
exts.append(RenegotiationInfoExtension().create())
exts.append(SNIExtension().create())
msg = ServerHello().create(version=(3, 3),
random=bytearray(32),
session_id=bytearray(0),
cipher_suite=4,
extensions=exts)
self.assertTrue(exp.is_match(msg))
with self.assertRaises(AssertionError):
exp.process(state, msg)