我只是在乱看是否可以使用“crypt”模块,我似乎遇到了一个我一生都无法解决的问题。我运行后的输出是这样的:
Password Not Found. secret HXXxJi0n6Huro HXXxJi0n6Huro
这意味着 cryptWord 和 cryptPass 是相同的,那么为什么程序不执行 ( if cryptWord == cryptPass:
) 和print 'Found Password:
我只是不明白。
dictionary.txt 文件中多次包含secret 这个词,都在不同的行中。evil.txt 文件有这一行:
test_user:HXXxJi0n6Huro
据我所知,一切正常吗?但是有些东西阻碍了它的正常工作,我就是想不通。任何帮助,将不胜感激。
import crypt
def testPass(cryptPass):
salt = cryptPass[0:2]
dictFile = open('dictionary.txt', 'r')
for word in dictFile.readlines():
word = word.strip('\n')
cryptWord = crypt.crypt(word, salt)
if cryptWord == cryptPass:
print "[+] Found Password: "+word+"\n"
return
print "[-] Password Not Found. " +word, cryptWord, cryptPass+ "\n"
return
def main():
passFile= open('evil.txt')
for line in passFile.readlines():
if ":" in line:
user = line.split(':')[0]
cryptPass = line.split(':')[1]
print "[*] Cracking Password For: "+user
testPass(cryptPass)
if __name__ == '__main__':
main()