2021-01-07


这一学期这么快就接近尾声,望我在期末能考个好成绩,加油。


在这里插入图片描述

字典攻击

import itertools # 迭代器
import datetime
import hashlib
import time
def generatelibary(library, length=8):
libararys = itertools.product(library,repeat=length)
dic = open(“paswordlirbarys.txt”,“w”,encoding=‘utf-8’)#写模式打开文件
for i in libararys:
dic.writelines(i)
dic.writelines("\n")
dic.close()
#x = hashlib.md5(“123”.encode(encoding=“utf-8”)).hexdigest()#hash算法存储密码
#202cb962ac59075b964b07152d234b70
#print(x)
def dict_attack(path,password):
file = open(path)
for passwords in file:
#print(passwords)
passwords = passwords.split("\n")[0]
if password == hashlib.md5(passwords.encode(encoding=“utf-8”)).hexdigest():
print(“你的密码是:{}”.format(passwords))
file.close()
if name == “main”:
#lowercase = ‘abcdefghijklmnopqrstuvwxyz’#字符组合
#uppercase = ‘ABCDEFGHIJKLMNOPQRS’
#digits = ‘0123456789’
word = “liyu0524”#要用到的字母
#special = “”"!"#$%&’( )*+,-./:;<=>?@[]^_`{|}~"""
#word = lowercase + uppercase + digits + special
starttime = datetime.datetime.now() # 获取当前时间
print(time.strftime("%Y%m%d%H%M%S", time.localtime(time.time())))
generatelibary(word,length=6) #生成8位数字字典
#dict_attack(“paswordlirbarys.txt”,“05213bc82bacf7312806baf095038402”)
endtime = datetime.datetime.now()
print(time.strftime("%Y%m%d%H%M%S", time.localtime(time.time())))
print('The time cost: ')
print(endtime - starttime)#时间

运行出来的结果

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值