This is a simple Linux kernel module that logs USB device connection and removal events. It logs the device name and the date when a USB device is plugged in or removed from the system. The log is saved to a specified file, and the module uses the kernel's USB notification system to capture the device events.
- Logs USB device connection and removal events.
- Logs the device name and the date of the event.
- Writes log messages to a specified file (
/home/<yourusername>/usblog.txt). - Supports the following USB device types: USB HID and USB storage devices.
- A Linux system with kernel headers installed.
- A kernel that supports the USB subsystem.
Clone this repository to your local machine:
git clone https://github.com/by3lish/usblogmaster.git
cd usb-loggerBefore building the module, make sure you have the necessary kernel headers installed. On Debian-based systems, you can install them using:
sudo apt-get install linux-headers-$(uname -r)To build the module, simply run:
makeAfter the module is built, you can install it by running:
sudo make installThis will load the kernel module using insmod.
To remove the module from the system:
sudo make uninstallThis will unload the module using rmmod.
Once the module is loaded, it will begin logging USB device events to the log file located at /home/<yourusername>/usblog.txt.
The log entries will look like this:
Device Plugged In: Name='USB Storage Device', Type='USB', Date='01.12.2024'
Device Removed: Name='USB Storage Device'
Make sure to change the LOG_FILE_PATH in the source code to your desired location for the log file.
The Makefile includes the following targets:
- all: Builds the kernel module.
- clean: Cleans up build artifacts.
- install: Installs (loads) the module.
- uninstall: Uninstalls (removes) the module.
This project is licensed under the GPL-2.0 License - see the LICENSE file for details.