在linux python中运行文件时遇到问题
收藏

当我键入python cracked.py以打开文件时,该文件不会打开并转到新行。为什么要这么做?这是我要运行的代码:
导入密码

def testPass(cryptPass):
    salt = cryptPass[0:2]
    dictFile = open('dictionary-1.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('/root/homework/HomeworkW8.zip')
    for line in passFile.readlines():
        if ":" in line:
            user = line.split(':')[0]
            cryptPass = line.split(':')[1].strip(' ')
            print "[*] Crackin Password For: "+user
            testPass(cryptPass)

if __name__  == "__main__":
    main()


最佳答案:

passFile包含一个zip文件。无法读取zip文件。您需要首先解压缩“homew8.zip”文件并打开其中的文件(如.txt或.csv或.xls等)。
如果你想知道如何解压文件,这里是链接
Unzipping files in python

    公众号
    关注公众号订阅更多技术干货!