基于python的MD5脚本

摘要

鉴于网上的各大MD5爆破网站,当网络差时访问速度慢,至此小弟写了个基于python的MD5爆破脚本,欢迎各位师傅在评论区留下您们宝贵的意见。


 

开发思路

1、通过 string模块 自动生成字典;

2、使用permutations()函数,对字典进行全排列;

3、使用 md5模块 对全排列的字典进行转换;

4、使用了多线程,分别对5~18位字符串进行md5碰撞,以防止时间太长(虽然现在也要很久)。

 


 

 md5碰撞函数

 1     def md5_poj(self, md5_value, k):
 2         if len(md5_value) != 32:
 3             print("error")
 4             return
 5         md5_value = md5_value.lower()
 6         # permutations() 全排列
 7         for item in permutations(all_letters, k):
 8             item = "".join(item)
 9             if md5(item.encode()).hexdigest() == md5_value:
10                 print('\n success: ' + md5_value + ' ==> ' + item)
11                 self.__mdfive = 1

其中 if len(md5_value) != 32 判断所输入的md5是否为32位的


 

主函数

 1     def main(self):
 2         NT_md5 = input("请填写MD5:")
 3         start_time = time()
 4         t_list = []
 5         print("正在查询...")
 6         # 添加线程
 7         t_first = threading.Thread(target=self.md5_first, args=(NT_md5,))
 8         t_first.daemon = 1
 9         t_first.start()
10         for k in range(5, 18):
11             t = Process(target=self.md5_poj, args=(NT_md5, k))
12             # t = threading.Thread(target=self.md5_poj, args=(NT_md5, k))
13             t.daemon = 1    # 守护程序
14             t_list.append(t)
15         # 启动所有线程
16         for i in t_list:
17             i.start()
18         # 当 __mdfive == 1 时结束所有线程
19         while 1:
20             if self.__mdfive:
21                 break
22         print("\n查询结束!")
23         print('使用了 %f 秒'%(time() - start_time))

 源码我放在github上了,可以点击右上角进入

 备注

如需转载,请联系作者:spmonkey,联系方式可通过博客园的联系,亦可发至作者邮箱:spm0nkey@163.com

posted @ 2022-03-30 15:44  spmonkey  阅读(769)  评论(0)    收藏  举报