Shiyan12

Задача 2

Dec 16th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. #coding: utf-8
  2. import zipfile
  3.  
  4. alphabet = [chr(i) for i in range(ord('a'), ord('z') + 1)]
  5. for i in range(10):
  6.     alphabet.append(str(i))
  7.  
  8. def brute_crack_zip(file):
  9.     z = zipfile.ZipFile(file, 'r')
  10.     def next_pwd(p = ''):
  11.         for alpha in alphabet:
  12.             new_p = p + alpha
  13.             try:
  14.                 z.extractall(pwd=new_p)
  15.                 return p
  16.             except Exception as e:
  17.                 pass
  18.             if len(new_p) < 8:
  19.                 next_pwd(new_p)
  20.     res = next_pwd()
  21.     if type(res) == 'str':
  22.         z.close()
  23.         return res
  24.     z.close()
  25.     return 'not found'
Add Comment
Please, Sign In to add comment