- Write a Python script to perform a dictionary attack on a Linux password file.
- Copy /etc/shadow file to your local directory. Study the format of this file.
- Add the following 3 lines to the /etc/shadow file. For speed purposes remove all other lines.
- Use the “crypt” library crypt function to create your hash.
- Use the “hmac” library compare_hash function to compare hashes from the /etc/shadow file to the hashes produced from your guesses.
- Use the string split() function to separate the separate the password lines from the shadow file by the ‘:’ delimiter to isolate the userid and the hash from an entry in the shadow file.
- Calculate the appropriate hash (using the method specified for the entry from the shadow file) for each word in this wordlist (http://www.openwall.com/passwords/wordlists/password-2011.lst (Links to an external site.)), compare the hash, and stop comparing when you find a match.
- Attempt the dictionary attack for each entry in the shadow file.
- Remember you need to provide the word from the dictionary, the method, and the salt to the crypt() function.
- Print the userid and password when a match is found:
“Match found for userid [userid]. Password = [password]”
- Print the “No match was found for [userid]” when there no match in the dictionary.
UPDATE: Your program should run with the following command line:
>> python3 dictionary.py [shadow filename] [dictionary filename]