The times when this worked were when I used ZIPCrypto compression. It's with AES-256 that it fails. How to get around this please?
I previously had success using the following Python code to open a password protected .zip file created with 7-Zip:
import zipfile
zip_file = zipfile.ZipFile('crack_me.zip')
output_verbose = 1 # increase that for long password list
with open('passwords.txt', 'rb') as password_list:
for index, line in enumerate(password_list):
try:
pwd = line.strip(b'\r\n')
zip_file.extractall(pwd=pwd)
except RuntimeError as e:
print(e)
if index % output_verbose == 0:
print('{}. The {} word not matched.'.format(index + 1, pwd))
else:
print('{}. Wow ! found the password: {}'.format(index + 1, pwd))
break
zip_file.close()
However, for no understandable reason, it has only worked a couple of times out of many attempts. Most times is gives "That compression method is not supported" for the exception.
I've tried deleting, renaming, re-creating the .zip file but no success. It makes no sense to me that it works occasionally.
I tried to simplify the issue as below:
import zipfile
zip_file = zipfile.ZipFile('crack_me.zip')
try:
zip_file.extractall(pwd=b"password")
print('Opened')
except RuntimeError as e:
print(e)
But I get the same exception. I've tried variations of pwd
such as bytes("password", "utf-8) and others.
The provided password opens the .zip file when opening with 7-Zip.
What is going on here please?