import randomimport sysimport zipfileimport timefrom threading import Threadfrom multiprocessing import Processclass MyIterator: # letters = '01234567... ...
import random
import sys
import zipfile
import time
from threading import Thread
from multiprocessing import Process
class MyIterator:
# letters = '0123456789abcdefghijklmnopqrstuvwxyz'
letters = '1234zjcv'
min_dig = 0
max_dig = 0
def __init__(self, min_dig, max_dig):
if min_dig < max_dig:
self.min_dig = min_dig
self.max_dig = max_dig
else:
self.min_dig = max_dig
self.max_dig = min_dig
def __iter__(self):
return self
def __next__(self):
rst = str()
for item in range(0,random.randrange(self.min_dig,self.max_dig+1)):
rst += random.choice(MyIterator.letters)
return rst
def extract():
start_time = time.time()
zfile = zipfile.ZipFile('123.zip')
for p in MyIterator(4, 6):
print(p)
try:
zfile.extractall(path='.', pwd=str(p).encode('utf-8'))
print('文件密碼為:{}'.format(p))
now_time = time.time()
print('破解用時:{}'.format(now_time - start_time))
sys.exit()
except Exception as e:
pass
if __name__ == '__main__':
tl = Thread(target=extract)
tl.start()
tl.join()