Beispiel #1
0
    def test_create_message_one_dialect(self):
        message = SMB3NegotiateRequest()
        message['security_mode'] = SecurityMode.SMB2_NEGOTIATE_SIGNING_ENABLED
        message['capabilities'] = 10
        message['client_guid'] = uuid.UUID(bytes=b"\x33" * 16)
        message['dialects'] = [Dialects.SMB_3_1_1]
        con_req = SMB2NegotiateContextRequest()
        con_req['context_type'] = \
            NegotiateContextType.SMB2_ENCRYPTION_CAPABILITIES

        enc_cap = SMB2EncryptionCapabilities()
        enc_cap['ciphers'] = [Ciphers.AES_128_GCM]
        con_req['data'] = enc_cap
        message['negotiate_context_list'] = [con_req]
        expected = b"\x24\x00" \
                   b"\x01\x00" \
                   b"\x01\x00" \
                   b"\x00\x00" \
                   b"\x0a\x00\x00\x00" \
                   b"\x33\x33\x33\x33\x33\x33\x33\x33" \
                   b"\x33\x33\x33\x33\x33\x33\x33\x33" \
                   b"\x68\x00\x00\x00" \
                   b"\x01\x00" \
                   b"\x00\x00" \
                   b"\x11\x03" \
                   b"\x00\x00" \
                   b"\x02\x00\x04\x00\x00\x00\x00\x00" \
                   b"\x01\x00\x02\x00" \
                   b"\x00\x00\x00\x00"
        actual = message.pack()
        assert len(message) == 56
        assert actual == expected
Beispiel #2
0
 def test_create_message(self):
     message = SMB2EncryptionCapabilities()
     message['ciphers'] = [Ciphers.AES_128_CCM, Ciphers.AES_128_GCM]
     expected = b"\x02\x00" \
                b"\x01\x00" \
                b"\x02\x00"
     actual = message.pack()
     assert len(message) == 6
     assert actual == expected
Beispiel #3
0
 def test_parse_message(self):
     actual = SMB2EncryptionCapabilities()
     data = b"\x02\x00" \
            b"\x01\x00" \
            b"\x02\x00"
     actual.unpack(data)
     assert len(actual) == 6
     assert actual['cipher_count'].get_value() == 2
     assert actual['ciphers'].get_value() == [
         Ciphers.AES_128_CCM, Ciphers.AES_128_GCM
     ]
Beispiel #4
0
    def test_create_message(self):
        message = SMB2NegotiateContextRequest()
        message['context_type'] = \
            NegotiateContextType.SMB2_ENCRYPTION_CAPABILITIES

        enc_cap = SMB2EncryptionCapabilities()
        enc_cap['ciphers'] = [Ciphers.AES_128_GCM]
        message['data'] = enc_cap
        expected = b"\x02\x00" \
                   b"\x04\x00" \
                   b"\x00\x00\x00\x00" \
                   b"\x01\x00" \
                   b"\x02\x00" \
                   b"\x00\x00\x00\x00"
        actual = message.pack()
        assert len(message) == 16
        assert actual == expected