-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzipC3.0.py
More file actions
128 lines (103 loc) · 4.13 KB
/
Copy pathzipC3.0.py
File metadata and controls
128 lines (103 loc) · 4.13 KB
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
from rich.console import Console
from rich.text import Text
import colorsys
import pyzipper
import multiprocessing
import os
import subprocess
import time
import pyfiglet
from colorama import init, Fore, Style
init(autoreset=True)
# Initialize a Console object to print to the terminal
console = Console()
def rainbow_text(text):
# Get the length of the input text
n = len(text)
# Create an empty Text object to store the styled text
rainbow_text = Text()
# Iterate over each character in the input text
for i, char in enumerate(text):
# Calculate the hue value for the current character (a value between 0 and 1)
hue = i / n
# Convert the hue to RGB values
r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(hue, 1, 1)]
# Append the character to the Text object with the RGB color style
rainbow_text.append(char, style=f"rgb({r},{g},{b})")
# Print the styled text to the console
console.print(rainbow_text)
space = ""
# Return the plain text string
return space
def display_banner():
# Use a specific font
f = pyfiglet.Figlet(font='slant')
ascii_art = f.renderText("ZipCracker")
# Display the ASCII art with a rainbow effect
rainbow_text(ascii_art)
# Print the byline
rainbow_text("__________________________by karthi")
def clear():
subprocess.run("clear")
def extract_zip_with_password(zip_path, password, extract_path):
try:
with pyzipper.AESZipFile(zip_path) as zf:
zf.pwd = password.encode('utf-8')
zf.extractall(path=extract_path)
return True
except (pyzipper.BadZipFile, RuntimeError):
return False
def password_cracker(zip_path, extract_path, start, end, found, password):
for attempt in range(start, end):
if found.value:
return
if attempt % 1000 == 0:
print(rainbow_text(f"Attempting password: {attempt}"))
if extract_zip_with_password(zip_path, str(attempt), extract_path):
with found.get_lock():
found.value = True
with password.get_lock():
password.value = attempt
return
def main():
try:
zip_path = input(rainbow_text("Enter path to your zip file: "))
extract_path = input(rainbow_text("Enter path to extract path: "))
if not os.path.isfile(zip_path):
raise FileNotFoundError(Fore.RED+"Zip file not found.")
start_range = int(input(rainbow_text("Enter start range for password: ")))
end_range = int(input(rainbow_text("Enter end range for password: ")))
if start_range >= end_range:
raise ValueError(Fore.RED+"Start range must be less than end range.")
num_processes = multiprocessing.cpu_count() # Use the number of available CPU cores
range_per_process = (end_range - start_range) // num_processes
password = multiprocessing.Value('i', 0)
found = multiprocessing.Value('b', False)
processes = []
start_time = time.time()
for i in range(num_processes):
start = start_range + i * range_per_process
end = start + range_per_process if i < num_processes - 1 else end_range
process = multiprocessing.Process(target=password_cracker, args=(zip_path, extract_path, start, end, found, password))
processes.append(process)
process.start()
for process in processes:
process.join()
end_time = time.time()
if found.value:
print(f"{Fore.CYAN}Password found: {password.value}")
print(f"{Fore.CYAN}Time taken: {end_time - start_time:.2f} seconds")
else:
print(f"{Fore.RED}Password not found in the specified range.")
except KeyboardInterrupt:
print(f"{Fore.YELLOW}Process interrupted by user.")
except FileNotFoundError as e:
print(f"{Fore.RED}Error: {e}")
except ValueError as e:
print(f"{Fore.RED}Error: {e}")
except Exception as e:
print(f"{Fore.RED}Unexpected error: {e}")
if __name__ == "__main__":
clear()
display_banner()
main()