A simple keylogger in Python that records keystrokes, saves them to a file, and sends the log as an email attachment using SendGrid.
- Captures all keystrokes (alphanumeric and special keys).
- Saves keystrokes to a timestamped file in a
filesdirectory. - Sends the log file as an email attachment via SendGrid after execution.
- Uses environment variables for sensitive data (API keys and email addresses).
- Python 3.x
- The following Python packages:
pynputpython-dotenvsendgrid
- A
.envfile with SendGrid API credentials and email addresses.
-
Clone the repository:
git clone https://github.com/alihassancods/keylogger-python.git cd keylogger-python -
Install dependencies:
pip install pynput python-dotenv sendgrid
-
Create a
.envfile in the repository root with the following variables:SENDGRID_API_KEY=your_sendgrid_api_key [email protected] [email protected] -
Create a
filesdirectory to store log files:mkdir files
Run the keylogger script:
python main.py- The script will start listening for keystrokes.
- To stop logging, press the
Esckey. - After stopping, the script will email the keystroke log file as an attachment.
- The
Keyloggerclass listens for keyboard events. - Each keystroke is appended to a file named with the current date and time.
- When stopped, the script encodes the log file and sends it via SendGrid.
- Email addresses and API keys are securely loaded from the
.envfile.
This tool is intended for educational purposes only. Do not use it to log keystrokes without the user's explicit consent. Unauthorized use may violate local laws and ethical guidelines.