Lesson 2 of 10
Ransomware - Technical Deep Dive
Ransomware is the dominant cyberthreat for organizations - $1.1 billion in ransoms paid in 2023 (Chainalysis). Modern ransomware operations run like businesses with RaaS (Ransomware-as-a-Service) models. Understanding the technical mechanics enables better defenses.
Ransomware Encryption Mechanics
# How modern ransomware encrypts your files
Step 1 - Key generation (before any file encryption):
Attacker generates RSA-2048/4096 key pair offline
Public key embedded in ransomware binary
Ransomware generates random AES-256 key per victim machine
Machine AES key encrypted with attacker's RSA public key
→ Encrypted machine key stored in ransom note file
Step 2 - File encryption:
For each file:
Generate random 256-bit AES-IV
Encrypt file contents with AES-256-CTR (fast, parallelizable)
Append encrypted key reference to file
Rename file: document.docx → document.docx.locked
Step 3 - Credential processing:
Run on-disk: mimikatz, LaZagne - harvest credentials for propagation
Check network shares: map all accessible SMB shares
Enumerate backups: look for Veeam, Backup Exec, Shadow Copies
Step 4 - Lateral movement and pre-encryption staging:
Deploy ransomware to all hosts via:
- PsExec to domain-joined hosts
- Group Policy Object (if DC compromised)
- WMI remote execution
Detonate simultaneously on ALL hosts to maximize pressure
Step 5 - Detonation:
Delete Volume Shadow Copies: vssadmin delete shadows /all /quiet
Disable backup services: net stop "Backup Exec" /y
Disable Windows Defender: Set-MpPreference -DisableRealTimeMonitoring $true
Write ransom note to every directory
Encrypt files on all local and network drives
Change desktop wallpaper with ransom demandRansomware Defense Architecture
# Defense-in-depth against ransomware
1. BACK UP CORRECTLY (3-2-1-1 rule):
3 copies of data
2 different storage media types
1 offsite (geographically separate)
1 offline / air-gapped (unreachable by ransomware)
Test restore MONTHLY - backups that haven't been tested don't exist
Use immutable backups: AWS S3 Object Lock (WORM - Write Once Read Many)
2. LIMIT BLAST RADIUS:
Least-privilege file shares - only necessary permissions
Segmented backup network - backup server on isolated VLAN
Disabled administrative shares: net share C$ /delete
Block PsExec and remote admin tools via AppLocker/WDAC
3. EARLY DETECTION:
Canary files - honeypot files that alert on modification
Monitor: vssadmin, bcdedit, wbadmin commands (ransomware indicators)
File entropy monitoring - detect mass encryption in progress
Alert on: creation of ReadMe.txt in multiple directories
4. HARDENING:
Disable RDP if not needed; use VPN + MFA if needed
Patch aggressively - 65% of ransomware uses known CVEs
Block Office macros (main phishing delivery vector)
Application allowlisting (WDAC) - only approved binaries run
5. MONITORING:
Alert on: Shadow copy deletion, mass file renames, AV disable attempts
EDR behavioral rules for ransomware activity patternsCommon Mistakes
- Backups accessible from the same network segment as workstations - modern ransomware specifically targets and encrypts network-accessible backups. Backups must be isolated or offline
- Paying without understanding the attack's full scope - paying the ransom and restoring doesn't address how attackers got in; they often maintain access after payment and encrypt again
- Not having a tested, documented ransomware response plan - the worst time to design your ransomware response is during an active encryption event
Tip
Tip
Practice Ransomware Technical Deep Dive in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).
Practice Task
Note
Practice Task - (1) Write a working example of Ransomware Technical Deep Dive from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Ransomware Technical Deep Dive is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.
Key Takeaways
- Ransomware is the dominant cyberthreat for organizations - $1.
- Backups accessible from the same network segment as workstations - modern ransomware specifically targets and encrypts network-accessible backups. Backups must be isolated or offline
- Paying without understanding the attack's full scope - paying the ransom and restoring doesn't address how attackers got in; they often maintain access after payment and encrypt again
- Not having a tested, documented ransomware response plan - the worst time to design your ransomware response is during an active encryption event
Finished this lesson?