I have been trying to make a simple zip file password cracker (just for fun, not malicious purposes) however my try and except statement will not work. No matter the input it always leads to the except statement, and the else is never executed (even though the zip file does extract)
import zipfile
k = 0
file = zipfile.ZipFile('john.zip')
def check(i):
p = bytes(i, 'ascii')
try:
file.extractall(pwd=p)
except:
return False
else:
return True
def crack():
x = open('john(1).txt', 'r')
for i in x.readlines():
i.strip('\n')
k = check(i)
if k == True:
print('Password is: ' + k)
break;
x.close()
x.close()`