# juanpardos/pqrevshell architecture

> Architecture diagram of the GitHub repository juanpardos/pqrevshell, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/juanpardos/pqrevshell
- Repository: https://github.com/juanpardos/pqrevshell

## Overview

##### Main components
- Server Module: Represented by server.py. This is where the reverse shell command sending occurs, and it performs the secure key exchange and encrypted communication setup.
- Client Module: Represented by client.py. This component connects to the attacker’s server, performs key exchange, receives encrypted commands, executes them, and sends back encrypted responses.
- Security Layer: A conceptual component that includes:
- ML-KEM based key exchange
- HKDF for key derivation
- Chacha20 encryption engine

##### Relationships and interactions between these components
- Key Derivation: Following the key exchange, show that both modules derive encryption keys and IVs via HKDF.

##### Architectural patterns and design principles
- Client-Server Pattern: Clearly differentiate server and client responsibilities.
- Security First: Emphasize that every stage (key exchange, key derivation, encryption, command execution) is secured through cryptographic methods.
- Minimal Components: With only two Python scripts handling the core functions, the design should remain simple but should highlight each security layer.

##### Following specific details
- At the top-level, show two primary blocks:
- A block for the Server (attacker) with server.py.
- A block for the Client (victim) with client.py.
- Inside each block or as an overlay, indicate the cryptographic processes:
- “ML-KEM: Secure Key Exchange”
- “HKDF: Key Derivation for Chacha20”
- “Chacha20: Encrypted Communication”
- From Server to Client: “Encrypted Command Transmission”
- From Client back to Server: “Encrypted Response Transmission”
- Optionally, add a section that relates to file exchanges (upload/download), if that functionality is demonstrated within the code.

## Diagram (Mermaid)

```mermaid
graph TD
    EE["External Network Environment"]:::external

    subgraph "Server Module (server.py)"
        S["Server Module (server.py)"]:::server
        S_Sec["ML-KEM,HKDF,Chacha20"]:::security
    end

    subgraph "Client Module (client.py)"
        C["Client Module (client.py)"]:::client
        C_Sec["ML-KEM,HKDF,Chacha20"]:::security
    end

    C -->|"ML-KEM_KeyExchange"| S
    S -->|"Chacha20_EncryptedCommands"| C
    C -->|"Chacha20_EncryptedResponses"| S
    S -.->|"File_Transfer(Optional)"| C
    EE -->|"Secured_Network_Comm"| S
    EE -->|"Secured_Network_Comm"| C

    click S "https://github.com/juanpardos/pqrevshell/blob/main/server.py"
    click S_Sec "https://github.com/juanpardos/pqrevshell/blob/main/server.py"
    click C "https://github.com/juanpardos/pqrevshell/blob/main/client.py"
    click C_Sec "https://github.com/juanpardos/pqrevshell/blob/main/client.py"

    classDef server fill:#ffcccc,stroke:#990000,stroke-width:2px;
    classDef client fill:#cce5ff,stroke:#00509e,stroke-width:2px;
    classDef security fill:#d5f5e3,stroke:#239b56,stroke-width:2px,stroke-dasharray: 5 5;
    classDef external fill:#f0f0f0,stroke:#888888,stroke-width:2px;
```
