标签:user 实现 blog unix 环境 ctf readline txt salt
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()
标签:user 实现 blog unix 环境 ctf readline txt salt
原文地址:http://www.cnblogs.com/hqutcy/p/6095418.html