I have some old RAR files and I know the general format of passwords I used to use, so I have generated a dictionary file combining those words in a variety of ways. The dictionary file is 500mb and I've wrote a python program to use the dictionary.
The issue is that the program has been running all night and is only 1% of the way in. I've now divided the dictionary file up and I am now running multiple instances of the program, but each instance is running pretty slow.
I would love any advice on how to improve the speed. I'm very new to Python, which will be obvious by my code (but I'm really enjoying Python).
import itertools import sys, traceback import os with open('dictionary.txt') as infile: words = [line.strip() for line in infile] for word1 in itertools.product(words, repeat=1): fword = word1 print "Attempting: " + fword # open unrar and test password output = os.popen("unrar.exe x protected.rar -p" + fword) outstring = output.read() slng = len(outstring) # unrar.exe returns "All OK" for correct password validate = outstring.find("All OK", 0, slng) if validate != -1: print "Found password: " + fword with open('correct_password.txt', 'w') as outfile: outfile.write(fword) sys.exit(0) else: # continue searching print "invalid password" raw_input("Password was not in this dictionary!")
FableLand FableWay FableTree FableSpirit FableApple