-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZipFile.py
More file actions
28 lines (25 loc) · 842 Bytes
/
ZipFile.py
File metadata and controls
28 lines (25 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import zipfile
def tryZipPwd(zFile,savePath,pw=None):
try:
if pw == None:
zFile.extractall(savePath)
else:
#注意指定path 和 pwd 参数
zFile.extractall(path = savePath,pwd = pw.encode())
print("Zip文件解压成功,密码:%s" % (pw))
return True
except:
print('Zip文件解压失败,密码:%s' % (pw))
return False
with zipfile.ZipFile('C:/Tencent/test.zip') as zFile:
passPath = 'C:/Tencent/password.txt'
passFile = open(passPath,'r')
for i in passFile.readlines():
password = i.strip('\n')
if tryZipPwd(zFile,'C:/Tencent/',password):
break
for i in range(12000,99999999):
if tryZipPwd(zFile,'C:/Tencent/',i):
break
passFile.close()