'zipfile extractall pauses script (Raspberry python3)

I have a dictionary with 10 words (one IS the correct password)

script on python3 (on Raspberry) iterates over dictionary

when it gets to the right password , pauses/stops (extracts the zip file) but resumes the script and does not exit nor it print "password is.."

#!/usr/bin/env python3

import zipfile
import sys

def crackzip(el_zip, clave):
    try:
        el_zip.extractall(pwd = clave)
        sys.exit("password is : " + clave)
    except:
        pass


file_zip = 'file_to_crack.zip'
dictionary = 'dictionary.txt'
zippy = zipfile.ZipFile(file_zip)
with open(dictionary, 'r') as f:
    for line in f.readlines():
        password = line.strip('\n')
        print(password)
        crackzip(zippy, password.encode('utf-8'))


Solution 1:[1]

I found that I wasn't stoping the process when the password was found, so now this is added and password showed when found!!

THANKS!!!

´´´ #!/usr/bin/env python3

import zipfile
import sys

def crackzip(el_zip, clave):
    try:
        el_zip.extractall(pwd = clave.enconde('uft-8'))
        print("password found: " + clave)
        revisor = 1
        return revisor
    except:
        revisor = 0
        return revisor


file_zip = 'file_to_crack.zip'
dictionary = 'dictionary.txt'
zippy = zipfile.ZipFile(file_zip)
revisor = 0
with open(dictionary, 'r') as f:
    for line in f.readlines():
        password = line.strip('\n')
        print(password)
        revisor = crackzip(zippy, password.encode('utf-8'))
        if revisor == 1:
            quit()

´´´

Solution 2:[2]

you are trying to concatenate a string object with a bytes object which is not a valid operation.

This produces an exception which your code squashes and continues.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Richonguzman
Solution 2 plugwash