Skip to main content

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

  1. 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'])
  1. Keyboard Monitoring:
from keystroke_sim import KeyboardMonitor

# Initialize monitor
monitor = KeyboardMonitor()

# Start monitoring
monitor.start()
  1. 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

  1. User Profiling

    • Collect sufficient training data
    • Update profiles periodically
    • Monitor profile consistency
  2. Threat Detection

    • Adjust sensitivity based on security needs
    • Review security reports regularly
    • Investigate alerts promptly
  3. Data Protection

    • Always use encryption for sensitive data
    • Secure encryption keys properly
    • Regular security audits
  4. 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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests: python -m pytest tests/
  5. Submit a pull request

Support

For issues, questions, or contributions:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keystroke_sim-0.3.0.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keystroke_sim-0.3.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

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

Hashes for keystroke_sim-0.3.0.tar.gz
Algorithm Hash digest
SHA256 b77d52ffcecd4ab8298cab8f7d250e2e7034e73ece8c97c525e42ff079d5f226
MD5 58e7adf2c25e7f6c9a9555bde813ab33
BLAKE2b-256 ec5010171be683c91e9d0c1b942d1f5fb2ccb1b1caf706f63cb61b9e48d3b89b

See more details on using hashes here.

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

Hashes for keystroke_sim-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01c06a66277deba6cbb03b0b36b3495ddb81d3e8096057d0a40bbef54d3539fd
MD5 adeb807ee3fa0ab6520a5ee32e6c84f9
BLAKE2b-256 4427fa236689529226857b78bd7d72c1453b491c2be83fb71fb71eee36b5b0e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page