-1
我正在学习python,并且正在研究其中一个早期练习,并按照说明创建了所有内容并放置了字典文件并指出脚本在我的/ etc/passwd文件中,但不断收到此错误:AttributeError:'str'对象没有属性'salt'
AttributeError: 'str' object has no attribute 'salt'
这里是我使用的代码:
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.\n"
return
def main():
passFile = open('/etc/passwd')
for line in passFile.readlines():
if ":" in line:
user = line.split(":")[0]
cryptPass = line.split(":")[1].strip(' ')
print "[*] Cracking Password for: " +user
testPass(cryptPass)
if __name__ == "__main__":
main()
这确实是答案,非常感谢你:) – 2014-11-22 18:53:57