-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathzip.py
47 lines (43 loc) · 1.38 KB
/
zip.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#-*-coding utf-8-*-
#-----------------------------------
# python2.7
# author:loster
# version:0.1
# description:暴力破解有密码的zip文件
#-------------------------------------
import zipfile
import os
from threading import Thread
import time
#压缩文件的路径
path = r'C:\Users\Administrator\Desktop\moeMaid-master.zip'
#password='1234'
def pojie_zip(path,password):
if path[-4:]=='.zip':
#path = dir+ '\\' +file
#print path
zip = zipfile.ZipFile(path, "r",zipfile.zlib.DEFLATED)
#print zip.namelist()
try:
#若解压成功,则返回True,和密码
zip.extractall(path='C:\\Users\\Administrator\\Desktop\\',members=zip.namelist() , pwd=password)
print ' ----success!,The password is %s' % password
zip.close()
return True
except:
pass #如果发生异常,不报错
print 'error'
def get_pass():
#密码字典的路径
passPath='C:\\Users\\Administrator\\Desktop\\zip.txt'
passFile=open(passPath,'r')
for line in passFile.readlines():
password=line.strip('\n')
print 'Try the password %s' % password
if pojie_zip(path,password):
break
passFile.close()
if __name__=='__main__':
start=time.clock()
get_pass()
print "done (%.2f seconds)" % (time.clock() - start)