Created
January 22, 2019 04:37
-
-
Save nyukhalov/2c93387dac8666408a372426fbc7073d to your computer and use it in GitHub Desktop.
unzips an archive using a password generated from a dictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import permutations | |
from zipfile import ZipFile | |
archive = 'archive.zip' | |
keywords = [ | |
'foo', | |
'bar', | |
'buzz' | |
] | |
num_keywords = 3 | |
for comb in permutations(keywords, num_keywords): | |
pwd = ''.join(comb) | |
print('trying ', pwd) | |
try: | |
with ZipFile(archive) as zf: | |
zf.extractall(pwd=pwd.encode()) | |
print(pwd, 'is correct') | |
exit(0) | |
except Exception as e: | |
#print(e) | |
print(pwd, ' is incorrect') | |
print('all combinations are incorrect') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment