import zipfile
# Create a list of dictionary words
dictionary_words = ['apple', 'banana', 'cherry', 'dog', 'elephant']
# Save the words to a file
with open('wordlist.txt', 'w') as f:
for word in dictionary_words:
f.write(word + '\\')
# Compress the file into a password-protected zip file
zip_file = zipfile.ZipFile('wordlist.zip', mode='w', compression=zipfile.ZIP_DEFLATED)
zip_file.setpassword(b'mypassword')
zip_file.write('wordlist.txt')
zip_file.close()
# Perform a brute force attack to extract the password
with open('wordlist.txt', 'r') as f:
words = f.readlines()
for word in words:
word = word.strip()
try:
with zipfile.ZipFile('wordlist.zip') as zip_file:
zip_file.extractall(pwd=bytes(word, 'utf-8'))
print(f'Password found: {word}')
break
except:
pass