Cross-platform keyboard input simulation and monitoring with security analysis
Project description
KeystrokeSimulator
A comprehensive Python library for keyboard input simulation, monitoring, and security analysis, developed by Bassem Abidi (abidi.bassem@me.com).
Features
Keystroke Simulation
- 🎯 Cross-platform support (Windows, macOS, Linux)
- ⌨️ Simulate individual keystrokes
- 📝 Type strings with customizable delays
- 🔥 Support for hotkey combinations
- 🔧 Custom keyboard layout definitions
Keyboard Monitoring
- 📊 Real-time keystroke logging
- 📈 Detailed keystroke statistics
- 🔍 Key combination tracking
- 📅 Date-organized logs
- 📊 Usage analytics
Security Features
- 🔐 Keystroke dynamics analysis
- 👤 User behavior profiling
- 🚨 Threat detection
- 🎯 Anomaly detection
- 📋 Security reporting
- 🔒 Encrypted logging
- 📊 Statistical analysis
Quick Start
Installation
pip install keystroke-sim
Basic Usage
- Keystroke Simulation:
from keystroke_sim import KeystrokeSimulator
# Initialize simulator
sim = KeystrokeSimulator()
# Type text
sim.type_string("Hello, World!", delay=0.1)
# Press hotkey
sim.press_hotkey(['ctrl', 'c'])
- Keyboard Monitoring:
from keystroke_sim import KeyboardMonitor
# Initialize monitor
monitor = KeyboardMonitor()
# Start monitoring
monitor.start()
- Security Analysis:
from keystroke_sim.security_analyzer import KeystrokeSecurityAnalyzer
# Initialize with encryption
analyzer = KeystrokeSecurityAnalyzer(encryption_key="your-secret-key")
# Create user profile
analyzer.create_baseline_profile(training_data)
# Monitor for threats
threats = analyzer.detect_threats(current_data)
# Generate security report
report = analyzer.generate_security_report(data)
Security Features in Detail
1. Keystroke Dynamics Analysis
- User typing pattern recognition
- Timing analysis (key press duration, flight time)
- Rhythm consistency measurement
- Pattern deviation detection
2. Threat Detection
# Initialize security components
monitor = KeyboardMonitor()
analyzer = KeystrokeSecurityAnalyzer()
# Configure threat detection
def on_threat(threat):
print(f"Threat detected: {threat['type']}")
print(f"Severity: {threat['severity']}")
print(f"Details: {threat['details']}")
# Start monitoring
monitor.on_threat = on_threat
monitor.start()
3. Security Reports
# Generate comprehensive security report
report = analyzer.generate_security_report(data)
# Report includes:
# - Risk score
# - Detected threats
# - Timing analysis
# - Pattern anomalies
# - Statistical metrics
4. Encrypted Logging
# Initialize with encryption
analyzer = KeystrokeSecurityAnalyzer(encryption_key="your-secret-key")
# Encrypt sensitive data
encrypted_data = analyzer.encrypt_log_data(log_data)
# Decrypt when needed
decrypted_data = analyzer.decrypt_log_data(encrypted_data)
Command Line Interface
Monitor Mode
# Basic monitoring
keystroke-sim monitor
# Advanced security monitoring
keystroke-sim monitor --security --sensitivity 0.8
Simulation Mode
# Type text
keystroke-sim simulate --text "Hello, World!" --delay 0.1
# Press hotkey
keystroke-sim simulate --hotkey ctrl c
Security Best Practices
-
User Profiling
- Collect sufficient training data
- Update profiles periodically
- Monitor profile consistency
-
Threat Detection
- Adjust sensitivity based on security needs
- Review security reports regularly
- Investigate alerts promptly
-
Data Protection
- Always use encryption for sensitive data
- Secure encryption keys properly
- Regular security audits
-
Monitoring
- Set appropriate alert thresholds
- Configure logging levels
- Regular backup of security reports
Advanced Configuration
Security Analyzer Configuration
config = {
'sensitivity': 0.7,
'min_training_data': 1000,
'alert_threshold': 0.8,
'encryption_enabled': True
}
analyzer = KeystrokeSecurityAnalyzer(config=config)
Custom Security Rules
# Define custom threat detection rules
def custom_threat_detector(data):
# Your custom detection logic
return threats
analyzer.add_threat_detector(custom_threat_detector)
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
python -m pytest tests/ - Submit a pull request
Support
For issues, questions, or contributions:
- GitHub Issues: https://github.com/bassemabidi/keystroke_sim/issues
- Email: abidi.bassem@me.com
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Bassem Abidi (abidi.bassem@me.com)
Version History
See CHANGELOG.md for version history and changes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file keystroke_sim-0.3.0.tar.gz.
File metadata
- Download URL: keystroke_sim-0.3.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b77d52ffcecd4ab8298cab8f7d250e2e7034e73ece8c97c525e42ff079d5f226
|
|
| MD5 |
58e7adf2c25e7f6c9a9555bde813ab33
|
|
| BLAKE2b-256 |
ec5010171be683c91e9d0c1b942d1f5fb2ccb1b1caf706f63cb61b9e48d3b89b
|
File details
Details for the file keystroke_sim-0.3.0-py3-none-any.whl.
File metadata
- Download URL: keystroke_sim-0.3.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01c06a66277deba6cbb03b0b36b3495ddb81d3e8096057d0a40bbef54d3539fd
|
|
| MD5 |
adeb807ee3fa0ab6520a5ee32e6c84f9
|
|
| BLAKE2b-256 |
4427fa236689529226857b78bd7d72c1453b491c2be83fb71fb71eee36b5b0e6
|