#!/usr/bin/python

import crypt

def testpass(cryptpass):
    salt = cryptpass[0:2]
    dictfile = open('dictionary.txt', 'r')
    for word in dictfile.readlines():
        w = word.strip('\n')
        cryptword = crypt.crypt(w, salt)
        if (cryptword == cryptpass):
            print "[+] Found Password: %s\n" % w
            return
    print '[-] Password not found.\n'
    return
def main():
    passfile = open('passwords.txt', 'r')
    for line in passfile.readlines():
        if ':' in line:
            user = line.split(':')[0]
            cryptPass = line.split(':')[1].strip(' ')
            print '[*] Cracking Password for %s' % user
            testpass(cryptPass)
if __name__ == '__main__':
    main()
