I've got a problem. I've made a simple zip file with password 12345. Now, when I try to extract the password using brute-force, zipfile chooses wrong password. It says it found password aaln0, but the extracted file is completly empty. Is there a way to 'fix' the library? Or is there a replacement for it? Thanks
Program code:
#!/usr/bin/env python
import itertools
import threading
import argparse
import time
import zipfile
import string
global found
found = False
def extract_zip(zFile, password):
"""
Extract archive with password
"""
try:
zFile.extractall(pwd=password)
write("[+] Password found:", password, "\n")
global found
found = True
except Exception, e:
pass
def write(*args):
print "[%s] %s" % (time.ctime(), " ".join(args))
def main_loop(zFile, length):
"""
Main loop
"""
write("[*] Python Brute-Force zip cracker")
write("[*] Zipfile: %s; password length: %s" % (zFile, length))
try:
zfile = zipfile.ZipFile(zFile)
except:
write("Cannot open zip file")
exit(1)
for combo in itertools.imap(''.join, itertools.product(string.letters + string.digits,
repeat=length)):
if found:
break
thread = threading.Thread(target=extract_zip, args=(zfile, combo))
thread.start()
if not found:
write("[-] Password not found")
def main():
"""
Main function
"""
parser = argparse.ArgumentParser(usage="brute-force-zipcracker.py -f <zipfile> -l <password length>")
parser.add_argument("-f", "--zipfile", help="specify zip file", type=str)
parser.add_argument("-l", "--length", type=int, help="password length", default=5)
args = parser.parse_args()
if (args.zipfile == None):
print parser.usage
exit(0)
main_loop(args.zipfile, args.length)
if __name__ == '__main__':
main()
zipfiledo you need? What does your code look like, and where doesaaln0come from? - Torxed12345, but the program says the password isaaln0. I added the code - JadedTunazipfilefrom selecting the wrong password? - JadedTuna