# Udev rules for Proxmark3 device detection and permissions
# Place this file in /etc/udev/rules.d/

# Proxmark3 RDV4 and Easy (VID 0x9ac4, PID 0x4b8f)
SUBSYSTEM=="usb", ATTRS{idVendor}=="9ac4", ATTRS{idProduct}=="4b8f", MODE="0666", GROUP="plugdev", TAG+="uaccess", ENV{DANGEROUS_PI_PM3}="1"

# Proxmark3 Easy alternate (VID 0x502d, PID 0x502d)
SUBSYSTEM=="usb", ATTRS{idVendor}=="502d", ATTRS{idProduct}=="502d", MODE="0666", GROUP="plugdev", TAG+="uaccess", ENV{DANGEROUS_PI_PM3}="1"

# Proxmark3 CDC ACM (communication device class)
SUBSYSTEM=="tty", ATTRS{idVendor}=="9ac4", ATTRS{idProduct}=="4b8f", MODE="0666", GROUP="plugdev", SYMLINK+="proxmark3-%n", ENV{DANGEROUS_PI_PM3}="1"
SUBSYSTEM=="tty", ATTRS{idVendor}=="502d", ATTRS{idProduct}=="502d", MODE="0666", GROUP="plugdev", SYMLINK+="proxmark3-%n", ENV{DANGEROUS_PI_PM3}="1"

# Proxmark3 in bootloader mode (may have different PID)
SUBSYSTEM=="usb", ATTRS{idVendor}=="2d0d", MODE="0666", GROUP="plugdev", TAG+="uaccess", ENV{DANGEROUS_PI_PM3_BOOTLOADER}="1"

# Notify systemd or custom scripts on device add/remove
ACTION=="add", ENV{DANGEROUS_PI_PM3}=="1", RUN+="/usr/bin/logger 'Proxmark3 device connected: $devpath'"
ACTION=="remove", ENV{DANGEROUS_PI_PM3}=="1", RUN+="/usr/bin/logger 'Proxmark3 device disconnected: $devpath'"
