-
Notifications
You must be signed in to change notification settings - Fork 10
/
RARNinja.py
134 lines (110 loc) · 5.23 KB
/
RARNinja.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import rarfile
import time; import os
from termcolor import colored
import colorama
colorama.init()
correctPath = False
rarfile.UNRAR_TOOL = "UnRAR.exe"
BANNER1 = colored('''
██▀███ ▄▄▄ ██▀███ ███▄ █ ██▓ ███▄ █ ▄▄▄██▀▀▀▄▄▄
▓██ ▒ ██▒▒████▄ ▓██ ▒ ██▒ ██ ▀█ █ ▓██▒ ██ ▀█ █ ▒██ ▒████▄
▓██ ░▄█ ▒▒██ ▀█▄ ▓██ ░▄█ ▒▓██ ▀█ ██▒▒██▒▓██ ▀█ ██▒ ░██ ▒██ ▀█▄
▒██▀▀█▄ ░██▄▄▄▄██ ▒██▀▀█▄ ▓██▒ ▐▌██▒░██░▓██▒ ▐▌██▒▓██▄██▓ ░██▄▄▄▄██
░██▓ ▒██▒ ▓█ ▓██▒░██▓ ▒██▒▒██░ ▓██░░██░▒██░ ▓██░ ▓███▒ ▓█ ▓██▒
░ ▒▓ ░▒▓░ ▒▒ ▓▒█░░ ▒▓ ░▒▓░░ ▒░ ▒ ▒ ░▓ ░ ▒░ ▒ ▒ ▒▓▒▒░ ▒▒ ▓▒█░
░▒ ░ ▒░ ▒ ▒▒ ░ ░▒ ░ ▒░░ ░░ ░ ▒░ ▒ ░░ ░░ ░ ▒░ ▒ ░▒░ ▒ ▒▒ ░
░░ ░ ░ ▒ ░░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ▒
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░''', 'blue')
BANNER2 = colored(''' -------------------------------------------------''', 'blue')
BANNER3 = colored(''' || RARNinja: The RAR Password Cracking Utility ||''', 'red')
BANNER4 = colored(''' -------------------------------------------------''', 'blue')
def printBanner():
print(BANNER1), print(BANNER2), print(BANNER3), print(BANNER4)
def progress():
clrscr()
found = False
with open(dictionary, "r") as file:
for tries, line in enumerate(file):
password = str(line).strip()
try:
with rarfile.RarFile(RAR, "r") as rar:
rar.extractall(path="./Extracted/", pwd=password)
print(colored(f"\nCracked and extracted! Password: {password}", "green"))
found = True
break
except:
print(f"Incorrect password tried: {password}")
continue
return(found, tries)
def noProgress():
clrscr()
found = False
print("\nWorking...", end='')
with open(dictionary, "r") as file:
for tries, line in enumerate(file, start=1):
password = str(line).strip()
try:
with rarfile.RarFile(RAR, "r") as rar:
rar.extractall(path="./Extracted/", pwd=password)
print(colored(f" Cracked and extracted! Password: {password}", "green"))
found = True
break
except:
continue
return(found, tries)
def clrscr():
if os.name == 'posix':
_ = os.system('clear')
else:
_ = os.system('cls')
printBanner()
############### Main ###############
if __name__ == "__main__":
printBanner()
try:
while (True):
RAR = input("\nEnter RAR file path here: ")
dictionary = input("Enter dictionary file path here: ")
if (os.path.isfile(RAR) is True and os.path.isfile(dictionary) is True):
break
else:
clrscr()
print("\nEither file does not exist or invalid path entered. Try again.\n")
continue
while (True):
print("\nShow progress?")
print("1. Yes (slower)\n2. No (faster)")
progressPrompt = input("\nSelect option number (Default = No): ") or "2"
if (progressPrompt == "1"):
start = time.time()
found, tries = progress()
completionTime = time.time() - start
break
elif (progressPrompt == "2"):
start = time.time()
found, tries = noProgress()
completionTime = time.time() - start
break
else:
clrscr()
print("\nInvalid entry. Choose either option 1 or 2. Try again.\n")
continue
if found:
try:
rate = (int(tries) // completionTime)
print(f"\n\nThe task completed successfully in {completionTime} seconds. (at ~{rate} tries/sec)")
print("Press any key to exit.")
input()
except ZeroDivisionError:
print("\n\nThe task completed successfully in zero seconds.")
print("Press any key to exit.")
input()
else:
print(colored(f" All lines in {dictionary} tried and exhausted (password not found), You may try another dictionary file.", "red"))
print("\nPress any key to exit.")
input()
except KeyboardInterrupt:
clrscr()
print("\nCTRL ^C\n\nThrew a wrench in the works.")
print("Press Enter to exit.")
input()