Skip to content

Instantly share code, notes, and snippets.

@adicuco
Created October 16, 2018 09:07
Show Gist options
  • Save adicuco/7d1b984f935c449412103871a157d767 to your computer and use it in GitHub Desktop.
Save adicuco/7d1b984f935c449412103871a157d767 to your computer and use it in GitHub Desktop.
Brute Force zip file (deprecated)
from zipfile import ZipFile
import itertools
charset = "0123456789"
minSize = 1
maxSize = 3
zipName = 'text.zip'
def genPassword():
for x in range(minSize, maxSize + 1):
print('Trying passwords of length %d' % x)
for l in itertools.product(charset, repeat=x):
yield ''.join(l)
with ZipFile(zipName) as fileobj:
password = None
for i in genPassword():
password = i
try:
fileobj.extractall(pwd=password.encode())
password = 'Password found: %s' % password
print(password)
break
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment