import itertools
import time
import zipfile
filepath = "文件路径"
uncompress_path = "解压路径"
pwd_num_list = [3,4,5]
pwd_dic = "abcdefghijklmnopqrstuvwxyz0123456789"
def uncompress(filepath,password):
try:
with zipfile.ZipFile(filepath) as zFile:
zFile.extractall(uncompress_path,pwd=password.encode("utf-8"))
return True
except:
return False
count = 0
start_time = time.time()
for pwd_num in pwd_num_list:
for c in itertools.permutations(pwd_dic, pwd_num):
count += 1
password = "".join(c)
if count % 10000 == 0:
print("已尝试破解", count, "次")
result = uncompress(filepath, password)
if result:
print("用时:", (time.time() - start_time), "秒")
print("一共尝试了", count, "次")
print("解压成功,密码是:", password)
break