├── README.md ├── brute_unrar.py └── screenshot.png /README.md: -------------------------------------------------------------------------------- 1 | # Python RAR Cracker 2 | A tiny python script for cracking rar file encrypted by a password 3 | 4 | ### Dependencies 5 | + [brute](https://github.com/rdegges/brute) 6 | + [python-unrar](https://github.com/matiasb/python-unrar) 7 | 8 | ### Usage 9 | There are two working modes. 10 | + In **dictionary** mode, the script loads each word in the dictionary and trys to decrypt the rarfile using that word. 11 | + In **brute** mode, the script trys every permutation of the given string set. 12 | ### Screenshot 13 | ![screenshot](./screenshot.png) 14 | ### Warning 15 | This script is only for learning purpose. 16 | Never use it to break the law. -------------------------------------------------------------------------------- /brute_unrar.py: -------------------------------------------------------------------------------- 1 | from brute import brute 2 | from unrar import rarfile 3 | import os 4 | 5 | try: 6 | input = raw_input 7 | except: 8 | input = input 9 | 10 | 11 | def fromDictionary(dicName): 12 | with open(dicName, "r") as f: 13 | for word in f: 14 | yield word.strip() 15 | 16 | 17 | def crackRar(rarFilename, pwdGenerator): 18 | rar = rarfile.RarFile(rarFilename) 19 | found = False 20 | for pwd in pwdGenerator: 21 | try: 22 | rar.extractall(pwd=pwd) 23 | print("file extracted") 24 | print("the password is %s" % pwd) 25 | found = True 26 | break 27 | except rarfile.BadRarFile: 28 | pass 29 | if not found: 30 | print("Sorry, cannot find the password") 31 | 32 | 33 | if __name__ == '__main__': 34 | print("----------------------------------------------------") 35 | print(' RAR Cracker') 36 | print(' by @Ghostish') 37 | print("----------------------------------------------------") 38 | filename = input("Please enter the filename: ") 39 | while not os.path.isfile(filename): 40 | filename = input("no such file, please enter a valid filename: ") 41 | 42 | mode = '' 43 | while mode != "dictionary" and mode != "brute": 44 | mode = input("Please select a working mode [dictionary/brute]: ") 45 | 46 | pwdGen = None 47 | if mode == "dictionary": 48 | dic_name = input("Please enter the filename of the dictionary: ") 49 | while not os.path.isfile(dic_name): 50 | dic_name = input("no such file, please enter a valid filename: ") 51 | pwdGen = fromDictionary(dic_name) 52 | 53 | if mode == "brute": 54 | letters = input("Include letters? [yes/no] (default yes) ") != 'no' 55 | symbols = input("Include symbols? [yes/no] (default yes) ") != 'no' 56 | numbers = input("Include numbers? [yes/no] (default yes) ") != 'no' 57 | spaces = input("Include spaces? [yes/no] (default no) ") == 'yes' 58 | start_length = int(input("min length: ")) 59 | length = int(input("max length: ")) 60 | pwdGen = brute(start_length=start_length,length=length,letters=letters,numbers=numbers,symbols=symbols,spaces=spaces) 61 | 62 | print("Start cracking") 63 | print("This may take some time, please wait...") 64 | crackRar(filename, pwdGen) 65 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ghostish/python-rar-cracker/61dbbd9bc9196d3494755bf3c33157d9a4defb18/screenshot.png --------------------------------------------------------------------------------