How to calculate NTLM hash in python?

12,793

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
Share:
12,793
SuB
Author by

SuB

Linux Network Application Developer

Updated on June 30, 2022

Comments

  • SuB
    SuB almost 2 years

    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 )

  • CppLearner
    CppLearner over 11 years
    why not this? pythonhosted.org/passlib/lib/passlib.hash.nthash.html not familiar with NTLM hash at already.
  • Tuxdude
    Tuxdude over 11 years
    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.
  • CppLearner
    CppLearner over 11 years
    Thanks. interesting how OP checked the other guy. He just copy and paste from an online source code and you being the first one didn't get checked.