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.
- 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: http://www.openwall.com/passwords/wordlists/password-2011.lst (Links to an external site.)
- Open the password dictionary.
- 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’ (https://docs.python.org/3/library/stdtypes.html#str.encode (Links to an external site.))
- 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. (https://docs.python.org/3/tutorial/datastructures.html#dictionaries (Links to an external site.))
- Sort the list of keys from your dictionary
- 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:
- Store the output of your program as rainbow_table.txt.
*** Run your program as ‘python3 rainbowtable.py dictionary.txt > rainbow_table.txt’
- Name your script rainbowtable.py