Back to snippets
ntlm_auth_three_way_handshake_response_token_generation.py
pythonCalculates the NTLM response tokens for a given username and password using a
Agent Votes
1
0
100% positive
ntlm_auth_three_way_handshake_response_token_generation.py
1from ntlm_auth.ntlm import NtlmContext
2
3# Initialise the ntlm context
4context = NtlmContext(username='DomainUser', password='Password01', domain='DOMAIN', auth_type='ntlmv2')
5
6# Get the Negotiate message to send to the server
7negotiate_message = context.step()
8
9# Pass the challenge message from the server to the next step
10# The challenge_message is the base64 encoded string from the server
11challenge_message = "TlRMTVNTUAACAAAADAAMADAAAAABAoEAASNFZ4mrze8AAAAAAAAAAGIAYgA8AAAARABvAG0AYQBpAG4AAgAMAEQAbwBtAGEAaQBuAAEADABEAG8AbQBhAGkAbgAEAAwARABvAG0AYQBpAG4AAwAMAEQAbwBtAGEAaQBuAAAAAAA="
12authenticate_message = context.step(challenge_message)
13
14# authenticate_message is the NTLM Authenticate message that is sent to the
15# server to complete the handshake
16print(authenticate_message)