-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlock_overlay.py
More file actions
438 lines (366 loc) Β· 20 KB
/
Copy pathlock_overlay.py
File metadata and controls
438 lines (366 loc) Β· 20 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
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
"""
lock_overlay.py β Terminal-style security lock overlay.
Four live panels:
βΈ TERMINAL SESSION β shell commands executing in real time
βΈ PACKET CAPTURE β network traffic being dropped packet by packet
βΈ MEMORY MAP β memory pages being wiped row by row
βΈ PYTHON REPL β encryption code typing itself out
Run with --preview to skip the actual workstation lock.
"""
import tkinter as tk
import random
import subprocess
import sys
from datetime import datetime
PREVIEW = "--preview" in sys.argv
# ββ palette βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
BG = "#000000"
GREEN = "#00FF41"
DKGRN = "#00CC33"
MGRN = "#009922"
DIMGRN = "#005511"
BORDER = "#007722"
DIM = "#003308"
RED = "#FF0000"
DKRED = "#AA0000"
YELLOW = "#CCCC00"
MONO = "Courier New"
HOST = "WORKSTATION"
def _ts():
n = datetime.now()
return n.strftime("%H:%M:%S.") + f"{n.microsecond // 1000:03d}"
def _hex(n):
return "".join(f"{random.randint(0, 15):X}" for _ in range(n))
def _pid():
return random.randint(1000, 9999)
# ββ static values generated once so they stay consistent across frames ββββββββ
_SESSION_KEY = _hex(16)
_SESSION_ID = _hex(8).upper()
_IP = f"192.168.{random.randint(1,5)}.{random.randint(10,200)}"
_HASH32 = _hex(32).lower()
# ββ terminal script: (tick_to_show, text, color_tag) βββββββββββββββββββββββββ
TERM_SCRIPT = [
(0, f"ββ[root@{HOST}]β[~]\n", "prompt"),
(1, f"ββββΌ ", "prompt"),
(2, "systemctl stop NetworkManager\n", "cmd"),
(6, " Stopping Network Manager...\n", "dim"),
(9, "[ OK ] NetworkManager.service stopped.\n", "ok"),
(13, f"ββ[root@{HOST}]β[~]\n", "prompt"),
(14, f"ββββΌ ", "prompt"),
(15, "iptables -F && iptables -X\n", "cmd"),
(18, "iptables -P INPUT DROP\n", "cmd"),
(21, "iptables -P OUTPUT DROP\n", "cmd"),
(24, "[ OK ] All traffic: BLOCKED\n", "ok"),
(28, f"ββ[root@{HOST}]β[~]\n", "prompt"),
(29, f"ββββΌ ", "prompt"),
(30, f"pkill -9 -u {HOST}\n", "cmd"),
(33, f" killed {_pid()} chrome.exe\n", "kill"),
(35, f" killed {_pid()} msedge.exe\n", "kill"),
(37, f" killed {_pid()} OneDrive.exe\n", "kill"),
(39, f" killed {_pid()} SearchHost.exe\n", "kill"),
(41, f" killed {_pid()} sihost.exe\n", "kill"),
(43, f" 23 processes terminated.\n", "ok"),
(47, f"ββ[root@{HOST}]β[~]\n", "prompt"),
(48, f"ββββΌ ", "prompt"),
(49, "python3 /opt/lockd/seal_session.py\n", "cmd"),
(53, f" [lockd] gen key AES-256-GCM\n", "muted"),
(56, f" [lockd] key {_SESSION_KEY[:8]}...{_SESSION_KEY[-4:]} (TPM-sealed)\n", "muted"),
(59, f" [lockd] sealing 4096 memory pages\n", "muted"),
(62, f" [lockd] zeroing swap + credential store\n", "muted"),
(65, f" [lockd] hash SHA-256:{_HASH32[:16]}...\n","muted"),
(68, f" [lockd] done session sealed β\n", "ok"),
(72, f"ββ[root@{HOST}]β[~]\n", "prompt"),
(73, f"ββββΌ ", "prompt"),
(74, "loginctl lock-sessions && exit\n", "cmd"),
(79, "\n *** SESSION TERMINATED ***\n\n", "warn"),
]
PACKETS = [
(_IP, "8.8.8.8", "DNS", 53, "DROP"),
(_IP, "93.184.216.34", "HTTPS", 443, "RST "),
(_IP, "1.1.1.1", "DNS", 53, "DROP"),
("192.168.1.1", _IP, "ARP", 0, "DROP"),
(_IP, "52.96.29.17", "HTTPS", 443, "RST "),
("ff02::1", _IP, "ICMPv6",0, "DROP"),
(_IP, "10.0.0.1", "SSH", 22, "RST "),
(_IP, "172.217.3.110", "HTTPS", 443, "DROP"),
]
# memory base addresses
MEM_ADDRS = [f"0x7FFE{i:04X}000" for i in range(8)]
CODE_LINES = [
(">>> ", "repl"),
(">>> import os, hashlib, gc\n", "code"),
(">>> from Crypto.Cipher import AES\n", "code"),
(">>> from Crypto.Random import get_random_bytes\n", "code"),
(">>> \n", "repl"),
(">>> # generate ephemeral lock key\n", "comment"),
(">>> salt = get_random_bytes(32)\n", "code"),
(">>> key = hashlib.pbkdf2_hmac(\n", "code"),
("... 'sha256', os.urandom(32), salt, 100_000)\n", "code"),
(">>> nonce = get_random_bytes(16)\n", "code"),
(">>> cipher = AES.new(key, AES.MODE_GCM, nonce=nonce)\n", "code"),
(">>> ct, tag = cipher.encrypt_and_digest(session_data)\n", "code"),
(f">>> print(ct.hex()[:32])\n", "code"),
(f"{_hex(32).lower()}\n", "out"),
(">>> key = bytes(len(key)); del cipher, ct, tag\n", "code"),
(">>> gc.collect()\n", "code"),
("0\n", "out"),
(">>> # memory cleared.\n", "comment"),
]
class LockOverlay:
def __init__(self):
self.root = tk.Tk()
self.root.configure(bg=BG)
self.root.attributes("-fullscreen", True)
self.root.attributes("-topmost", True)
self.root.overrideredirect(True)
self.root.config(cursor="none")
if PREVIEW:
self.root.bind("<Escape>", lambda e: self.root.destroy())
self.root.update()
W, H = self.root.winfo_width(), self.root.winfo_height()
self.W, self.H = W, H
self.fs = max(10, W // 165)
# animation state β must come before _build_ui() which calls _render_mem_map()
self.tick = 0
self.phase = 0
self._term_idx = 0
self._pkt_i = 0
self._pkt_total = 0
self._code_i = 0
self._mem_wipe = 0
self._build_ui()
self._mem_wipe = 0 # how many mem rows wiped so far
self._animate()
self.root.mainloop()
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UI construction
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def _build_ui(self):
W, H, fs = self.W, self.H, self.fs
fbold = (MONO, fs, "bold")
fmono = (MONO, fs)
fsmol = (MONO, fs - 1)
# ββ header ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
hdr = tk.Frame(self.root, bg=BG)
hdr.pack(fill=tk.X, padx=10, pady=(8, 3))
self._hdr_title = tk.Label(hdr, text="", font=fbold, fg=GREEN, bg=BG, anchor="w")
self._hdr_title.pack(side=tk.LEFT)
self._hdr_right = tk.Label(hdr, text="", font=fsmol, fg=DIMGRN, bg=BG, anchor="e")
self._hdr_right.pack(side=tk.RIGHT)
tk.Frame(self.root, bg=BORDER, height=1).pack(fill=tk.X, padx=10)
# ββ main area βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
mid = tk.Frame(self.root, bg=BG)
mid.pack(fill=tk.BOTH, expand=True, padx=10, pady=(4, 0))
# left: terminal (58% width)
left = tk.Frame(mid, bg=BG)
left.pack(side=tk.LEFT, fill=tk.BOTH, expand=True)
self._panel_title(left, "βΈ TERMINAL SESSION")
self._term = self._make_text(left, fmono, fill=True, expand=True)
self._term.tag_configure("prompt", foreground=DKGRN, font=fbold)
self._term.tag_configure("cmd", foreground=GREEN, font=fbold)
self._term.tag_configure("ok", foreground=DKGRN)
self._term.tag_configure("kill", foreground=MGRN)
self._term.tag_configure("muted", foreground=MGRN)
self._term.tag_configure("dim", foreground=DIMGRN)
self._term.tag_configure("warn", foreground=YELLOW, font=fbold)
self._term.tag_configure("cursor", foreground=GREEN, font=fbold)
# right column
right = tk.Frame(mid, bg=BG)
right.pack(side=tk.LEFT, fill=tk.BOTH, padx=(8, 0))
# packet capture
self._panel_title(right, "βΈ PACKET CAPTURE [ eth0 ]")
self._pkt = self._make_text(right, fsmol, height=10)
self._pkt.tag_configure("src", foreground=MGRN)
self._pkt.tag_configure("arrow", foreground=DIMGRN)
self._pkt.tag_configure("dst", foreground=DIMGRN)
self._pkt.tag_configure("drop", foreground=DKRED)
self._pkt.tag_configure("rst", foreground=YELLOW)
self._pkt.tag_configure("stat", foreground=DIMGRN)
tk.Frame(right, bg=DIM, height=1).pack(fill=tk.X, pady=2)
# memory map
self._panel_title(right, "βΈ MEMORY MAP [ zeroing pages ]")
self._mem_text = self._make_text(right, fsmol, height=8)
self._mem_text.tag_configure("addr", foreground=MGRN)
self._mem_text.tag_configure("wiped", foreground=DIMGRN)
self._mem_text.tag_configure("active", foreground=GREEN)
self._mem_text.tag_configure("queued", foreground=DIM)
self._render_mem_map() # initial render
# ββ separator βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
tk.Frame(self.root, bg=BORDER, height=1).pack(fill=tk.X, padx=10)
# ββ python repl βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
bot = tk.Frame(self.root, bg=BG)
bot.pack(fill=tk.X, padx=10, pady=(3, 8))
self._panel_title(bot, "βΈ PYTHON 3.12 [seal_session.py]")
self._code = self._make_text(bot, fsmol, height=7)
self._code.tag_configure("repl", foreground=MGRN)
self._code.tag_configure("code", foreground=GREEN)
self._code.tag_configure("comment", foreground=DIMGRN)
self._code.tag_configure("out", foreground=DKGRN)
# ββ ACCESS DENIED overlay (hidden until phase 2) ββββββββββββββββββββββ
self._denied_frame = tk.Frame(self.root, bg=BG)
self._denied_lbl = None # created in _show_denied()
def _panel_title(self, parent, text):
tk.Label(parent, text=f" {text}",
font=(MONO, self.fs - 1, "bold"),
fg=BORDER, bg=BG, anchor="w").pack(fill=tk.X)
def _make_text(self, parent, font, height=None, fill=False, expand=False):
kw = dict(font=font, bg=BG, fg=DIMGRN,
bd=0, highlightthickness=0,
state="disabled", wrap=tk.NONE, insertwidth=0)
if height:
kw["height"] = height
t = tk.Text(parent, **kw)
t.pack(fill=tk.BOTH if fill else tk.X, expand=expand)
return t
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Text helpers
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def _append(self, w, text, tag=""):
w.config(state="normal")
if tag:
w.insert("end", text, tag)
else:
w.insert("end", text)
w.config(state="disabled")
w.see("end")
def _trim(self, w, maxlines=20):
w.config(state="normal")
lines = int(w.index("end-1c").split(".")[0])
if lines > maxlines:
w.delete("1.0", f"{lines - maxlines}.0")
w.config(state="disabled")
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Panel renderers
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def _render_mem_map(self):
w = self._mem_text
w.config(state="normal")
w.delete("1.0", "end")
for i, addr in enumerate(MEM_ADDRS):
size = f"{(i + 1) * 4}KB"
w.insert("end", f" {addr} {size:>6} ", "addr")
if i < self._mem_wipe:
w.insert("end", "ββββββββββββββββ zeroed\n", "wiped")
elif i == self._mem_wipe:
w.insert("end", "ββββββββββββββββ wiping...\n", "active")
else:
w.insert("end", "ββββββββββββββββ mapped\n", "queued")
w.config(state="disabled")
def _add_packet(self):
p = PACKETS[self._pkt_i % len(PACKETS)]
src, dst, proto, dport, action = p
port_str = f":{dport}" if dport else " "
line_ts = _ts()
self._append(self._pkt, f" {line_ts} ", "stat")
self._append(self._pkt, f"{src}", "src")
self._append(self._pkt, f" β {dst}{port_str} {proto:<6} ", "arrow")
tag = "drop" if action == "DROP" else "rst"
self._append(self._pkt, f"{action}\n", tag)
self._trim(self._pkt, 13)
self._pkt_i += 1
self._pkt_total += 1
if self._pkt_total % 8 == 0:
self._append(
self._pkt,
f" ββ {self._pkt_total} blocked / 0 forwarded ββ\n",
"stat"
)
self._trim(self._pkt, 13)
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Animation loop
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def _animate(self):
t = self.tick
self.tick += 1
# ββ header (always) ββββββββββββββββββββββββββββββββββββββββββββββββββ
dot = "β" if t % 8 < 5 else "β"
stat = "RUNNING" if self.phase == 0 else ("SECURED" if self.phase == 1 else "LOCKED")
self._hdr_title.config(
text=f" HACKEROS SECURITY LOCK v4.2.1 {dot} {stat}",
fg=(GREEN if self.phase < 2 else RED)
)
self._hdr_right.config(
text=f"{_ts()} Β· {_IP} Β· TPM 2.0 Β· Session: {_SESSION_ID}"
)
# ββ phase 0: main animation βββββββββββββββββββββββββββββββββββββββββββ
if self.phase == 0:
# β terminal: reveal lines per script timing β
while (self._term_idx < len(TERM_SCRIPT) and
TERM_SCRIPT[self._term_idx][0] <= t):
_, text, tag = TERM_SCRIPT[self._term_idx]
self._append(self._term, text, tag)
self._trim(self._term, 35)
self._term_idx += 1
# blinking cursor after last appended line (only while waiting for next cmd)
# We skip rewriting for simplicity β the content itself sells it.
# β packet capture: one packet every 2 ticks β
if t % 2 == 0:
self._add_packet()
# β memory map: advance wipe every 9 ticks β
if t % 9 == 0 and self._mem_wipe < len(MEM_ADDRS):
self._mem_wipe += 1
self._render_mem_map()
# β python repl: one line every 4 ticks, start at tick 10 β
if t >= 10 and t % 4 == 0 and self._code_i < len(CODE_LINES):
text, tag = CODE_LINES[self._code_i]
self._append(self._code, text, tag)
self._trim(self._code, 9)
self._code_i += 1
# β transition to phase 1 after terminal script finishes β
if self._term_idx >= len(TERM_SCRIPT) and t >= TERM_SCRIPT[-1][0] + 6:
self.phase = 1
self.tick = 0
# ββ phase 1: brief "done" pause ββββββββββββββββββββββββββββββββββββββ
elif self.phase == 1:
if t == 0:
self._append(self._term, "\n[ LOCK ] Integrity hash committed.\n", "ok")
self._append(self._term, "[ LOCK ] System secured. β\n", "ok")
self._append(self._code, ">>> # session sealed.\n", "comment")
if t >= 12:
self.phase = 2
self.tick = 0
self._show_denied()
# ββ phase 2: ACCESS DENIED flash ββββββββββββββββββββββββββββββββββββ
elif self.phase == 2:
if self._denied_lbl:
colors = [RED, DKRED, "#FF2222", "#CC0000", RED, "#FF5555", DKRED]
self._denied_lbl.config(fg=colors[t % len(colors)])
bg_cycle = ["#000000", "#0c0000", "#000000", "#060000"]
self._denied_frame.config(bg=bg_cycle[t % len(bg_cycle)])
if t >= 24:
self._finish()
return
self.root.after(80, self._animate)
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def _show_denied(self):
for w in self.root.winfo_children():
w.pack_forget()
self._denied_frame.pack(fill=tk.BOTH, expand=True)
W, H, fs = self.W, self.H, self.fs
denied_fs = max(36, int(fs * 3.6))
box = tk.Frame(self._denied_frame, bg="#0c0000",
highlightbackground=RED, highlightthickness=2)
box.place(relx=0.5, rely=0.5, anchor="center",
width=int(W * 0.62), height=int(H * 0.44))
self._denied_lbl = tk.Label(
box, text="ACCESS DENIED",
font=(MONO, denied_fs, "bold"),
fg=RED, bg="#0c0000"
)
self._denied_lbl.pack(pady=(30, 10))
tk.Label(box,
text="AUTHENTICATION REQUIRED TO RESUME SESSION",
font=(MONO, fs + 1), fg="#CC0000", bg="#0c0000").pack()
tk.Label(box,
text=f"User: {HOST} Β· Session: {_SESSION_ID} Β· Sealed by TPM 2.0",
font=(MONO, fs - 1), fg=DIMGRN, bg="#0c0000").pack(pady=10)
tk.Frame(box, bg=DKRED, height=1).pack(fill=tk.X, padx=30)
tk.Label(box,
text="[ Enter PIN Β· Fingerprint Β· Smart Card ]",
font=(MONO, fs - 1), fg=DIM, bg="#0c0000").pack(side=tk.BOTTOM, pady=14)
def _finish(self):
self.root.destroy()
if not PREVIEW:
subprocess.Popen(["rundll32.exe", "user32.dll,LockWorkStation"])
if __name__ == "__main__":
LockOverlay()