暴力破解unix/linux平台上采用crypt加密的口令

 1 # coding=utf-8
 2 
 3 '''
 4 暴力破解crypt模块加密的密码
 5 '''
 6 
 7 import crypt
 8 import optparse
 9 
10 usage = 'Usage: %prog [optinos] -p password.txt -d dictionary.txt'
11 parser = optparse.OptionParser(usage,version=1.0)
12 parser.add_option('-p',dest='pFile',action='store',
13                   help='加密后的口令存放文件')
14 parser.add_option('-d',dest='dFile',action='store',
15                   help='字典文件')
16 (options,args) = parser.parse_args()
17 
18 def dection_passwords(password):
19    salt = password[:2]
20    dfile = open(options.dFile)
21    for word in dfile:
22         word = word.strip('\r\n')
23         cryptWord = crypt.crypt(word,salt)
24         if cryptWord == password:
25             print '找到密码,密码是:',word
26             return
27    print '未找到密码!'
28    return
29 
30 def main():
31    passfile = open(options.pFile)
32    for password in passfile:
33         password = password.strip('\r\n')
34         if password != '':
35             dection_passwords(password)
36 
37 if __name__ == '__main__':
38    main()

运行后的结果是:

1 python ForceCrackCrypt.py -p /root/Desktop/password.txt -d /root/Desktop/dictionary.txt
2 找到密码,密码是: 123456
3 找到密码,密码是: 11111111
4 找到密码,密码是: abc123

 

posted @ 2016-07-17 20:51  挣扎的猪  阅读(1595)  评论(0编辑  收藏  举报