def zipDecrypt():
path1 = "a.zip" # 需要解壓的文件路徑及地址
path2 = "D:\\code\\python\\test" # 需要解壓到的文件夾地址
##密碼裡面含有大小寫字母,數字以及特殊符號
words = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'( )*+,-./:;<=>[email protected][]^_`{|}~"
for re in range(2):
r = its.product(words,repeat=re)
for i in r:
# print(type(i))
a ="".join(i) ##通過.join將數組裡面的元素轉換成字符串
print("當前測試密碼:",a)
###嘗試測試密碼,如果錯誤continue,進入下一次循環
try:
zFile = zipfile.ZipFile(path1, "r")
zFile.extractall(path = path2,pwd=a.encode())
zFile.close()
print('密碼破解成功:',a)
exit(0)
except Exception as e:
print("error",e)
continue
zipDecrypt()