Skip to content

Instantly share code, notes, and snippets.

@tbhaxor
Created October 3, 2019 20:36
Show Gist options
  • Save tbhaxor/12febbe2394dda3d72ba3e1d84e73122 to your computer and use it in GitHub Desktop.
Save tbhaxor/12febbe2394dda3d72ba3e1d84e73122 to your computer and use it in GitHub Desktop.
Zip password cracker
from os import path
import tempfile
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from zipfile import ZipFile
from queue import Queue
# configuring argument parser
parser = ArgumentParser(description="Zip file cracker",
formatter_class=RawDescriptionHelpFormatter)
parser.add_argument("--zip", help="zip file to extract",
required=True, metavar="PATH")
parser.add_argument(
"--wordlist", help="path of wordlist to be used", metavar="PATH", required=True)
args = parser.parse_args()
print("[!] Loading zip: {}".format(args.zip))
try:
# opening zip file
with open(args.wordlist) as file:
words = [x.strip() for x in file.readlines()]
pass
except FileNotFoundError:
# print error and exit
print("[x] Wordlist not found")
exit(1)
print("[!] Loaded {} words".format(len(words)))
# iterate words
for word in words:
try:
# try to extract zip
ZipFile(args.zip).extractall(
pwd=word.encode(), path=tempfile.gettempdir())
# if extracted print password
print("[!] Password Found: {}".format(word))
# break and exit
break
except RuntimeError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment