Skip to content

Instantly share code, notes, and snippets.

@t41y0u
Last active December 5, 2019 12:32
Show Gist options
  • Save t41y0u/178754965e8bcd3885f48619ac077bb2 to your computer and use it in GitHub Desktop.
Save t41y0u/178754965e8bcd3885f48619ac077bb2 to your computer and use it in GitHub Desktop.
A script to brute force password protected zip files given wordlist using the python module zipfile
# A script to brute force password protected zip files given wordlist using the python module zipfile
# Created by Duong for GCI 2019
import time
import zipfile
# Replace the filename with your actual filename
filename = 'test.zip'
wordlist = 'wordlist.txt'
# Parsing the zip file to a ZipFile object
file = zipfile.ZipFile(filename)
# Open the wordlist
with open(wordlist, 'r') as f:
# Read each lines
lines = f.readlines()
count = len(lines)
for line in lines:
password = line.strip('\n')
print('Testing: %s | Status: ' % password, end = '')
try:
# Testing the password
file.extractall(pwd = password.encode())
print('Success!')
except:
# If an error occured, proceed to the next line
print('Failed | Strings left: %s' % count)
count = count - 1
pass
else:
# No errors occured and the password has been found. Exit the process to save time
print('Password found: %s' % password)
exit(0)
time.sleep(1) # Remove to speed up output time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment