# riteshkumar1205/ethical-keylogger-lab architecture

> Architecture diagram of the GitHub repository riteshkumar1205/ethical-keylogger-lab, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/riteshkumar1205/ethical-keylogger-lab
- Repository: https://github.com/riteshkumar1205/ethical-keylogger-lab

## Overview

##### Main Components
a. Consent & Configuration Loader
- Reads environment variables (SENDER_EMAIL, EMAIL_PASSWORD, RECEIVER_EMAIL)
- Presents the user-consent prompt
b. Input Monitors
- Keystroke Logger (pynput)
- Clipboard Monitor (clipboard)
- Screenshot Capturer (mss or scrot)
- Active Window Tracker (xdotool via subprocess or python wrapper)
c. Data Collector
- System Info Collector (username, IP addresses, timestamp)
- Batch Aggregator / Scheduler (handles intervals, batch sizes)
d. Security & Integrity
- AES Encryption Module (cryptography.Fernet)
- SHA256 Hashing for log integrity
e. Storage & Reporting
- Local Log Store (file system path, sample Output.pdf)
- Email Reporter (SMTP client via requests or smtplib)
f. Audit Logger
- Maintains its local audit trail for compliance

##### Relationships & Data Flows
- Startup: Configuration Loader → Consent Prompt
- Upon “Consent Granted”:
– Input Monitors → Data Collector → Security & Integrity
– Encrypted Output → either Local Store or Email Reporter
- Email Reporter → External SMTP Server → Receiver’s Inbox
- Audit Logger subscribes to all high-level events (consent, batch send, errors)

##### Architectural Patterns
– Modular Monolith: separate Python classes/modules for each concern
– Pipeline/Publisher‐Subscriber: monitors publish events → collector subscribes
– Single Responsibility: each component does one job (monitoring, encrypting, sending)

##### Key Technologies & Libraries
– Python 3.x
– pynput (keystrokes), clipboard, mss/scrot (screenshots)
– cryptography.Fernet (AES)
– hashlib (SHA256)
– smtplib or requests (email)
– xdotool (active window title)
– pytest or unittest (test_logger.py)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Ethical Keylogger"
        direction TB
        ConfigConsent["Config & Consent Loader"]:::config
        InputMonitors["Input Monitors\n• Keystroke Logger\n• Clipboard Monitor\n• Screenshot Capturer\n• Active Window Tracker"]:::input
        DataCollector["Data Collector\n• System Info Collector\n• Batch Aggregator"]:::input
        SecurityIntegrity["Security & Integrity\n• AES Encryption (Fernet)\n• SHA256 Hashing"]:::security
        subgraph "Storage & Reporting"
            direction TB
            LocalStore["Local Log Store"]:::storage
            EmailReporter["Email Reporter"]:::storage
        end
    end

    ConfigConsent -->|"config loaded & consent"| InputMonitors
    InputMonitors -->|"raw events"| DataCollector
    DataCollector -->|"batched payload"| SecurityIntegrity
    SecurityIntegrity -->|"AES-encrypted payload"| LocalStore
    SecurityIntegrity -->|"AES-encrypted payload"| EmailReporter
    LocalStore -->|"store file"| ExternalFS
    EmailReporter -->|"SMTP Send"| SMTPServer

    AuditLogger["Audit Logger"]:::config
    AuditLogger -.-> ConfigConsent
    AuditLogger -.-> InputMonitors
    AuditLogger -.-> DataCollector
    AuditLogger -.-> SecurityIntegrity
    AuditLogger -.-> LocalStore
    AuditLogger -.-> EmailReporter

    ExternalFS["Local File System"]:::external
    SMTPServer["External SMTP Server"]:::external

    subgraph "Supporting Files"
        direction TB
        Tests["Tests (Logging & Audit)"]:::config
        Dependencies["Dependencies (requirements.txt)"]:::config
        CLIEntry["CLI Entry Point\n(setup.py, README.md)"]:::config
        LicenseNode["LICENSE"]:::config
    end

    classDef input fill:#ADD8E6,stroke:#000;
    classDef security fill:#90EE90,stroke:#000;
    classDef storage fill:#FFA500,stroke:#000;
    classDef external fill:#D3D3D3,stroke:#000;
    classDef config fill:#E0E0E0,stroke:#000;

    click ConfigConsent "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/keyloggers_2025.py"
    click InputMonitors "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/keyloggers_2025.py"
    click DataCollector "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/keyloggers_2025.py"
    click SecurityIntegrity "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/keyloggers_2025.py"
    click LocalStore "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/sample Output.pdf"
    click EmailReporter "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/keyloggers_2025.py"
    click AuditLogger "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/keyloggers_2025.py"
    click Tests "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/test_logger.py"
    click Dependencies "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/requirements.txt"
    click CLIEntry "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/setup.py"
    click CLIEntry "https://github.com/riteshkumar1205/ethical-keylogger-lab/blob/main/README.md"
    click LicenseNode "https://github.com/riteshkumar1205/ethical-keylogger-lab/tree/main/LICENSE"
```
