python语言zip文件密码恢复程序代码1

import rarfile
import zipfile
import py7zr
import time

定义字典文件路径

dict_path = r"mm.txt"

定义要破解的压缩包文件路径

file_path = r"2.zip"

c = 0
a = 0
print(“本软件只支持 7z, zip, rar 格式的压缩包”)

try:
ozd = open(dict_path, “r”, encoding=“utf8”).read().split(“\n”)
except:
print(“字典读取失败”)
print(f"检测到字典里有{len(ozd)}个密码")

if file_path.endswith(“.zip”):
print(“检测到是 zip 压缩包”)

zip_file = zipfile.ZipFile(file_path)
for pas in ozd:
    c = c + 1
    pasw = bytes(pas.encode("utf8"))
    print(f"正在尝试密码:{pas}")
    time.sleep(0.1)  # 这里添加了 1 秒的延时

    try:
        zip_file.extractall(pwd=pasw)
        print("破解成功,密码是:" + pas)
        a = a + 1
        break
    except:
        pass

if a == 0:
    print("破解失败")

elif file_path.endswith(“.rar”):
print(“检测到是 rar 压缩包”)

rar_file = rarfile.RarFile(file_path)
for pas in ozd:
    c = c + 1
    pasw = bytes(pas.encode("utf8"))
    print(f"正在尝试密码:{pas}")
    time.sleep(0.1)  # 这里添加了 1 秒的延时
    try:
        rar_file.extractall(pwd=pasw)
        print("破解成功,密码是:" + pas)
        a = a + 1
        break
    except:
        pass

if a == 0:
    print("破解失败")

elif file_path.endswith(“.7z”):
print(“检测到是 7z 压缩包”)

for pas in ozd:
    c = c + 1
    pasw = bytes(pas.encode("utf8"))
    print(f"正在尝试密码:{pas}")
    time.sleep(0.1)  # 这里添加了 1 秒的延时
    try:
        qz = py7zr.SevenZipFile(file_path, password=pasw)
        qz.extractall()
        print("破解成功,密码是" + pas)
        a = a + 1
        break
    except:
        pass


if a == 0:
    print("破解失败")

else:
print(“此文件不是压缩包文件”)
print(f"已经尝试了{c}个密码")
input(“破解完成,请按任意键继续…”)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

易软科技(河源)有限公司

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

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

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

打赏作者

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

抵扣说明:

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

余额充值