Comprehensive technical documentation for malware analysts, detection engineers, and incident responders
Summary • Crypto • Phases • Encryption • LAN • IOCs • ATT&CK • Detection • Full Report EN • Reporte ES
Note
THREAT INTELLIGENCE DOCUMENTATION — FOR AUTHORIZED SECURITY RESEARCH ONLY.
This repository contains analysis documentation only (no source code) from the reverse engineering of the Babuk ransomware family. Published to support malware analysis, detection engineering, incident response, and academic research.
Babuk Locker (also known as Babyk, Babuk) was a ransomware operation active from January 2021 that targeted enterprises, critical infrastructure, and government entities including the Washington D.C. Metropolitan Police Department. The group operated a double-extortion model with a Tor-based data leak site.
This repository contains detailed technical analysis documentation of Babuk Ransomware Version 1 (Windows variant), providing complete visibility into:
- The hybrid ECDH + ChaCha20 encryption scheme
- Multi-threaded file encryption with dual-mode processing (small/large files)
- LAN propagation via Windows Network Resource enumeration
- Service/process termination and shadow copy destruction
- The NIST K-571 elliptic curve implementation (256-bit equivalent security)
| Attribute | Value |
|---|---|
| Malware family | Babuk Locker / Babyk |
| Version | 1.0 (initial variant) |
| First seen | January 2021 |
| Target OS | Windows (this variant) |
| Language | C++ (originally Embarcadero Dev-C++) |
| Encryption | ECDH (NIST K-571) + ChaCha20 + SHA-256 |
| Key size | 571-bit ECC (~256-bit symmetric equivalent) |
| Extension | .__NIST_K571__ |
| Ransom note | How To Restore Your Files.txt |
| Notable victims | DC Metropolitan Police, Houston Rockets, Serco |
| Leak site | babukq4e2p4wu4iq.onion (defunct) |
Babuk implements a multi-layer hybrid encryption scheme combining asymmetric and symmetric cryptography. This is the core technical contribution of this analysis.
OPERATOR LEVEL (pre-embedded)
┌─────────────────────────────────────────────────────────┐
│ MY_ECDH_PUB_KEY (144 bytes) │
│ Operator's ECDH public key — NIST K-571 curve │
│ Hardcoded at compile time │
└───────────────────────┬─────────────────────────────────┘
│
VICTIM LEVEL (runtime) │
┌───────────────────────┴─────────────────────────────────┐
│ 1. RtlGenRandom() → 88 random bytes → CHACHA20KEY_1 │
│ 2. ChaCha20 self-encryption of KEY_1 → ECDH seed │
│ 3. ecdh_generate_keys() → victim key pair │
│ ├── VICTIM_ECDH_PUBLIC_KEY (144 bytes) → saved │
│ └── VICTIM_ECDH_PRIVATE_KEY (72 bytes) → memory │
│ 4. ecdh_shared_secret(victim_priv, operator_pub) │
│ └── ECDH_SHARED_SECRET (144 bytes) │
└───────────────────────┬─────────────────────────────────┘
│
FILE LEVEL │
┌───────────────────────┴─────────────────────────────────┐
│ 5. SHA-256(shared_secret[:72]) → CHACHA20_FINAL_KEY_1 │
│ 6. SHA-256(shared_secret[:144]) → CHACHA20_FINAL_KEY_2 │
│ 7. memcpy(shared_secret[:12]) → CHACHA20_FINAL_NONCE │
│ │
│ ALL files encrypted with the SAME derived keys │
│ Double ChaCha20 pass: Key1 then Key2 (same nonce) │
└──────────────────────────────────────────────────────────┘
| Aspect | Implementation | Assessment |
|---|---|---|
| Curve | NIST K-571 (Koblitz) | Strong — 256-bit equivalent security |
| Key derivation | SHA-256 of shared secret | Acceptable but non-standard |
| Symmetric cipher | ChaCha20 (double pass) | Redundant — second pass adds no security |
| Nonce handling | First 12 bytes of shared secret | CRITICAL FLAW — same nonce for ALL files |
| Per-file keys | None — single key pair per victim | WEAKNESS — compromise of one key decrypts all |
| Key storage | Public key saved to %APPDATA%\ecdh_pub_k.bin |
Required for decryption by operator |
| CSPRNG | RtlGenRandom (SystemFunction036) |
Adequate — Windows CSPRNG |
Important
The use of a single nonce across all files with the same key is a significant cryptographic weakness. While ChaCha20 is a stream cipher and nonce reuse doesn't directly enable plaintext recovery (unlike AES-CTR), it means every file is encrypted with the identical keystream. If any plaintext-ciphertext pair is known, all files can be decrypted via XOR.
PHASE 1 — System Preparation
═══════════════════════════════════════════════════════════
[1.1] ServiceFucker() → Stop 44 security/backup services
[1.2] ProcessFucker() → Terminate 31 file-locking processes
[1.3] ShadowFucker() → vssadmin delete shadows /all /quiet
[1.4] SHEmptyRecycleBin → Empty recycle bin silently
PHASE 2 — Cryptographic Setup
═══════════════════════════════════════════════════════════
[2.1] GetSystemInfo → Detect processor count
[2.2] ChaChaKey1Setup() → RtlGenRandom → 88 bytes entropy
[2.3] ECDHPrivateKeySetup() → ChaCha20 self-XOR → ECDH seed
[2.4] ecdh_generate_keys() → Victim ECDH key pair (K-571)
[2.5] ecdh_shared_secret() → Diffie-Hellman shared secret
[2.6] SHA-256(secret) → ChaCha20 final keys (2x 32 bytes)
[2.7] memcpy(secret[:12]) → ChaCha20 nonce (12 bytes)
PHASE 3 — Key Persistence
═══════════════════════════════════════════════════════════
[3.1] Save VICTIM_ECDH_PUBLIC_KEY to %APPDATA%\ecdh_pub_k.bin
[3.2] Fallback: %TEMP%\ecdh_pub_k.bin
PHASE 4 — File Encryption
═══════════════════════════════════════════════════════════
[4.1] If -lanfirst: SearchLAN() → WNetOpenEnumW recursion
[4.2] MountVolumes() → Mount all unmounted NTFS volumes
[4.3] GetLogicalDrives() → Enumerate A:-Z:
[4.4] Multi-threaded SearchFiles() per drive
└── Thread count = NumProcessors * 2
[4.5] If -lansecond: SearchLAN() after local encryption
[4.6] WaitForMultipleObjects() → Join all threads
PHASE 5 — Final Cleanup
═══════════════════════════════════════════════════════════
[5.1] ShadowFucker() → Delete shadow copies again
Babuk implements size-based encryption strategy to maximize speed:
┌──────────────────────────────────────────────────────┐
│ FILE SIZE DECISION │
│ │
│ File <= 40 MB (41,943,040 bytes) │
│ ├── Memory-map ENTIRE file │
│ ├── ChaCha20(Key1, Nonce) XOR full content │
│ ├── ChaCha20(Key2, Nonce) XOR full content │
│ └── 100% of file encrypted │
│ │
│ File > 40 MB │
│ ├── Calculate: block_spacing = filesize / 10MB / 3 │
│ ├── Encrypt 3 blocks of 10 MB each │
│ │ ├── Block 1: offset 0 │
│ │ ├── Block 2: offset block_spacing * 10MB │
│ │ └── Block 3: offset block_spacing * 2 * 10MB │
│ ├── ChaCha20 double-pass on each block │
│ └── ~30 MB encrypted regardless of file size │
└──────────────────────────────────────────────────────┘
For each file:
1. SetFileAttributesW(NORMAL) — Remove read-only protection
2. CreateFileW(READ|WRITE) — Open with full access
3. If locked → Restart Manager API:
a. RmStartSession()
b. RmRegisterResources()
c. RmGetList() → find locking processes
d. TerminateProcess() on each (skip Explorer/Critical)
e. RmEndSession()
4. CreateFileMappingA() — Memory-map the file
5. MapViewOfFile() — Map into address space
6. ChaCha20XOR(Key1) → in-place — First encryption pass
7. ChaCha20XOR(Key2) → in-place — Second encryption pass
8. UnmapViewOfFile() — Flush to disk
9. MoveFileExW(+ ".__NIST_K571__") — Append extension
10. Drop ransom note in directory
Babuk implements recursive Windows network resource enumeration for lateral file encryption:
SearchLAN(NULL)
└── WNetOpenEnumW(RESOURCE_GLOBALNET, RESOURCETYPE_ANY)
└── WNetEnumResourceW() loop
├── If RESOURCEUSAGE_CONTAINER → SearchLAN(resource) // Recurse deeper
└── Else → SearchFiles(lpRemoteName, 0) // Encrypt share
| Flag | Behavior |
|---|---|
-lanfirst |
Encrypt LAN shares BEFORE local drives |
-lansecond |
Encrypt LAN shares AFTER local drives (default) |
-nolan |
Skip LAN encryption entirely |
| Category | Services |
|---|---|
| Backup | vss, veeam, VeeamTransportSvc, VeeamDeploymentService, VeeamNFSSvc, BackupExecVSSProvider, BackupExecAgentAccelerator, BackupExecAgentBrowser, BackupExecJobEngine, BackupExecManagementService, BackupExecRPCService, YooBackup, YooIT, AcrSch2Svc, AcronisAgent, CASAD2DWebSvc, CAARCUpdateSvc, GxVss, GxBlr, GxFWD, GxCVD, GxCIMgr, VSNAPVSS, PDVFSService |
| Security | sophos, DefWatch, ccEvtMgr, ccSetMgr, SavRoam, RTVscan, zhudongfangyu, stc_raw_agent |
| Database | sql, svc$, memtas, mepocs |
| Accounting | QBFCService, QBIDPService, Intuit.QuickBooks.FCS, QBCFMonitorService |
| Category | Processes |
|---|---|
| Database | sql.exe, oracle.exe, ocssd.exe, dbsnmp.exe, dbeng50.exe |
| Office | excel.exe, winword.exe, outlook.exe, powerpnt.exe, msaccess.exe, mspub.exe, onenote.exe, visio.exe, wordpad.exe, notepad.exe, infopath.exe |
thunderbird.exe, thebat.exe |
|
| Browser | firefox.exe |
| Other | synctime.exe, agntsvc.exe, isqlplussvc.exe, xfssvccon.exe, mydesktopservice.exe, ocautoupds.exe, encsvc.exe, tbirdconfig.exe, mydesktopqos.exe, ocomm.exe, sqbcoreservice.exe, steam.exe |
Excluded directories:
Windows, Windows.old, Tor Browser, Internet Explorer, Google, Opera, Mozilla, Mozilla Firefox, $Recycle.Bin, ProgramData, All Users, Program Files, Program Files (x86)
Excluded files:
autorun.inf, boot.ini, bootfont.bin, bootsect.bak, bootmgr, bootmgr.efi, bootmgfw.efi, desktop.ini, iconcache.db, ntldr, ntuser.dat, ntuser.dat.log, ntuser.ini, thumbs.db, ecdh_pub_k.bin
| Indicator | Value |
|---|---|
| Encrypted extension | .__NIST_K571__ |
| Ransom note | How To Restore Your Files.txt |
| ECDH key file | %APPDATA%\ecdh_pub_k.bin (144 bytes) |
| Fallback key | %TEMP%\ecdh_pub_k.bin |
| Type | Value |
|---|---|
| Onion URL | babukq4e2p4wu4iq.onion |
| Login path | /login.php?id=8M60J4vCbbkKgM6QnA07E9qpkn0Qk7 |
| Indicator | Detail |
|---|---|
| Shadow deletion | cmd.exe /c vssadmin.exe delete shadows /all /quiet |
| Recycle bin empty | SHEmptyRecycleBinW(NULL, NULL, 7) |
| Shutdown parameters | SetProcessShutdownParameters(0, 0) |
| Dynamic API loading | LoadLibraryA("advapi32.dll") → SystemFunction036 |
| WoW64 redirection | Wow64DisableWow64FsRedirection for shadow deletion |
| Network enumeration | WNetOpenEnumW(RESOURCE_GLOBALNET) |
| Volume mounting | SetVolumeMountPointW on unmounted NTFS volumes |
| Restart Manager abuse | RmStartSession → RmGetList → terminate locking processes |
| Attribute | Value |
|---|---|
| Compiler | MSVC (Visual Studio 2019/2022) or Embarcadero Dev-C++ |
| Subsystem | CONSOLE |
| Linked libs | advapi32.lib, shlwapi.lib, netapi32.lib, rstrtmgr.lib, mpr.lib, shell32.lib |
| Runtime | Static (/MT) |
| Optimization | /O2 |
| Tactic | Technique | ID | Implementation |
|---|---|---|---|
| Execution | Command and Scripting Interpreter | T1059.003 | cmd.exe /c vssadmin.exe delete shadows |
| Execution | Shared Modules | T1129 | Dynamic LoadLibraryA for API resolution |
| Persistence | (none) | — | Babuk does not persist — single execution |
| Defense Evasion | Indicator Removal | T1070.004 | Shadow copy deletion, recycle bin empty |
| Defense Evasion | File and Directory Permissions Modification | T1222.001 | SetFileAttributesW(NORMAL) to remove protection |
| Defense Evasion | Process Injection | T1055 | WoW64 FS redirection bypass |
| Discovery | System Information Discovery | T1082 | GetSystemInfo() for processor count |
| Discovery | File and Directory Discovery | T1083 | FindFirstFileW recursive enumeration |
| Discovery | Network Share Discovery | T1135 | WNetOpenEnumW(RESOURCE_GLOBALNET) |
| Discovery | Peripheral Device Discovery | T1120 | GetLogicalDrives() + GetDriveTypeW() |
| Lateral Movement | Remote Services: SMB | T1021.002 | LAN share file encryption via WNet |
| Impact | Data Encrypted for Impact | T1486 | ChaCha20 double-pass encryption |
| Impact | Service Stop | T1489 | 44 services terminated via SCM |
| Impact | Inhibit System Recovery | T1490 | Shadow copy deletion (x2), recycle bin |
| Impact | System Shutdown/Reboot | T1529 | SetProcessShutdownParameters(0, 0) |
Babuk-Ransomware-Analysis/
├── README.md # This file — full technical overview
└── docs/
├── ANALYSIS_EN.md # Complete reverse engineering report (English)
└── ANALYSIS_ES.md # Reporte de ingenieria inversa completo (Espanol)
Note: This repository contains analysis documentation only. No source code, binaries, or compilable materials are included.
rule Babuk_Ransomware_V1 {
meta:
description = "Detects Babuk Ransomware Version 1"
author = "KONDOR DEV SECURITY CORP"
date = "2025-04-09"
malware_family = "Babuk"
severity = "critical"
strings:
$ext = ".__NIST_K571__" wide
$note_name = "How To Restore Your Files.txt" wide
$note_body = "BABUK LOCKER" ascii
$onion = "babukq4e2p4wu4iq.onion" ascii
$shadow = "vssadmin.exe delete shadows /all /quiet" wide
$key_file = "ecdh_pub_k.bin" wide ascii
$func1 = "SystemFunction036" ascii
$func2 = "Wow64DisableWow64FsRedirection" ascii
condition:
uint16(0) == 0x5A4D and 4 of them
}title: Babuk Ransomware Shadow Copy Deletion
id: babuk-shadow-delete
status: experimental
logsource:
category: process_creation
product: windows
detection:
selection:
ParentImage|endswith: '\cmd.exe'
CommandLine|contains|all:
- 'vssadmin'
- 'delete'
- 'shadows'
- '/all'
condition: selection
level: critical
tags:
- attack.impact
- attack.t1490alert tcp $HOME_NET any -> $EXTERNAL_NET any (
msg:"MALWARE Babuk Ransomware Onion Beacon";
content:"babukq4e2p4wu4iq";
classtype:trojan-activity;
sid:2025001; rev:1;
)
| Source | Link |
|---|---|
| McAfee — Babuk Analysis | mcafee.com/blogs |
| Trend Micro — Babuk Deep Dive | trendmicro.com |
| CISA — Ransomware Guide | cisa.gov/stopransomware |
| No More Ransom | nomoreransom.org |
| MITRE ATT&CK — Ransomware | attack.mitre.org |
| NIST K-571 Specification | FIPS 186-3 |
Warning
LEGAL NOTICE / AVISO LEGAL
EN: This repository contains threat intelligence documentation only — no source code, binaries, or compilable materials. Published exclusively for cybersecurity research, malware analysis, detection engineering, and academic study. The publisher assumes no liability for misuse of the information contained herein.
ES: Este repositorio contiene solo documentacion de inteligencia de amenazas — sin codigo fuente, binarios, ni materiales compilables. Publicado exclusivamente para investigacion en ciberseguridad, analisis de malware, ingenieria de deteccion y estudio academico. El publicador no asume responsabilidad por el mal uso de la informacion aqui contenida.
Analysis by KONDOR DEV SECURITY CORP — For the cybersecurity research community