USB Tracker Shield πŸ›‘️ – Real-Time Cybersecurity Tool Made in Python (CustomTkinter GUI)

 Demo :


Click Video πŸ‘‡πŸ‘‡πŸ‘‡



















🌟 Features:

  • Real-time USB detection

  • Detect insert/removal events

  • Simple GUI with status logs

  • Lightweight, runs in background

  • Perfect for cybersec beginners


Code :


import customtkinter as ctk

import psutil

import time

import threading


# ----------- GUI SETUP ----------------

ctk.set_appearance_mode("dark")

ctk.set_default_color_theme("green")


class USBTrackerShield(ctk.CTk):

    def __init__(self):

        super().__init__()

        self.title("USB Tracker Shield - Cybersecurity Tool")

        self.geometry("520x400")

        self.resizable(False, False)


        # Title Label

        self.label = ctk.CTkLabel(self, text="πŸ›‘️ USB Tracker Shield", font=("Roboto", 20, "bold"))

        self.label.pack(pady=15)


        # Log Display Box

        self.log_box = ctk.CTkTextbox(self, width=480, height=230)

        self.log_box.pack(pady=10)

        self.log_box.insert("end", "πŸ” Monitoring USB devices in real-time...\n")


        # Status Bar

        self.status = ctk.CTkLabel(self, text="Status: Running", font=("Roboto", 14))

        self.status.pack(pady=5)


        # Start USB Monitor Thread

        self.prev_devices = self.get_usb_devices()

        threading.Thread(target=self.monitor_usb, daemon=True).start()


    def get_usb_devices(self):

        return [d.device for d in psutil.disk_partitions() if 'removable' in d.opts or 'cdrom' in d.opts]


    def log_event(self, msg):

        timestamp = time.strftime("[%H:%M:%S]")

        self.log_box.insert("end", f"{timestamp} {msg}\n")

        self.log_box.see("end")


    def monitor_usb(self):

        while True:

            current_devices = self.get_usb_devices()

            added = set(current_devices) - set(self.prev_devices)

            removed = set(self.prev_devices) - set(current_devices)


            for dev in added:

                self.log_event(f"πŸ”Œ USB Inserted: {dev}")

            for dev in removed:

                self.log_event(f"⚠️ USB Removed: {dev}")


            self.prev_devices = current_devices

            time.sleep(2)


if __name__ == "__main__":

    app = USBTrackerShield()

    app.mainloop()

Comments

Popular posts from this blog

πŸš€ Simple Login & Registration System in Python Tkinter πŸ“±

πŸš€ Create a Python Screen Recorder with Audio (Complete Code)

πŸ“‘ Fuzzu Packet Sniffer – Python GUI for Real-Time IP Monitoring | Tkinter + Scapy