-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrar-fu.py
127 lines (114 loc) · 4.49 KB
/
rar-fu.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
########################################################
# Do not work on Pydroid 3 because it needs unrar package to unlock rarfiles #
# If you use termux – you are good to go #
########################################################
import os, time
import rarfile #needs unrar pkg
from termcolor import colored
# font-colors
class fontcolor():
def green(string):
return colored(string, "green", attrs=['bold'])
def light_green(string):
return colored(string, "green")
def white(string):
return colored(string, "white", attrs=['bold'])
def yellow(string):
return colored(string, "yellow", attrs=['bold'])
def cyan(string):
return colored(string, "cyan", attrs=['bold'])
def red(string):
return colored(string, "red", attrs=['bold'])
def blue(string):
return colored(string, "blue", attrs=['bold'])
# smb ==> symbols
class smb:
WARN = fontcolor.red("[-] ")
DONE = fontcolor.green("[+] ")
INPUT = fontcolor.cyan("[»] ")
INFO = fontcolor.yellow("[!] ")
# banner art
banner_1 = fontcolor.light_green('''
██▀███ ▄▄▄ ██▀███ █████▒█ ██
▓██ ▒ ██▒▒████▄ ▓██ ▒ ██▒ ▓██ ▒ ██ ▓██▒
▓██ ░▄█ ▒▒██ ▀█▄ ▓██ ░▄█ ▒ ▒████ ░▓██ ▒██░
▒██▀▀█▄ ░██▄▄▄▄██ ▒██▀▀█▄ ░▓█▒ ░▓▓█ ░██░
░██▓ ▒██▒ ▓█ ▓██▒░██▓ ▒██▒ ░▒█░ ▒▒█████▓
░ ▒▓ ░▒▓░ ▒▒ ▓▒█░░ ▒▓ ░▒▓░ ▒ ░ ░▒▓▒ ▒ ▒
░▒ ░ ▒░ ▒ ▒▒ ░ ░▒ ░ ▒░ ░ ░░▒░ ░ ░
░░ ░ ░ ▒ ░░ ░ ░ ░ ░░░ ░ ░
░ ░ ░ ░ ░
''')
banner_2 = fontcolor.white(''' GitHub : @sumit-buddy''')
banner_3 = fontcolor.green(''' -----------------------------------------------''')
banner_4 = fontcolor.green(''' || Rar-Fu : RAR file dictionary attacker ||''')
banner_5 = fontcolor.green(''' -----------------------------------------------''')
# print banners
def banner():
print(banner_1)
print(banner_2)
print(banner_3)
print(banner_4)
print(banner_5)
# shows start time
def start_time():
start_time_show = time.asctime()
print(fontcolor.green("\nStart time ==> ") + fontcolor.white(start_time_show) + "\n")
# shows end time
def end_time():
end_time_show = time.asctime()
print(fontcolor.green("\nEnd time ==> ") + fontcolor.white(end_time_show) + "\n")
# check path and file
def check_path(path):
if os.path.isfile(path):
pass
else:
print(f"{smb.WARN}File Not Found !")
exit()
# count password from text file
def count_passwd(text_file):
count = 0
with open(text_file, "r") as wordlist:
for line in wordlist:
count += 1
return count
# clear screen
def clr_scr():
if os.name == 'posix':
_ = os.system('clear')
else:
_ = os.system('cls')
# use unrar to unlock rar file
def unrar(passwd, rar_file):
fileload = rarfile.RarFile(rar_file)
fileload.UNRAR_TOOL = "UnRAR.exe"
fileload.extractall("cracked_files", pwd = passwd)
# try passwords from wordlist
def crack():
passfile = open(pass_file, "r")
passwords = passfile.readlines()
for passwd in passwords:
passwd = passwd.rstrip("\n")
try:
unrar(passwd, rar_file)
print(f"\n{smb.DONE}" + fontcolor.green("PASSWORD FOUND & FILE CRACKED : ") + fontcolor.white(passwd))
break
except:
print(f"{smb.WARN}Wrong Password : " + passwd)
while True:
banner()
rar_file = input(f"\n{smb.INPUT}" + fontcolor.white("Enter Rar File Path : "))
check_path(rar_file)
pass_file = input(f"{smb.INPUT}" + fontcolor.white("Enter Password List Path : "))
check_path(pass_file)
total_passwds = count_passwd(pass_file)
print(f"\n{smb.DONE}" + fontcolor.white("Total Passwords In Wordlist : ") + fontcolor.green(total_passwds))
print(f"\n{smb.DONE}" + fontcolor.white("Starting Cracking ") + fontcolor.green(rar_file))
time.sleep(4)
start_time()
start_time = time.time()
crack()
end_time()
print(fontcolor.green("Program Executed In ==> ") + fontcolor.white("%s seconds") % (time.time() - start_time))
input("\nPress [ENTER] To Continue...")
clr_scr()