-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
413 lines (350 loc) · 15.9 KB
/
main.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
import os
import sys
import time
import threading
import subprocess
import json
from utils.theme import set_theme, get_current_theme, theme_banner, themes
if os.name == 'nt':
import msvcrt
else:
import tty
import termios
def read_requirements(file_path):
with open(file_path, 'r') as file:
return [line.strip() for line in file if line.strip() and not line.startswith('#')]
def read_tools_info(json_path):
with open(json_path, 'r') as file:
data = json.load(file)
return data
try:
import pkg_resources
import fade
from blessed import Terminal
from pystyle import Add, Anime, Center, Colorate, Colors, Cursor, Write
except Exception as e:
print(e)
term = Terminal()
def get_choice_windows(prompt):
print(prompt, end='', flush=True)
choice = ""
while True:
char = msvcrt.getch()
if char == b'\x1b':
next1, next2 = msvcrt.getch(), msvcrt.getch()
if next1 == b'[':
if next2 == b'C':
return 'next'
elif next2 == b'D':
return 'prev'
elif char in [b'\r', b'\n']:
print()
return choice.strip()
elif char == b'>':
return 'next'
elif char == b'<':
return 'prev'
elif char == b'?':
return '?'
elif char == b'=':
return '='
elif char == b'\x08':
if choice:
choice = choice[:-1]
sys.stdout.write('\b \b')
sys.stdout.flush()
elif char == b'\x03': # Ctrl+C
raise KeyboardInterrupt
elif char == b'\x04': # Ctrl+D
raise EOFError
elif char == b'\x1a': # Ctrl+Z
raise KeyboardInterrupt
else:
choice += char.decode()
sys.stdout.write(char.decode())
sys.stdout.flush()
def get_choice_unix(prompt):
print(prompt, end='', flush=True)
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
choice = ""
while True:
char = sys.stdin.read(1)
if char == '\x1b':
next1, next2 = sys.stdin.read(1), sys.stdin.read(1)
if next1 == '[':
if next2 == 'C':
return 'next'
elif next2 == 'D':
return 'prev'
elif char in ['\r', '\n']:
print()
return choice.strip()
elif char == '>':
return 'next'
elif char == '<':
return 'prev'
elif char == '?':
return '?'
elif char == '=':
return '='
elif char == '\x7f':
if choice:
choice = choice[:-1]
sys.stdout.write('\b \b')
sys.stdout.flush()
elif char == '\x03': # Ctrl+C
raise KeyboardInterrupt
elif char == '\x04': # Ctrl+D
raise EOFError
elif char == '\x1a': # Ctrl+Z
raise KeyboardInterrupt
else:
choice += char
sys.stdout.write(char)
sys.stdout.flush()
except (KeyboardInterrupt, EOFError):
return 'exit'
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
def clear():
system = os.name
if system == 'nt':
os.system('cls')
elif system == 'posix':
os.system('clear')
else:
print('\n'*120)
return
def animated_text(text, delay=0.05):
for line in text.split('\n'):
for char in line:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(delay)
sys.stdout.write('\n')
sys.stdout.flush()
time.sleep(delay)
def get_scripts():
scripts = []
for root, _, files in os.walk('utils'):
for file in files:
if file.endswith('.py') and root != 'utils':
category = os.path.basename(root)
script_name = os.path.splitext(file)[0].replace('_', ' ').title()
scripts.append((script_name, category))
return scripts
def calculate_total_length(entry_number, entry_script, entry_category):
return len(entry_number) + len(entry_script) + len(entry_category)
def add_spaces(entry, total_length, target_length):
return entry + ' ' * (target_length + total_length)
def display_ascii_art(page_scripts, page_number, total_pages, tools_info, current_theme):
developers = " x ".join(tools_info['developers'])
version = tools_info['version']
entries_per_page = 30
total_entries = len(page_scripts)
lines_per_page = (total_entries + 2) // 3
text_color = f"{current_theme['primary']}AA{current_theme['reset']}{current_theme['secondary']}BBBBBBBBBB{current_theme['reset']}{current_theme['primary']}CCCCCCCCC{current_theme['reset']}"
add_color = len(text_color)
line_width = add_color
split = f" "
bar_old = f" ─────────────────────────────────────────────────────────────────────────────────────────────────────────"
lbar = "─" * 105
bar = f"{split}{lbar}"
art = theme_banner(f"""
▄▄▄· ▄▄▄▄▄ • ▌ ▄ ·. • ▌ ▄ ·. ▄• ▄▌▄▄▌ ▄▄▄▄▄▪ ▄▄▄▄▄ ▄▄▌ .▄▄ ·
▐█ ▀█ •██ ▪ ·██ ▐███▪ ·██ ▐███▪█▪██▌██• •██ ██ •██ ▪ ▪ ██• ▐█ ▀.
▄█▀▀█ ▐█.▪ ▄█▀▄ ▐█ ▌▐▌▐█· ▐█ ▌▐▌▐█·█▌▐█▌██▪ ▐█.▪▐█· ▐█.▪ ▄█▀▄ ▄█▀▄ ██▪ ▄▀▀▀█▄
▐█ ▪▐▌ ▐█▌·▐█▌.▐▌██ ██▌▐█▌ ██ ██▌▐█▌▐█▄█▌▐█▌▐▌ ▐█▌·▐█▌ ▐█▌·▐█▌.▐▌▐█▌.▐▌▐█▌▐▌▐█▄▪▐█
▀ ▀ ▀▀▀ ▀█▄▀▪▀▀ █▪▀▀▀ ▀▀ █▪▀▀▀ ▀▀▀ .▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀ ▀█▄▀▪ ▀█▄▀▪.▀▀▀ ▀▀▀▀
""")
art += f"""{current_theme["primary"]}
Developers : {current_theme['reset']}{current_theme["secondary"]}{developers}{current_theme['reset']}{current_theme["primary"]}
{bar}
Version : {current_theme['reset']}{current_theme["secondary"]}{version}{current_theme['reset']}{current_theme["primary"]}
{bar}
"""
for i in range(lines_per_page):
line = ""
for j in range(3):
if(total_entries < 30):
index = i * 3 + j
else:
if j == 0:
index = i
elif j == 1:
index = i + 10
elif j == 2:
index = i + 20
if index < total_entries:
total_lenght = ""
spaces2 = " " * 15
script, category = page_scripts[index]
script_number = (page_number - 1) * entries_per_page + index + 1
entry_number = f"{current_theme['primary']}{script_number}{current_theme['reset']}"
entry_script = f"{current_theme['secondary']}{script}{current_theme['reset']}"
entry_category = f"{current_theme['primary']}({category.title()}){current_theme['reset']}"
total_length = calculate_total_length(entry_number, entry_script, entry_category)
spaces_to_add = total_length - line_width
spaces = ""
if spaces_to_add < 0:
spaces = " " * abs(spaces_to_add)
elif spaces_to_add > 0:
spaces2 = spaces2[:-spaces_to_add]
if j == 0:
line += f" {entry_number} {entry_script} {entry_category}{spaces}{spaces2}"
elif j == 1:
line += f"{entry_number} {entry_script} {entry_category}{spaces}{spaces2}"
else:
line += f"{entry_number} {entry_script} {entry_category}"
else:
line += " " * line_width
art += line + "\n"
if art.endswith("\n"):
art = art[:-1]
art += f"""
{current_theme["primary"]}{bar}
Page : {current_theme['reset']}{current_theme["secondary"]}{page_number}{current_theme['reset']}{current_theme["primary"]}-{current_theme['reset']}{current_theme["secondary"]}{total_pages}{current_theme['reset']}{current_theme["primary"]}
{bar}{current_theme["reset"]}\n"""
art += f" "
if page_number > 1:
art += f"\t\t {current_theme['primary']}<{current_theme['reset']} {current_theme['secondary']}Prev{current_theme['reset']} "
art += f"\t\t\t{current_theme['primary']}={current_theme['reset']} {current_theme['secondary']}Theme{current_theme['reset']}\t\t\t {current_theme['primary']}?{current_theme['reset']} {current_theme['secondary']}Info{current_theme['reset']}\t\t"
if page_number < total_pages:
art += f" {current_theme['primary']}>{current_theme['reset']} {current_theme['secondary']}Next{current_theme['reset']}"
animated_text(art, delay=0)
def execute_script(script_name):
try:
if "utils" in script_name:
script_path = script_name
else:
script_path = os.path.join('utils', script_name)
subprocess.run([sys.executable, script_path], check=True)
except subprocess.CalledProcessError as e:
print(f"An error occurred while running the script {script_path}: {e}")
def display_icon(icon_text):
icon_lines = icon_text.splitlines()
total_lines = len(icon_lines)
display_time = 1.5
interval = display_time / total_lines
for line in icon_lines:
animated_text(Colors.green + line + Colors.reset + "\n", delay=0.01)
time.sleep(interval)
def blink_warning_centered():
Cursor.HideCursor()
ascii_art = """
██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████
"""
orange_text = Colors.orange + ascii_art + Colors.reset
text_width = max(len(line) for line in ascii_art.splitlines())
text_height = len(ascii_art.splitlines())
with term.cbreak(), term.hidden_cursor():
x = (term.width // 2) - (text_width // 2)
y = (term.height // 2) - (text_height // 2)
for _ in range(4):
for i, line in enumerate(orange_text.splitlines()):
print(term.move_xy(x, y + i) + line, end='', flush=True)
time.sleep(0.25)
for i in range(text_height):
print(term.move_xy(x, y + i) + ' ' * text_width, end='', flush=True)
time.sleep(0.25)
print(term.clear(), end='', flush=True)
print(term.move_xy(0, 0), end='', flush=True)
def warning_animation():
icon_text = f"""
____
/___/\_
_\ \/_/\__
__\ \/_/\
\ __ __ \ \
__\ \_\ \_\ \ \ __
/_/\\ __ __ \ \_/_/\
\_\/_\__\/\__\/\__\/_\_\/
\_\/_/\ /_\_\/
\_\/ \_\/
"""
warning_message = """The use of these tools can have significant
risks and consequences. By using this software, you
agree that we are not responsible for any damage or
issues that may arise from the use of these tools.
Please use responsibly and at your own risk.
"""
blink_warning_centered()
combined_message = Add.Add(icon_text, warning_message, 3)
Write.Print(Center.Center(combined_message),get_current_theme()['primary'], interval=0.0025)
Write.Input("Press Enter to continue...", get_current_theme()['fade'], interval=0.1)
def main():
clear()
current_theme = get_current_theme()
warning_animation()
username = os.getlogin()
scripts = get_scripts()
tools_info = read_tools_info('utils/tools.json')
page_size = 30
total_pages = (len(scripts) + page_size - 1) // page_size
current_page = 1
while True:
clear()
current_theme = get_current_theme()
page_scripts = scripts[(current_page-1)*page_size:current_page*page_size]
display_ascii_art(page_scripts, current_page, total_pages, tools_info, current_theme)
prompt = f"""
{current_theme["primary"]}╭─── {current_theme["secondary"]}{username}@Atom
{current_theme["primary"]}│
{current_theme["primary"]}╰─$ {current_theme["reset"]} """
Cursor.ShowCursor()
if os.name == 'nt':
choice = get_choice_windows(prompt)
else:
choice = get_choice_unix(prompt)
if choice.isdigit():
script_index = int(choice) - 1
if 0 <= script_index < len(page_scripts):
script_name, category = page_scripts[script_index]
script_path = os.path.join('utils', category, script_name.replace(' ', '_').lower() + '.py')
execute_script(script_path)
elif choice == '?':
execute_script("tools_info.py")
elif choice == '=':
execute_script("theme_page.py")
elif choice == ':':
print("\nAvailable themes:")
for i, theme_name in enumerate(themes.keys(), 1):
print(f"{themes[theme_name]['primary']}{i}. {theme_name}{themes[theme_name]['reset']}")
theme_choice = input("Choose a theme by number: ").strip()
theme_names = list(themes.keys())
try:
theme_index = int(theme_choice) - 1
if 0 <= theme_index < len(theme_names):
set_theme(theme_names[theme_index])
clear()
else:
print(f"{get_current_theme()['primary']}Invalid choice. No theme changed.{get_current_theme()['reset']}")
except ValueError:
print(f"{get_current_theme()['primary']}Invalid input. Please enter a number.{get_current_theme()['reset']}")
elif choice == 'next' and current_page < total_pages:
Cursor.HideCursor()
clear()
display_ascii_art(page_scripts, current_page, total_pages, tools_info, current_theme)
Cursor.ShowCursor()
current_page += 1
elif choice == 'prev' and current_page > 1:
Cursor.HideCursor()
clear()
display_ascii_art(page_scripts, current_page, total_pages, tools_info, current_theme)
Cursor.ShowCursor()
current_page -= 1
elif choice == 'exit':
print('\n')
break
else:
print(f"\n{get_current_theme()['primary']}Invalid choice. Please try again.{get_current_theme()['reset']}")
time.sleep(0.5)
if __name__ == "__main__":
main()