Advertisement
BeamNG_IRC

Brute Force locked ZIP file

Apr 17th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.67 KB | None | 0 0
  1. # get dictionary file here: http://www.math.sjsu.edu/~foster/dictionary.txt
  2. import zipfile
  3. import sys
  4. import itertools
  5. def begin():
  6.     exit = 0
  7.     x = 0
  8.     zip = zipfile.ZipFile(file, "r") # zip file name
  9.     with open('dictionary.txt') as f: # dictionary file name
  10.         con = f.read().splitlines() # set con to contain the text document as a list
  11.         while x != 349999: # number of words in dictionary minus 1
  12.             if exit != 0:
  13.                 sys.exit(0)
  14.             try:
  15.                 password = con[x] # set password to x in list
  16.                 zip.setpassword(password) # try it
  17.                 zip.extractall()
  18.                 zip.printdir()
  19.                 zip.close()
  20.                 x = 349999
  21.                 print '************************'
  22.                 print password, 'accepted' # if password is correct
  23.                 print '************************'
  24.                 exit = 1
  25.             except: # if password is wrong
  26.                 print password, 'bad'
  27.                 x += 1 # x + 1
  28.     chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_$&#@ " # possible characters
  29.     for length in range(0,20):
  30.        for attempt in itertools.product(chars,repeat = length):
  31.           if exit != 0:
  32.               sys.exit(0)
  33.           password = ''.join(attempt)
  34.           print password, 'bad'
  35.           try:
  36.               zip.setpassword(password) # try it
  37.               zip.extractall()
  38.               zip.printdir()
  39.               zip.close()
  40.               print password, 'accepted'
  41.               exit = 1
  42.           except:
  43.               pass
  44. file = raw_input('Locked ZIP file name: ')
  45. begin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement