1 year ago
#346723
Felix D
Bruteforcing a zip password in python
I want to bruteforce a 4 digit password with the following loop. My openFile function works as planned when using it isolated. When I try it with my breakPW funtion it doesnt work at all.
Any tips and tricks?
I tried it with the following code. However, it just iterates through the passwords, but somehow doesnt open the zip file when it hits the correct password.
import string
from zipfile import ZipFile
zip_file = 'test.zip'
def openFile(zip_file, password):
try:
with ZipFile(zip_file) as zf:
zf.extractall(pwd=bytes(password,'utf-8'))
except:
return
alphabet_numbers = string.ascii_lowercase + string.digits
def breakPW():
for elem1 in alphabet_numbers:
for elem2 in alphabet_numbers:
for elem3 in alphabet_numbers:
for elem4 in alphabet_numbers:
password = elem1 + elem2 + elem3 + elem4
openFile('test.zip', password)
breakPW()
python
unzip
zip
brute-force
python-zipfile
0 Answers
Your Answer