def test_get_NTLMv2_response(self):
        # 4.2.4.2.2 - NTLMv2 Response
        server_challenge = b"\x01\x23\x45\x67\x89\xab\xcd\xef"
        client_challenge = b"\xaa" * 8
        test_target_info = TargetInfo()
        test_target_info[AvId.MSV_AV_NB_DOMAIN_NAME] = \
            b"\x44\x00\x6f\x00\x6d\x00\x61\x00\x69\x00\x6e\x00"
        test_target_info[AvId.MSV_AV_NB_COMPUTER_NAME] = \
            b"\x53\x00\x65\x00\x72\x00\x76\x00\x65\x00\x72\x00"

        expected_response = b"\x68\xcd\x0a\xb8\x51\xe5\x1c\x96" \
                            b"\xaa\xbc\x92\x7b\xeb\xef\x6a\x1c" \
                            b"\x01\x01\x00\x00\x00\x00\x00\x00" \
                            b"\x00\x00\x00\x00\x00\x00\x00\x00" \
                            b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" \
                            b"\x00\x00\x00\x00\x02\x00\x0c\x00" \
                            b"\x44\x00\x6f\x00\x6d\x00\x61\x00" \
                            b"\x69\x00\x6e\x00\x01\x00\x0c\x00" \
                            b"\x53\x00\x65\x00\x72\x00\x76\x00" \
                            b"\x65\x00\x72\x00\x00\x00\x00\x00" \
                            b"\x00\x00\x00\x00"
        expected_key = b"\x8d\xe4\x0c\xca\xdb\xc1\x4a\x82" \
                       b"\xf1\x5c\xb0\xad\x0d\xe9\x5c\xa3"

        actual_response, actual_key = \
            ComputeResponse._get_NTLMv2_response("User", "Password", "Domain",
                                                 server_challenge,
                                                 client_challenge, b"\x00" * 8,
                                                 test_target_info)

        assert actual_response == expected_response
        assert actual_key == expected_key
Exemple #2
0
    def test_get_NTLMv2_response(self):
        test_target_info = target_info

        expected_response = ntlmv2_ntlmv2_response
        expected_key = ntlmv2_session_base_key

        actual_response, actual_key = ComputeResponse._get_NTLMv2_response(user_name, password, domain_name,
                                                       server_challenge, client_challenge, timestamp, test_target_info)

        assert actual_response == expected_response
        assert actual_key == expected_key
Exemple #3
0
def check_authenticate(msg_authenticate: AuthenticateMessage,
                       msg_challenge: ChallengeMessage) -> bool:

    if len(msg_authenticate.NtChallengeResponse) <= 24:
        raise 'Only NTLMv2 authentication supported'

    nt_challenge_response = NTLMv2Response.parse(
        msg_authenticate.NtChallengeResponse)

    nt_response, session_key = ComputeResponse._get_NTLMv2_response(
        decode_unicode(msg_authenticate.UserName), 'test',
        decode_unicode(msg_authenticate.DomainName),
        msg_challenge.ServerChallenge,
        nt_challenge_response.ChallengeFromClient,
        nt_challenge_response.TimeStamp, nt_challenge_response.TargetInfo)

    return msg_authenticate.NtChallengeResponse == nt_response