From e96f4761215bba5f3147238a2ea857e558e20f06 Mon Sep 17 00:00:00 2001 From: 7ka1 <7ka1@noreply.localhost> Date: Thu, 19 Mar 2026 13:39:31 +0000 Subject: [PATCH] Actualiser 7lna.py --- 7lna.py | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/7lna.py b/7lna.py index b3cc214..8992d21 100644 --- a/7lna.py +++ b/7lna.py @@ -62,6 +62,7 @@ class Antivirus7LnA(ctk.CTk): self.shield_observer = None self.shield_active = False + self.zero_usb_mode = False # <--- AJOUT : État du mode Zero USB self.check_dependencies() self.setup_ui() @@ -157,11 +158,17 @@ class Antivirus7LnA(ctk.CTk): known_mounts = current_mounts except: pass + # <--- MODIFICATION : Logique Zero USB intégrée def prompt_usb_scan(self, path, name): - send_desktop_notification("USB Détectée", f"Disque {name} branché.") - if messagebox.askyesno("Protection USB", f"Nouveau périphérique USB détecté :\n{name}\n\nVoulez-vous l'analyser ?"): + if self.zero_usb_mode: + send_desktop_notification("⚡ Zero USB Actif", f"Analyse automatique forcée pour : {name}", is_critical=True) self.select_view("scanner") threading.Thread(target=self.run_clamav_scan, args=(path, True, self.scan_console), daemon=True).start() + else: + send_desktop_notification("USB Détectée", f"Disque {name} branché.") + if messagebox.askyesno("Protection USB", f"Nouveau périphérique USB détecté :\n{name}\n\nVoulez-vous l'analyser ?"): + self.select_view("scanner") + threading.Thread(target=self.run_clamav_scan, args=(path, True, self.scan_console), daemon=True).start() # --- VUE : TABLEAU DE BORD --- def init_dashboard_view(self): @@ -179,6 +186,19 @@ class Antivirus7LnA(ctk.CTk): sys_info = f"🖥️ OS : {platform.system()} {platform.release()} | 👤 Compte : {os.getlogin()}" ctk.CTkLabel(sys_frame, text=sys_info, font=ctk.CTkFont(size=16, weight="bold")).pack(padx=20, pady=10, anchor="w") + # <--- AJOUT : Switch pour activer/désactiver le Mode Zero USB + self.zero_usb_switch = ctk.CTkSwitch(frame, text="🛡️ Mode Zero USB (Scan auto des clés USB)", + command=self.toggle_zero_usb, + font=ctk.CTkFont(size=16, weight="bold"), + progress_color="#DC2626") # Rouge pour indiquer un mode "agressif" + self.zero_usb_switch.pack(pady=20, anchor="w", padx=20) + + # <--- AJOUT : Fonction de bascule pour le Switch + def toggle_zero_usb(self): + self.zero_usb_mode = self.zero_usb_switch.get() + etat = "ACTIVÉ" if self.zero_usb_mode else "DÉSACTIVÉ" + send_desktop_notification("Paramètre de Sécurité", f"Mode Zero USB {etat}") + # --- FONCTION D'AUTHENTIFICATION GLOBALE --- def get_sudo_password(self, callback_func, title="Sécurité Administrateur", msg="Privilèges requis pour cette action.\nEntrez votre mot de passe session :"): dialog = ctk.CTkToplevel(self) @@ -415,7 +435,6 @@ class Antivirus7LnA(ctk.CTk): return try: - # Utilisation de stdbuf ou bufsize pour forcer l'affichage ligne par ligne sans lag cmd = ['sudo', '-S', 'arp-scan', '--localnet', '--ignoredups'] process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1) @@ -424,7 +443,6 @@ class Antivirus7LnA(ctk.CTk): count = 0 for line in iter(process.stdout.readline, ''): - # On filtre les lignes inutiles (warnings de fichiers ou headers techniques) if any(x in line.lower() for x in ["permission denied", "starting arp-scan", "packets received", "ending arp-scan", "[sudo]"]): continue @@ -432,7 +450,6 @@ class Antivirus7LnA(ctk.CTk): self.audit_console.insert("end", f"{self.get_time_prefix()}[-] Mot de passe refusé.\n", "danger") break - # Si la ligne contient une IP (format x.x.x.x) if line.strip() and (line[0].isdigit()): self.audit_console.insert("end", f" 📱 Appareil trouvé : {line.strip()}\n", "success") count += 1 @@ -442,7 +459,7 @@ class Antivirus7LnA(ctk.CTk): process.wait() self.audit_console.insert("end", f"\n{self.get_time_prefix()}[+] Scan terminé. {count} appareils détectés sur votre WiFi.\n", "info") - if count > 15: # Seuil d'alerte arbitraire + if count > 15: send_desktop_notification("WiFi Guard", f"Attention : Beaucoup d'appareils ({count}) sont connectés à votre réseau.", is_critical=True) except Exception as e: