-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
191 lines (149 loc) · 4.71 KB
/
Copy pathmain.py
File metadata and controls
191 lines (149 loc) · 4.71 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
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
import customtkinter as ctk
from tkinter import filedialog
from scanner import scan_file
import threading
import time
# ================= CONFIG ================= #
ctk.set_appearance_mode("dark")
ctk.set_default_color_theme("green")
app = ctk.CTk()
app.geometry("1200x700")
app.title("Malware Detection Simulator")
selected_file = ""
# ================= COLORS ================= #
BG = "#0b0f19"
CARD = "#111827"
ACCENT = "#00ff9f"
TEXT = "#e5e7eb"
MUTED = "#9ca3af"
RED = "#ff4d4d"
YELLOW = "#facc15"
app.configure(fg_color=BG)
# ================= FUNCTIONS ================= #
def choose_file():
global selected_file
file_path = filedialog.askopenfilename()
if file_path:
selected_file = file_path
file_label.configure(text=file_path)
def fake_scan():
progress_bar.set(0)
for i in range(101):
time.sleep(0.01)
progress_bar.set(i/100)
percent_label.configure(text=f"{i}%")
def start_scan():
if not selected_file:
result_box.configure(state="normal")
result_box.delete("1.0", "end")
result_box.insert("end", "Select a file first.")
result_box.configure(state="disabled")
return
status_label.configure(text="Scanning...", text_color=YELLOW)
fake_scan()
result = scan_file(selected_file)
result_box.configure(state="normal")
result_box.delete("1.0", "end")
result_box.insert("end", result)
result_box.configure(state="disabled")
if "HIGH" in result:
threat_label.configure(text="HIGH RISK", text_color=RED)
status_label.configure(text="Danger Detected", text_color=RED)
elif "MEDIUM" in result:
threat_label.configure(text="MEDIUM RISK", text_color=YELLOW)
status_label.configure(text="Suspicious File", text_color=YELLOW)
else:
threat_label.configure(text="LOW RISK", text_color=ACCENT)
status_label.configure(text="System Safe", text_color=ACCENT)
# ================= GRID LAYOUT ================= #
app.grid_columnconfigure(0, weight=1)
app.grid_columnconfigure(1, weight=3)
app.grid_rowconfigure(0, weight=1)
# ================= SIDEBAR ================= #
sidebar = ctk.CTkFrame(app, fg_color=CARD, corner_radius=0)
sidebar.grid(row=0, column=0, sticky="nsew")
title = ctk.CTkLabel(
sidebar,
text="CAN I HACK IT?",
font=("Arial", 22, "bold"),
text_color=ACCENT
)
title.pack(pady=30)
select_btn = ctk.CTkButton(
sidebar,
text="Select File",
command=choose_file,
fg_color=ACCENT,
text_color="black",
height=45
)
select_btn.pack(pady=10, padx=20, fill="x")
scan_btn = ctk.CTkButton(
sidebar,
text="Start Scan",
command=lambda: threading.Thread(target=start_scan).start(),
fg_color="#1f2937",
border_color=ACCENT,
border_width=1,
height=45
)
scan_btn.pack(pady=10, padx=20, fill="x")
status_label = ctk.CTkLabel(
sidebar,
text="Ready",
text_color=ACCENT,
font=("Arial", 16, "bold")
)
status_label.pack(pady=40)
# ================= MAIN AREA ================= #
main = ctk.CTkFrame(app, fg_color=BG)
main.grid(row=0, column=1, sticky="nsew", padx=20, pady=20)
main.grid_columnconfigure(0, weight=2)
main.grid_columnconfigure(1, weight=1)
main.grid_rowconfigure(1, weight=1)
# ================= TOP CARD ================= #
top_card = ctk.CTkFrame(main, fg_color=CARD, corner_radius=15)
top_card.grid(row=0, column=0, columnspan=2, sticky="nsew", pady=(0, 15))
file_label = ctk.CTkLabel(
top_card,
text="No file selected",
text_color=MUTED,
font=("Consolas", 13)
)
file_label.pack(pady=15)
# ================= LEFT: RESULTS ================= #
result_card = ctk.CTkFrame(main, fg_color=CARD, corner_radius=15)
result_card.grid(row=1, column=0, sticky="nsew", padx=(0, 10))
result_box = ctk.CTkTextbox(
result_card,
fg_color="#0d1320",
text_color=ACCENT,
font=("Consolas", 13)
)
result_box.pack(fill="both", expand=True, padx=10, pady=10)
result_box.configure(state="disabled")
# ================= RIGHT: THREAT PANEL ================= #
right_card = ctk.CTkFrame(main, fg_color=CARD, corner_radius=15)
right_card.grid(row=1, column=1, sticky="nsew")
threat_label = ctk.CTkLabel(
right_card,
text="NO THREAT",
font=("Arial", 26, "bold"),
text_color=ACCENT
)
threat_label.pack(pady=40)
progress_bar = ctk.CTkProgressBar(
right_card,
width=200,
progress_color=ACCENT
)
progress_bar.pack(pady=20)
progress_bar.set(0)
percent_label = ctk.CTkLabel(
right_card,
text="0%",
text_color=MUTED,
font=("Arial", 14)
)
percent_label.pack()
app.mainloop()