Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/m3str3/ransomware

A realistic ransomware simulation built with Rust and Reactβ€”covering malware creation, data exfiltration, and a reactive blog. For educational purposes only
https://github.com/m3str3/ransomware

malware ransomware rust

Last synced: 3 days ago
JSON representation

A realistic ransomware simulation built with Rust and Reactβ€”covering malware creation, data exfiltration, and a reactive blog. For educational purposes only

Awesome Lists containing this project

README

        

# Ransomware

## πŸ“Œ Overview
This project simulates a ransomware operation, covering infection, encryption, exfiltration, and centralized control. It includes multiple components:

* **RustLock (Rust ransomware)**: The main ransomware payload, responsible for encrypting user data and exfiltrating it to the relay server over FTP.
* **Server/ClearService (C2 #1 - Relay Server)**: The first-hop server that temporarily stores the encrypted files in waiting to be downloaded for C2#2. The idea behind having a relay server is to be able to exfiltrate data over the clearnet (faster than TOR). It also allows to have a custom configuration like 0 logs or wipe systems in case of logins.
* **Server/HiddenService (C2 #2 - Central Server)**: The main TOR server scans multiple relay servers waiting for a new record, then downloads the data. It also serves a ransomware website via TOR.

```
ransomware/
β”œβ”€β”€ README.md <--------------------- You are here :)!
β”‚
β”œβ”€β”€ RustLock/ $ Ransomware Locker & Unlocker (Rust)
β”‚ β”‚ # ====================================
β”‚ β”œβ”€β”€ build.rs - Build script
β”‚ β”œβ”€β”€ compile.py - Compile script (recommended)
β”‚ β”œβ”€β”€ .gitignore
β”‚ β”œβ”€β”€ keys/ - RSA Keys for locker and unlocker
β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”œβ”€β”€ antireversing.rs - Anti-debugging & obfuscation techniques
β”‚ β”‚ β”œβ”€β”€ config.rs - Configurations
β”‚ β”‚ β”œβ”€β”€ lib.rs - Shared library
β”‚ β”‚ β”œβ”€β”€ locker.rs - Locker entry point
β”‚ β”‚ β”œβ”€β”€ unlocker.rs - Unlocker entry point
β”‚ β”‚ β”œβ”€β”€ cypher/ - Encryption components for locker
β”‚ β”‚ └── decypher/ - Decryption components for unlocker
β”‚ └── README.md - Documentation for RustLock module
β”‚
└── server/ Command & Control (C2) Servers
β”‚
β”œβ”€β”€ ClearService/ $ Public C2 (C2 #1) - Relay server
β”‚ β”‚ # ====================================
β”‚ β”œβ”€β”€ Dockerfile - Docker for quick deployment
β”‚ β”œβ”€β”€ api.py - API to serve encrypted data to C2#2
β”‚ β”œβ”€β”€ install.sh - Installation script
β”‚ └── README.md - Documentation for ClearService
β”‚
└── HiddenService/ # Hidden C2 (C2 #2) - Central server
β”‚ # ====================================
β”œβ”€β”€ install.sh - Installation script
β”œβ”€β”€ backend/ - Backend (Flask/Django API for ransom blog)
β”‚ β”œβ”€β”€ api.py - API that manages ransom operations
β”‚ └── README.md - Backend documentation
β”‚
β”œβ”€β”€ conf/ - Configuration files
β”‚ β”œβ”€β”€ key.bin - Private key for .onion service
β”‚ β”œβ”€β”€ torrc - Tor service configuration (if applicable)
β”‚ └── etc... - Other configuration files
β”‚
β”œβ”€β”€ frontend/ - Ransom blog (React app)
β”‚ β”œβ”€β”€ src/ - React source code
β”‚ β”œβ”€β”€ public/ - Static assets
β”‚ β”œβ”€β”€ package.json - Dependencies
β”‚ └── README.md - Frontend documentation
β”‚
└── README.md - General documentation for HiddenService
```

# Exfiltration architecture

The ransomware follows this multi-stage attack pattern:

```mermaid
graph TD;
A[Infected User]
R[locker.exe]

subgraph Victim
A --> R
end

subgraph C2#1 - Relay Infrastructure
B[C2#1 - Relay Server]
end

subgraph C2#2 - Central Infrastructure
C[C2#2 - Central Server]
D[C2#2 - Web Interface ransom blog]
end
R -->|"Exfiltrates Encrypted Data over FTP"| B
B <-->|"Retrieves Data with API KEY"| C;
C -->|"Feeds"| D;

```

## πŸ”Ή Step-by-step Execution Flow:

### 1. Infection (RustLocker)
* locker.exe is executed on the victim’s machine.
* It scans the filesystem and encrypts all relevant files using AES key that has been generated on execution time.
* It encrypts the Key with a public RSA then encode it in base64.
* It send the encrypted data and key to C2#1 over FTP

### 2. Exfiltration (C2#1)
* The victim encrypted data is sent to C2#1 (Relay Server) over FTP.
* C2#1 generates a unique entry for the data
* This server has 0 log policy (not really implemented on the example)
* Implements a password to download the encrypted data about the victims

### 3. Ransom Blog Updates (C2#2)
* Periodically, the backend services ask for all the C2#1 (can be multiple) for encrypted data and keys.
* The victim’s data appears on the ransom blog (hosted by C2#2).
* This server now has the key (AES+RSA) encode in base64 that can use for unencrypt the data

# πŸ” Encryption Details
## The key cycle looks like
```mermaid
sequenceDiagram
participant Ransomware as Ransomware (Infected Machine)
participant AES as AES-256 Key (Generated)
participant RSA as RSA-4096 Public Key (Embedded)
participant C2

Ransomware->>AES: Generate AES key in memory
Ransomware->>Ransomware: Encrypt files with AES key
Ransomware->>RSA: Encrypt AES key using RSA public key
Ransomware->>C2: Upload encrypted AES key & file metadata
```
* **AES** the key is generated on execution. As its faster than RSA, it is used for encryption.
* **RSA** after encryption, AES key is encrypted with public RSA, so only the person who has the private key can recover the original key.

# πŸ›‘οΈ Anti-Analysis & Evasion Techniques
To resist forensic analysis, RustLock implements basic methods like:

* **Environment Checks**: Detects sandboxes, virtual machines, and debuggers.