Skip to content

Instantly share code, notes, and snippets.

@dr1nk0rdi3
Last active June 22, 2019 14:21
Show Gist options
  • Save dr1nk0rdi3/f874547096e936c733848e383ed71eae to your computer and use it in GitHub Desktop.
Save dr1nk0rdi3/f874547096e936c733848e383ed71eae to your computer and use it in GitHub Desktop.
Brute force for .zip
#!/usr/bin/python3
from os import chdir, getcwd
from zipfile import ZipFile
from sys import exit
from time import time
import argparse
WHITE, RED, YELLOW, GREEN, END = '\33[1;97m','\33[1;91m', '\33[1;93m', '\33[1;32m', '\33[0m'
def brute(name_zip,file_txt,dst):
word_list = open(file_txt,'r',encoding='latin-1')
msg = '\n\t\t{0}Successful Brute Force!{1}\n\t\t {2}Password is{1} {3}{4}{1}\n'
t1 = time()
zip_file = ZipFile(name_zip)
for lin in word_list:
lin = lin.rstrip().encode()
try:
zip_file.extractall(path=dst,pwd=lin)
print(msg.format(YELLOW,END,GREEN,RED,lin.decode()))
except:
pass
word_list.close()
t2 = time()
print("\nTotal time: {:.2f} seconds".format(t2-t1))
return
def main():
p = argparse.ArgumentParser(
description='{0}BruteZip.py{1}'.format(GREEN,END))
p.add_argument(
'-d',
'--decrypt',
help ='Decrypt file',
action='store',
metavar = 'File.zip')
p.add_argument(
'-w',
'--wordlist',
help='Set wordlist',
action='store',
metavar= 'wordlist.txt')
p.add_argument(
'-o',
'--output',
help='choose the destination folder and directory')
args = p.parse_args()
if not args.wordlist:
p.print_help()
exit(1)
else:
wd = args.wordlist
if not args.output:
dir_dst = getcwd()
chdir(dir_dst)
else:
dir_dst = args.output
if args.decrypt:
namefile = args.decrypt
else:
print('Please, set a file for brute force')
p.print_help()
exit(1)
brute(namefile,wd,dir_dst)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
exit()
except SystemExit:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment