-1

When I type python cracked.py to open file, the file does not open and goes to a new line. Why is it doing that? this is the code I'm trying to run:

import crypt 

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()
tripleee
  • 175,061
  • 34
  • 275
  • 318

2 Answers2

2

passFile contains a zip file. you cannot read a zip file. You need to 1st unzip the "HomeworkW8.zip" file and open the file inside it(like .txt or .csv or .xls etc..).

If you want to know how to unzip the file, here is the link Unzipping files in python

LOKE2707
  • 312
  • 1
  • 5
  • 19
0

When you just import using:

import crypt

The other modules will be imported as python is inbuilt with the crypt module which implements an interface to the crypt(3) routine, which is a one-way hash function based upon a modified DES algorithm.

Maybe you can rename your module.

Pedram Parsian
  • 3,750
  • 3
  • 19
  • 34
Mou Sam Dahal
  • 273
  • 2
  • 10