Advertisement
FlyFar

CrackP - ZIP

Jan 10th, 2023
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | Cybersecurity | 0 0
  1. #!/usr/bin/python
  2. import zipfile
  3. import argparse
  4.  
  5. def extractFile(zFile, password):
  6.     try:
  7.         zFile.extractall(pwd=password)
  8.         print "[+] Found password = " + password
  9.         return True
  10.     except:
  11.         return False
  12.  
  13. def main():
  14.     parser = argparse.ArgumentParser("%prog -f <zipfile> -d <dictionary>")
  15.     parser.add_argument("-f", dest="zname", help="specify zip file")
  16.     parser.add_argument("-d", dest="dname", help="specify dictionary file")
  17.     args = parser.parse_args()
  18.  
  19.     if (args.zname == None):
  20.         print parser.usage
  21.         exit(0)
  22.     elif (args.dname == None):
  23.         zname = args.zname
  24.         dname = 'passwords.txt'
  25.     else:
  26.         zname = args.zname
  27.         dname = args.dname
  28.  
  29.     zFile = zipfile.ZipFile(zname)
  30.     passFile = open(dname)
  31.  
  32.     for line in passFile.readlines():
  33.         password = line.strip("\n")
  34.         found = extractFile(zFile, password)
  35.         # Exit if password found
  36.         if found == True:
  37.             exit(0)
  38.  
  39.     # If it makes it here password has not been found...
  40.     print '[-] Password not found'
  41.  
  42. if __name__ == "__main__":
  43.     main()
Tags: ZIPCrack
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement