import crypt
import os
import shutil
'''curDir = os.getcwd()
print(curDir)
os.mkdir('NixFiles')'''
'''shutil.move("/Users/Ayounes/Desktop/Python_dev/dictionary.txt",
"/Users/Ayounes/Desktop/Python_dev/")
shutil.move("/Users/Ayounes/Desktop/Python_dev/passwords.txt", "/Users/Ayounes/Desktop/Python_dev/")'''
def testPass(cryptPass):
salt = cryptPass[0:2]
dictFile = open('dictionary.txt', 'r')
for word in dictFile.read().split():
#print(word)
cryptWord = crypt.crypt(word, salt)
#print(cryptWord)
if(cryptWord == cryptPass):
print('Found password: %s' % word)
print('Index located at position: %d' % word.index(" "))
return
print('Password was not found.\n')
return
def main():
passFile = open('passwords.txt','r')
cryptPass1 = passFile.readline()
testPass(cryptPass1)
if __name__ == '__main__':
main()
My program retrieves a hash from a passwords.txt file. It then proceeds to take the salt parameters(first 2 characters of the hash) and hashes the words in the dictionary.txt file one at a time, line by line while comparing that hash to the original one in the passwords.txt file.
Once we have a match it presumes to print out which password was a decrypted match for the original hash.
'grilledcheese22' is the 4th word down at position 3 in the dictionary.txt file and it keeps outputting the index at postion: 0
How do I output the correct position in the .txt file?
Original hash: 22CWIxwLb7tWM
Decrypted hash inside dictionary.txt: 'grilledcheese22'