-
Notifications
You must be signed in to change notification settings - Fork 172
/
zipattack.py
37 lines (35 loc) · 1.03 KB
/
zipattack.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
# -*- coding: utf-8 -*-
# @Author: lock
# @Date: 2016-11-02 17:17:26
# @Last Modified by: lock
# @Last Modified time: 2017-05-04 00:20:23
import zipfile
import threading
import optparse
def extractFile(zFile, password):
try:
zFile.extractall(pwd=password)
print("Key Found:", password)
exit()
except:
print("start test passwod: "+ password +"\n")
pass
def main():
parser = optparse.OptionParser('usage\t -f <zipfile> -d <dictionary> or -h get help')
parser.add_option('-f', dest='zname', type='string', help='specifyzip file')
parser.add_option('-d', dest='dname', type='string', help='specifydictionary file')
options, args = parser.parse_args()
if options.zname == None or options.dname == None:
print(parser.usage)
exit(0)
else:
zname = options.zname
dname = options.dname
zFile = zipfile.ZipFile(zname)
dFile = open(dname, 'r')
for line in dFile.readlines():
password = line.strip('\n')
t = threading.Thread(target=extractFile, args=(zFile, password))
t.start()
if __name__ == '__main__':
main()