Python与Hack之Unix口令

1.在实验时候,先导入crypt库:必须在Unix环境下才能实现这个模块

 

2.代码贴一下,以后有了Unix环境试试吧:

import crypt
import sys
sys.modules['Crypto']=crypto

def testPass(cryptPass):
salt=cryptPass[0:2]
dictFile=open('dictionary.txt','r')
for word in dictFile.readline():
word=word.strip('\n')
cryptWord=crypto.crypto(word,salt)
if(cryptWord==cryptPass):
print("[+] Found Password:"+word+"\n")

print("[-] Password Not Found.\n")

def main():
passFile=open('passwords.txt')
for line in passFile.readline():
if ":" in line:
user=line.split(':')[0]
cryptPass=line.split(':')[1].strip(' ')
print("[+] Cracking Password For:"+user)
testPass(cryptPass)
if __name__=="__main__":
main()


posted @ 2016-11-23 21:23  小春熙子  阅读(401)  评论(0编辑  收藏  举报