# h4ckzu5/ransomware architecture

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

- Interactive diagram: https://gitdiagram.com/h4ckzu5/ransomware
- Repository: https://github.com/h4ckzu5/ransomware

## Overview

##### Project type and purpose
- This is a small, web-based ransomware tool written in PHP.
- Its goal is to encrypt files on a target host via a PHP script (RansomWare.php), display a ransom note in the browser, and later restore files once payment instructions are followed.

##### File structure
- Top level:
- README.md – project description and basic instructions
- RansomWare.php – the core PHP script that performs encryption, notes, and decryption
- The README mentions auxiliary files (.htaccess, shor7cut.php) that are auto-created or should be deleted after restoration.
- No frameworks or databases—pure PHP plus the web server’s file system.

##### Extract insights from the README
- Open-source PHP ransomware, intended to be deployed on any PHP-enabled web host.
- After decrypting files, the operator must remove the .htaccess and shor7cut.php “shortcut” drop-off script.

##### Main components
a. Web Server
– Apache or Nginx with PHP-FPM
b. PHP RansomWare Module (RansomWare.php)
– Scans filesystem, encrypts files (OpenSSL or built-in PHP functions), drops ransom note in HTML
– Creates .htaccess to force all requests to a “payment” landing page
– Generates shor7cut.php for decrypt routine
c. Victim File System
– The directory tree containing target documents/images/etc.
d. Victim Browser UI
– The ransom note page where payment instructions are shown
e. Attacker Key Management (external, conceptual)
– Could be an external API or email mechanism to deliver decryption keys once payment is confirmed

##### Relationships and interactions
- Victim’s browser → HTTP GET to Web Server → PHP script executes
- RansomWare.php ↔ Victim FS: encrypt()/decrypt() calls
- RansomWare.php → drops ransom-note.html + .htaccess + shor7cut.php
- After payment, victim invokes shor7cut.php → PHP decrypt routine uses stored key to restore files
- (Optional) PHP script sends payment confirmation to Attacker Key Management → returns decryption key

##### Architectural patterns and design principles
- Single-tier, server-centric application (no separate backend service or database)
- Script-driven lifecycle:
- Initialization (scan & encrypt)
- Ransom note display (UI)
- Decryption stage (triggered by shor7cut.php)
- Minimal external dependencies: relies on PHP’s encryption extensions and the web server.

##### Relevant technologies, frameworks, or libraries
- PHP (core language)
- PHP OpenSSL or Mcrypt (for symmetric/asymmetric encryption)
- .htaccess (Apache config) or equivalent rewrite rules
- shor7cut.php (decryption entry point)

##### Elements
- Clear labels for each component (Web Server, PHP Script, File System, Browser, Attacker Service)
- HTTP requests/responses
- File read/write (encryption/decryption)
- Key exchange to Attacker Service
- Local FS and encryption routines in another
- External/attacker elements in a third

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Victim Interaction
    subgraph "Victim Interaction"
        Browser["Victim Browser UI"]:::frontend
    end

    %% Web Server Layer
    subgraph "Web Server Layer"
        Server["Apache/Nginx + PHP-FPM"]:::server
    end

    %% RansomWare Module Layer
    subgraph "RansomWare Module"
        Script["PHP RansomWare Module\n(RansomWare.php)"]:::script
        Note["Ransom Note\n(ransom-note.html)"]:::ui
        HT[".htaccess"]:::config
        Shortcut["shor7cut.php"]:::script
    end

    %% Storage Layer
    subgraph "Victim File System"
        FS["File System Storage"]:::storage
    end

    %% External Attacker Service
    Attacker["Attacker Key Management"]:::external

    %% Data Flows
    Browser -->|"HTTP GET /RansomWare"| Server
    Server -->|"Execute Script"| Script
    Script -->|"Scans & Encrypts"| FS
    Script -->|"Drops files"| Note
    Script -->|"Creates rewrite rules"| HT
    Script -->|"Generates decrypt entry"| Shortcut
    Server -->|"Serve ransom note"| Browser

    Browser -->|"HTTP GET shor7cut.php"| Server
    Server --> Shortcut
    Shortcut -->|"Decrypts files"| FS
    Shortcut -->|"Cleanup step\n(remove .htaccess & shor7cut.php)"| FS

    Script -->|"Request decryption key"| Attacker
    Attacker -->|"Return key"| Script

    %% Click Events
    click Script "https://github.com/h4ckzu5/ransomware/blob/master/RansomWare.php"
    click Browser "https://github.com/h4ckzu5/ransomware/blob/master/README.md"

    %% Styles
    classDef frontend fill:#fde2e2,stroke:#e63946,stroke-width:2px
    classDef server fill:#e8f1f2,stroke:#1d3557,stroke-width:2px
    classDef script fill:#fff4e6,stroke:#f77f00,stroke-width:2px
    classDef storage fill:#edf7ed,stroke:#2a9d8f,stroke-width:2px
    classDef external fill:#f0f0f0,stroke:#6c757d,stroke-width:2px,stroke-dasharray: 5 5
    classDef ui fill:#fff0f6,stroke:#c9184a,stroke-width:2px
    classDef config fill:#f8f9fa,stroke:#adb5bd,stroke-width:2px,stroke-dasharray: 2 2
```
