Python3实战--暴力破解zip或rar压缩文件密码

Python3实战--暴力破解zip或rar压缩文件密码

混合密码

1、准备字典

import itertools as its

words = 'abcdefghijklmnopqrstuvwxyz1234567890'
r = its.product(words, repeat=4)  # repeat要生成多少位的字典
with open("pwd.txt", "a")as f:
	for i in r:
		f.write("".join(i))
		f.write("".join("\r"))

2、暴力破解

import zipfile
#from unrar import rarfile
import threading
# 判断线程是否需要终止
flag = True
 
def extract(password, file):
    try:
        password = str(password)
        file.extractall(pwd=password.encode('utf-8'))#zip解压缩
        #file.extractall(pwd=password)#rar解压缩
        print("压缩包的密码是:{}".format(password))
        global flag
        flag = False
    except Exception:
        pass		#密码错误则跳过 
def main():
    file = zipfile.ZipFile("test.zip")#压缩文件
    #file = rarfile.RarFile("pwd.rar")
    passwords = open('pwd.txt')				#密码字典
    for line in passwords.readlines():#逐行读取密码
        if flag is True:
        		password = line.strip('\n')		#去掉回车
        		print(line,end="")						#逐个查看当前密码
        		t = threading.Thread(target=extract, args=(password, file))
        		t.start()	#开始
        		t.join()	#Parent父线程会等待child子线程运行完再继续运行
if __name__ == '__main__':	
    main()

数字密码

import zipfile
#from unrar import rarfile
import threading
# 判断线程是否需要终止
flag = True
 
def extract(password, file):
    try:
        password = str(password)
        file.extractall(pwd=password.encode('utf-8'))#zip解压缩
        #file.extractall(pwd=password)#rar解压缩
        print("压缩包的密码是:{}".format(password))
        global flag
        flag = False
    except Exception:
        pass		#密码错误则跳过 
def main():
    file = zipfile.ZipFile("test2.zip")#压缩文件
    #file = rarfile.RarFile("pwd.rar")
    for number in range(10000):
        if flag is True:
        	  number=str(number).zfill(4)
        	  print(number)
        	  t = threading.Thread(target=extract, args=(number, file))
        	  t.start()
        	  t.join()
if __name__ == '__main__':	
    main()

破解软件

如何用ARCHPR快速破解压缩包密码

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ChenBbMing

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值