Search code examples
pythonzipoutput

no output/pwd print - zip cracker Process finished with exit code 0


import zipfile
import itertools
import string
from threading import Thread


def crack(zip, pwd):
    try:
        zip.extractall(pwd=str.encode(pwd))
        print("Success: Password is " + pwd)
    except:
        pass


zipFile = zipfile.ZipFile("/Users/Yamakasi/Desktop/PY/Mat1.zip")
myLetters = string.ascii_letters + string.digits + string.punctuation
for i in range(1, 1):
    for j in map("".join, itertools.product(myLetters, repeat=i)):
        t = Thread(target=crack, args=(zipFile, j))
        t.start()

#Hey @ll, Process finished with exit code 0 but no output on may zip cracker? Greeting and Thanks for your help!


Solution

  • The problem is with your external for loop. It doesn't run at all.

    range(i, j) runs from i to j-1 so range(1, 1) will run from 1 to 0 which means don't run at all.

    for i in range(1, 1):
        print("hi")
    

    The above code doesn't print anything since the for loop is not entered once. If you want to run the for loop once, you should use:

    for i in range(1, 2):
        print("hi")
    

    Output:

    hi