# -*- coding:utf-8 -*-
import zipfile
import threading
from termcolor import *
def crack(zFile,password):
try:
zFile.extractall(pwd=password.encode(‘cp850‘,‘replace‘))
print("++++++++++++++++++++++++KEY FOUND+++++++++++++++++++++++++++++++")
print(colored("[+]",‘green‘)+colored("Found password:"+password,‘cyan‘))
event.set()
return password
except Exception as e:
print(colored("[-]",‘red‘)+colored(password,‘blue‘)+colored(":is not the right key","yellow"))
def load():
zFile = zipfile.ZipFile(‘D:\\download\\1.zip‘)
# 由于系统默认的编码格式gbk所以这里要改变读取的编码格式不然会造成python抛出异常
passFile = open(‘C:\\Users\\Ma\\Desktop\\Desk\\实用小工具\\zip文件破解\\1.txt‘,encoding=‘utf-8‘, mode = ‘r‘)
for line in passFile.readlines():
if event.isSet():
return
else:
password = line.strip(‘\n‘)
t = threading.Thread(target=crack, args=(zFile, password))
t.start()
t.join()
if __name__ == ‘__main__‘:
event = threading.Event()
load()

原文:https://www.cnblogs.com/baimaoma/p/9085014.html