Reputation: 2547
How can I calculate NTLM hash of a passowrd in python? Is there any library or sample code?
I want it for writing a NTLM brute force tools with python (Like Cain & Abel )
Upvotes: 11
Views: 18448
Reputation: 55
I had similar problem with Python version 3.12.5, here is the solution:
from passlib.hash import nthash
def hashing_NTLM(provided_password):
return nthash.hash(provided_password)
# Example usage:
password = "insert your password here"
hashed_password = hashing_NTLM(password)
print(f"Hash: {hashed_password}")
Remember to have passlib installed:
pip install passlib
Upvotes: 1
Reputation: 49503
You can make use of the hashlib and binascii modules to compute your NTLM hash:
import binascii, hashlib
input_str = "SOMETHING_AS_INPUT_TO_HASH"
ntlm_hash = binascii.hexlify(hashlib.new('md4', input_str.encode('utf-16le')).digest())
print ntlm_hash
Upvotes: 6
Reputation:
It is actually very quite simple use hashlib
here
import hashlib,binascii
hash = hashlib.new('md4', "password".encode('utf-16le')).digest()
print binascii.hexlify(hash)
Or you can additionally use the python-ntlm
library here
Upvotes: 14