How halildeniz/ransomwaresim works
Project Type and Purpose
• RansomwareSim is a Python-based educational simulation tool (not a web or GUI app) that mimics ransomware behavior: it encrypts files (Encoder.py), communicates with a command-and-control server (ControlServer.py), and then decrypts them (Decoder.py).
Top-Level File Structure
• ControlServer.py
• Encoder.py (the “ransomware” client)
• Decoder.py (the recovery client)
• requirements.txt (dependencies: cryptography, colorama)
• Readme.md, LICENSE, SECURITY.md
Key Components
A. Encoder (Ransomware Client)
• Modules:
• File Scanner & Encryptor (uses cryptography library)
• Desktop Wallpaper Changer (OS calls)
• Ransom Note Writer (README.txt on desktop)
• Network Client (sockets) to send system info and request key
B. Control Server
• Listens for incoming client connections
• Receives system metadata from Encoder
• Generates & stores per-session encryption/decryption keys
• Responds to clients (sends decryption key when authorized)
C. Decoder (Recovery Client)
• Network Client to contact Control Server with key request
• Decryptor module (uses cryptography library) to restore files
D. File System
• Target directory for encryption/decryption
• User’s Desktop (for ransom note & wallpaper)
E. External Libraries
• cryptography (AES key generation, file encryption)
• colorama (console coloring)
Component Relationships & Data Flows
1. Encoder scans and encrypts files → writes encrypted files back to file system.
2. Encoder changes desktop wallpaper & drops ransom note.
3. Encoder opens TCP socket → sends system info → receives session ID (and/or placeholder key).
4. User runs Decoder → it connects to Control Server over TCP → submits session ID + request.
5. Control Server verifies session → sends back decryption key.
6. Decoder uses key to decrypt files, restoring the original data.
Architectural Patterns & Principles
• Client-Server pattern: two clients (Encoder, Decoder) communicating with central Control Server.
• Layered responsibilities within each client:
• Presentation/CLI layer (console prompts, colorama)
• Business logic layer (encryption/decryption, wallpaper change)
• Data layer (file I/O)
• Clear separation between “malicious behavior” (Encoder) and “remediation” (Decoder).
Detail Level
• Method groupings rather than every function.
• Sequence: encrypt → notify C&C → request key → decrypt.
• Don’t overcrowd: keep per-component internals to 2–3 bullet labels.