Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import zipfile
- import sys
- from random import randint
- from multiprocessing import Process
- import io
- class Decrypter:
- LEN_MAX = 15
- def __init__(self, pr):
- print(f"Process #{pr} started!")
- with open("words.txt", "r") as fin:
- self.words = fin.readlines()
- self.words = [bytes(i[:-1], encoding='utf-8') for i in self.words]
- self.nr = len(self.words)
- with open("zip-test-55.zip", "rb") as zip:
- zip_file = io.BytesIO(zip.read())
- self.file = zipfile.ZipFile(zip_file)
- self.bruteforce()
- def print_result(self, p):
- ans = str(p, encoding='utf-8')
- with open("password.txt", "w") as fout:
- fout.write(ans)
- sys.exit()
- def get_rnd(self):
- return randint(0, self.nr - 1)
- def try_decrypt(self, passwd):
- try:
- self.file.extractall(pwd=passwd)
- print("SUCCESS:", passwd)
- self.print_result(passwd)
- sys.exit()
- except Exception as e:
- pass
- def bruteforce(self):
- while True:
- taken = [False for i in range(self.nr)]
- ans = b''
- while (len(ans) < Decrypter.LEN_MAX):
- p = self.get_rnd()
- if taken[p]:
- continue
- taken[p] = True
- ans += self.words[p]
- self.try_decrypt(ans)
- def main():
- NR_PROCESS = 16
- prc = []
- for i in range(NR_PROCESS):
- prc.append(Process(target=Decrypter, args=(i,)))
- prc[-1].start()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement