Skip to content

Instantly share code, notes, and snippets.

@nyukhalov
Created January 22, 2019 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyukhalov/2c93387dac8666408a372426fbc7073d to your computer and use it in GitHub Desktop.
Save nyukhalov/2c93387dac8666408a372426fbc7073d to your computer and use it in GitHub Desktop.
unzips an archive using a password generated from a dictionary
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