Skip to content

Instantly share code, notes, and snippets.

@jpdias
Last active August 11, 2020 16:11
Show Gist options
  • Save jpdias/6e19fb84d49bfd8c7d858d74c31958de to your computer and use it in GitHub Desktop.
Save jpdias/6e19fb84d49bfd8c7d858d74c31958de to your computer and use it in GitHub Desktop.
Python3 ZIP dictionary bruteforcer
import zipfile
import timeit
import sys
argv = sys.argv
zFile = zipfile.ZipFile(str(argv[1]))
dictionary_attack = argv[2]
def Cracker():
attempts = 0
flag = 0
with open(dictionary_attack, 'r') as attack:
print("Cracking password...")
for line in attack:
try:
# from the wordlist there is newline
# they need to be stripped
# encode passwd from str to bytes
passwd = line.strip('\n')
zFile.extractall(pwd=str.encode(passwd))
except Exception:
attempts += 1
pass
else:
print("Success! Password is %s" % (passwd))
flag = 1
break
print("Attempted %d passwords from %s wordlist" % (attempts, dictionary_attack))
if flag == 0:
print("Password Cracking Failed!")
if __name__ == "__main__":
start = timeit.default_timer()
Cracker()
stop = timeit.default_timer()
print("zip-cracker crack it in %d secs" % (stop - start))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment