Question: Crack a zip file using Python I am trying to crack a password on a zip file. I wrote the code in a .py file.

Crack a zip file using Python

I am trying to crack a password on a zip file. I wrote the code in a .py file.

import zipfile import optparse from threading import Thread def extractFile(zFile, password): try: zFile.extractall(pwd=password) print '[+] Found password ' + password + ' ' except: pass def main(): parser = optparse.OptionParser("usage%prog "+\ "-f -d ") parser.add_option('-f', dest= 'zname', type= 'string',\ help= 'specify dictionary file') parser.add_option('-d', dest= 'dname', type= 'string',\ help= 'specify dictionary file') (options, args) = 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(' ') t = Thread(target=extractFile, args=(zFile, password)) t.start() if __name__ == '__main__': main()

I tried using the following command in the command prompt to execute the code to crack the password, and it keeps giving me a syntax error :

unzip.py -f (my zip file name) -d (my dictionary list file name)

Am I improperly executing the code?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!