title: Python 3 Zip Password Cracker
body: <p>I am working on a simple zip file password cracker for a school project, and I need it to display the password once it cracks it from the dictionary word list. Whenever I run it, it only extracts the file, and doesn't print anything. How can I fix this to also show the password? Here is my code.</p>
  
  <pre><code>import optparse
  import zipfile
  from threading import Thread
  
  def extract_zip(zFile, password):
          try:
                  password = bytes(password.encode('utf-8'))
                  zFile.extractall(pwd=password)
                  print ("[+] Password Found: " + password + '\n')
          except:
                  pass
  
  def Main():
          parser = optparse.OptionParser("useage &amp;prog "+\
                          "-f &lt;zipfile&gt; -d &lt;dictionary&gt;")
  
          parser.add_option('-f', dest='zname', type='string',\
                          help='specify zip file')
          parser.add_option('-d', dest='dname', type='string',\
                          help='specify dictionary file')
          (options, arg) = parser.parse_args()
          if (options.zname == None) | (options.dname == None):
                  print (parser.usage)
                  exit(0)
          else:
                  zname = options.zname
                  dname = options.dname
  
          zFile = zipfile.ZipFile(zname)
          passFile = open(dname)
  
          for line in passFile.readlines():
              password = line.strip('\n')
              t = Thread(target=extract_zip, args=(zFile, password))
              t.start()
  
  if __name__ == '__main__':
          Main()
  </code></pre>