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 )
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 )
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
passlib
is a separate python package, but binascii
and hashlib
are part of the standard python library. Not saying you should not use passlib
, it is upto the author's preference. There are other libraries as well like python-ntlm
. –
Discommodity 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
© 2022 - 2024 — McMap. All rights reserved.
import hashlib print(hashlib.new('md4', "password".encode('utf-16le')).hexdigest())
– Rhpositive