Rainbow Table

Windows stores passwords using the NT LAN Manager (NTLM) hash.  This hash is created by hashing the plain text password with the MD4 algorithm.  There is no salt used.  The lack of salt enables the use of a rainbow table to lookup passwords from their hash.   For this assignment you will create a rainbow table for a set of passwords. 

More about NTLM: http://techgenix.com/how-cracked-windows-password-part1/

For this assignment you will create a Rainbow table for NTLM passwords.   Use the following list of steps as a guide.

  1. Use the sys library to read a command line argument that is the name of a password dictionary file.
    For your submission used the password dictionary file found at this link:
  2. Open the password dictionary. 
  3. Loop through the contents of the password dictionary one password at a time.
    • Strip any leading and trailing whitespace characters.
    • encode the word as ‘utf_16_le’ ()
    • Use the Python library hashlib to hash the password with the md4 algorithm.
      • import hashlib
      • hashlib.new() to select an algorithm
      • use update() to create the hash
      • use hexdigest() to refer to the hash
    • Store the password in a Python dictionary with the hash as the key. ()
  4. Sort the list of keys from your dictionary
  5. Use a for loop to print all keys and passwords. Print on hash and password pair per line. Structure each line as follows to allow a password to be looked up easily from it’s hash:
    [hash]:[password]
  6. Store the output of your program as rainbow_table.txt. 
    *** Run your program as ‘python3 rainbowtable.py dictionary.txt > rainbow_table.txt’
  7. Name your script rainbowtable.py