Post

Phobos Ransomware β€” Malware Analysis Walkthrough

Deep analysis of Phobos ransomware: encrypted configuration, process termination, persistence mechanisms, and file encryption strategies.

Phobos Ransomware β€” Malware Analysis Walkthrough

Overview

Β Β 
PlatformCyberDefenders
CategoryMalware Analysis
DifficultyInsane
FocusRansomware Β· AES Config Decryption Β· Registry Persistence Β· Process Termination
Lab LinkPhobos

Phobos is a well-known ransomware family that has been active since 2018. This challenge walks through analyzing a real Phobos sample, focusing on its encrypted configuration system, anti-analysis techniques, and encryption methodology.

The malware employs:

  • AES-encrypted configuration with indexed entries
  • CRC32 integrity checking to detect tampering
  • Process termination to release file locks before encryption
  • Registry persistence via Run keys
  • Dual encryption strategy for small vs large files

Tools Used

  • IDA Pro (static analysis, decompilation)
  • x32dbg (dynamic analysis, config extraction)
  • PE-bear / DIE (PE metadata inspection)

Objective

The goal of this analysis is to fully understand Phobos ransomware’s execution chain:

  • How it protects its configuration from analysis
  • How it achieves persistence and privilege escalation
  • How it terminates security software before encryption
  • How it decides which encryption strategy to use

By the end, we will have mapped the complete attack lifecycle from initial execution to file encryption.


Q1 β€” Hashing Algorithm Identification

Question

What is the hashing algorithm used by the malware?


What we look for

Malware commonly uses hashing for:

  • Integrity checking β€” verify code hasn’t been tampered
  • API hashing β€” resolve APIs without plaintext strings
  • Configuration validation β€” ensure encrypted config is intact

Common algorithms to watch for: | Algorithm | Characteristics | | β€”β€”β€” | β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”- | | CRC32 | Lookup table, XOR operations, 32-bit output | | MD5 | 128-bit output, complex rounds | | djb2 | Simple multiply-add loop, no table | | ROR13 | Rotate-right operations |


Analysis

During static analysis, I identified a function at sub_4085D9 (0x004085D9) performing data hashing:

1
2
3
4
5
6
7
8
9
10
11
int __usercall sub_4085D9@<eax>(int a1@<eax>, _BYTE *a2@<ecx>, int a3) 
{ 
  unsigned int v3; // eax 
  v3 = ~a1; 
  while ( a3 ) 
  { 
    --a3; 
    v3 = lookup_table[(unsigned __int8)(v3 ^ *a2++)] ^ (v3 >> 8); 
  } 
  return ~v3; 
}

Identification markers:

FeatureObservationCRC32 Signature
Initializationv3 = ~a1βœ“ Bitwise NOT
Lookup table256 entries at 0x40B000βœ“ Precomputed table
Core looptable[v3 ^ byte] ^ (v3 >> 8)βœ“ Standard CRC32
Finalizationreturn ~v3βœ“ Final inversion
Output size32-bit integerβœ“ CRC32

CRC32 Hash Function CRC32 implementation with lookup table

Answer: CRC32


Q2 β€” .cdata Checksum Value

Question

Could you provide the hard-coded value of the .cdata checksum?


What we look for

After identifying a hashing algorithm, the next step is understanding how it’s used.

Common use cases:

  • Anti-debugging checks
  • Code integrity verification
  • Configuration validation

We trace cross-references to the hash function to find where the computed hash is compared against a stored value.


Analysis

Following xrefs to sub_4085D9 (0x004085D9), I found an integrity check in the malware’s initialization:

1
2
if ( CRC32_hash(0, v0, dword_40B40C) != dword_40B430 )
    return;  // Exit if tampered

This is an anti-tampering mechanism β€” the malware verifies its .cdata section hasn’t been modified.

The hardcoded checksum at dword_40B430 (0x0040B430):

1
.data:0040B430 dword_40B430    dd 0D55F8833h    ; DATA XREF: real_Start+62↑r

This anti-tampering mechanism serves multiple purposes:

  • Prevents AV modification β€” if antivirus patches the binary, it won’t run
  • Detects analyst tampering β€” modifications during analysis will fail
  • Ensures payload integrity β€” encrypted config must be intact

Answer: 0xD55F8833


Q3 β€” Malware Version

Question

What is the malware’s version?


What we look for

Ransomware families like Phobos store configuration in encrypted blobs to evade static analysis. To extract config values, we need to:

  1. Identify the decryption function β€” usually takes an index/ID parameter
  2. Set breakpoints at function entry and return
  3. Monitor parameters to understand which config is being decrypted
  4. Capture return values containing decrypted strings

This approach reveals all encrypted strings without needing to reverse the encryption algorithm.


Analysis

The malware stores its configuration in an AES-encrypted blob. I identified two key functions:

FunctionAddressPurpose
sub_4062A60x004062A6Initialize config structure
sub_4063470x00406347Decrypt config entry by ID

Dynamic Extraction

To find the version, I set breakpoints in x32dbg:

  1. Entry breakpoint at sub_406347 (0x00406347) β€” check [esp+4] for config ID
  2. Return breakpoint at 0x00406431 β€” check EAX for decrypted data pointer

Config Decrypt Breakpoint Breakpoint hit at config decryption function

Stack Config Index Stack showing config index 0x33 (51)

After stepping over, EAX contains the decrypted version string:

Version String in EAX EAX pointing to decrypted version: β€œ[Β«IDΒ»-2822] v2.9.1”

The version format [<<ID>>-XXXX] vX.X.X is characteristic of Phobos variants, where:

  • <<ID>> β€” placeholder for victim ID
  • 2822 β€” campaign/affiliate identifier
  • v2.9.1 β€” actual version number

Answer: v2.9.1


Q4 β€” DLL Masquerading

Question

The malware masquerades as a legitimate Windows DLL. Which DLL does it impersonate?


What we look for

Malware often disguises itself using legitimate-sounding names to:

  • Evade casual inspection
  • Blend in with legitimate system files
  • Bypass simple allowlist-based security

We inspect PE metadata (Version Information resource) to identify claimed identity.


Analysis

Using DIE to inspect the Version Information resource:

Suspicious DLL Name PE metadata showing ole32.dll masquerade

The malware claims to be ole32.dll β€” Microsoft’s OLE (Object Linking and Embedding) library.

Why ole32.dll? The malware legitimately imports OLE32 functions:

  • CoInitializeEx / CoUninitialize
  • CoCreateInstance

These are used for WMI access to delete shadow copies. The masquerade creates a coherent cover story.

Why this matters:

  • If security tools see ole32.dll making COM calls, it appears normal
  • The real ole32.dll is a core Windows component, not suspicious
  • Sophisticated masquerading β€” not just random name choice

Answer: ole32.dll


Q5 β€” First API Function Called

Question

Could you provide the first API function that is called by the malware?


What we look for

Understanding the first API call reveals the malware’s immediate priorities:

  • Privilege escalation?
  • Environment detection?
  • Anti-analysis checks?

We trace execution from the entry point, following the call chain until we hit an external API.


Analysis

Tracing from the entry point sub_402FA7 (0x00402FA7) β†’ sub_4029F5 (0x004029F5), I found the first significant operation:

The malware checks if it’s running with elevated privileges. If not, it attempts to restart itself with elevated privileges via sub_40489E (0x0040489E):

1
2
3
4
5
6
7
BOOL sub_40489E()
{
  // ...
  StartupInfo.cb = 68;
  v5 = CreateProcessW(0, v0, 0, 0, 0, 0, 0, 0, &StartupInfo, &ProcessInformation);
  // ...
}

CreateProcessW Function CreateProcessW call at 0x0040490E inside sub_40489E

Restart Caller sub_40489E called from MalwareMain (sub_4029F5) at 0x00402C74

Before any encryption or spreading occurs, the malware calls CreateProcessW to elevate privileges.

Execution flow:

1
2
3
4
5
6
7
8
9
Entry Point (sub_402FA7)
    ↓
MalwareMain (sub_4029F5)
    ↓
Check if Admin (IsElevated)
    ↓
If not admin β†’ RestartAsAdmin (sub_40489E)
    ↓
CreateProcessW ← FIRST API CALL

This is a classic UAC bypass pattern β€” restart with elevated privileges before performing destructive operations.

Answer: CreateProcessW


Q6 β€” Process List Decryption Address

Question

Could you provide the address at which the process list decryption function is called?


What we look for

Ransomware must kill processes that hold file locks before encryption:

  • Database servers (SQL, Oracle, MySQL)
  • Office applications (Excel, Word)
  • Backup software (Veeam, Acronis)
  • Email clients (Outlook, Thunderbird)

We search for:

  • Process enumeration APIs (CreateToolhelp32Snapshot, Process32First/Next)
  • Process termination (TerminateProcess)
  • Then trace back to find where the kill list is decrypted

Analysis

Ransomware typically kills processes that lock files (SQL, backup software, etc.).

I found sub_4022EE (0x004022EE) β€” the process killer thread:

1
2
3
4
5
6
7
8
9
10
int __stdcall sub_4022EE(LPVOID lpThreadParameter)
{
  v5 = (__int16 *)sub_406347(10, 0);  // ← Decrypt config ID 10 (process list)
  // ...
  while ( !sub_405962() )
  {
    sub_404DEE(lpMem);   // Kill matching processes
    Sleep(0x1F4u);
  }
}

The call to sub_406347 (0x00406347) with config index 10 happens at address 0x004022FB:

1
2
.text:004022F9  push    0Ah              ; Config ID = 10 (process list)
.text:004022FB  call    sub_406347       ; ← THIS ADDRESS

Process List Decrypted EAX containing decrypted process names: msftesql.exe, sqlagent.exe, sqlbrowser.exe…

Decrypted process kill list includes:

CategoryProcesses
SQL Serversmsftesql, sqlagent, sqlservr, mysql
Oracleoracle, ocssd, dbsnmp
Office Appsexcel, outlook, powerpnt, onenote
Emailthunderbird, thebat
Backupsqbcoreservice

These processes hold exclusive locks on database files, documents, and emails. Killing them allows the ransomware to encrypt files that would otherwise be inaccessible.

Answer: 0x004022FB


Q7 β€” First Security Disable Command

Question

What’s the first command the malware uses to turn off a critical security measure?


What we look for

Before encryption, ransomware typically:

  • Disables Windows Firewall β€” prevent network-based detection
  • Deletes shadow copies β€” prevent recovery via VSS
  • Disables Windows Defender β€” evade real-time protection
  • Clears event logs β€” destroy forensic evidence

We monitor decrypted config strings for shell commands.


Analysis

Setting a breakpoint on the config decryption function and monitoring returns, I captured:

Firewall Disable Command EAX containing firewall disable commands

1
2
3
netsh advfirewall set currentprofile state off
netsh firewall set opmode mode=disable
exit

The first command disables Windows Firewall using the modern netsh advfirewall syntax.

Command breakdown:

CommandPurposeWindows Version
netsh advfirewall set currentprofile state offDisable firewallVista+
netsh firewall set opmode mode=disableDisable firewallXP (legacy)

The malware includes both commands for maximum compatibility across Windows versions.

Why disable the firewall?

  • Allow C2 communication without interference
  • Enable lateral movement across the network
  • Prevent network-based security tools from blocking traffic

Answer: netsh advfirewall set currentprofile state off


Q8 β€” Persistence Function Address

Question

Could you provide the address of the function used by the malware for persistence?


What we look for

Ransomware persistence ensures the malware survives reboots and can:

  • Continue encryption if interrupted
  • Re-encrypt new files after restart
  • Maintain foothold for additional attacks

Common persistence mechanisms:

  • Registry Run keys β€” HKLM/HKCU\...\Run
  • Scheduled Tasks β€” schtasks.exe
  • Services β€” sc.exe create
  • Startup folder β€” shell:startup

We search for registry APIs: RegOpenKeyEx, RegSetValueEx, RegCreateKey.


Analysis

Following xrefs to RegSetValueExW:

RegSetValueExW Xref Cross-references to RegSetValueExW

This leads to sub_403A93 (0x00403A93), which is called from the main persistence function:

WriteRegistry Xref sub_403A93 called from sub_401236

The persistence function at sub_401236 (0x00401236):

Persistence Function Persistence function writing to Run keys

This function:

  1. Copies itself to a new location
  2. Writes to HKLM\...\Run and HKCU\...\Run
  3. Sets the copied file as HIDDEN (attribute 0x2)

Persistence locations:

Registry KeyScope
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunAll users (requires admin)
HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\RunCurrent user only

By writing to both locations, the malware ensures persistence regardless of privilege level.

Answer: 0x00401236


Q9 β€” C2 Communication Protocol

Question

What protocol is used by the malware for C2 communication?


What we look for

Malware C2 communication typically uses:

  • HTTP/HTTPS β€” blends with normal web traffic
  • DNS β€” often allowed through firewalls
  • Custom protocols β€” harder to detect but more suspicious

We check the Import Address Table (IAT) for networking libraries.


Analysis

Examining the import table reveals WINHTTP.dll imports:

WinHTTP Imports WINHTTP imports: WinHttpOpen, WinHttpConnect, WinHttpSendRequest…

ImportPurpose
WinHttpOpenInitialize WinHTTP
WinHttpConnectConnect to server
WinHttpOpenRequestCreate HTTP request
WinHttpSendRequestSend request
WinHttpReceiveResponseReceive response

All WinHttp* functions = HTTP protocol.

Why HTTP?

  • Blends with normal web traffic
  • Usually allowed through corporate firewalls
  • Easy to implement and debug
  • Can be tunneled through proxies

Answer: HTTP


Q10 β€” Drive Monitor Thread Address

Question

Could you provide the address of the thread used to check continuously for new disk connections?


What we look for

Ransomware often monitors for new storage devices to maximize damage:

  • USB drives inserted during encryption
  • Network shares mounted after initial scan
  • External drives connected by users

We search for:

  • GetLogicalDrives β€” returns bitmask of available drives
  • Thread creation with drive-related logic
  • Loop patterns with sleep intervals

Analysis

Looking at thread creation in the main function:

Thread Creation Multiple threads spawned including sub_401CC5

The function sub_401CC5 (0x00401CC5) monitors for new drives:

Drive Monitor Thread GetLogicalDrives loop detecting new drives

1
2
3
4
5
6
7
8
9
10
while ( !sub_405962() )
{
    v3 = GetLogicalDrives();          // Check current drives
    if ( v3 != LogicalDrives )        // If changed
    {
        v4 = v3 & ~LogicalDrives;     // Find NEW drives (bitwise AND NOT)
        // ... encrypt new drives
    }
    Sleep(0x3E8u);                    // Sleep 1 second (0x3E8 = 1000ms)
}

Algorithm breakdown:

  • GetLogicalDrives() returns a bitmask (bit 0 = A:, bit 2 = C:, etc.)
  • v3 & ~LogicalDrives isolates only the new bits (new drives)
  • Checking every 1 second ensures rapid response to new storage

When a new USB drive or network share appears, the malware immediately encrypts it β€” even during an active attack.

Answer: 0x00401CC5


Q11 β€” File Size Threshold

Question

The file size is compared to a specific value. Could you provide this value?


What we look for

Ransomware must balance encryption speed vs thoroughness:

  • Small files β€” encrypt entirely (fast anyway)
  • Large files β€” partial encryption (faster, still destroys data)

We search for:

  • File size APIs (GetFileSize, GetFileSizeEx)
  • Comparison operations before encryption function calls
  • Branching logic selecting different encryption routines

Analysis

Following xrefs to GetFileSizeEx:

GetFileSizeEx Xref GetFileSizeEx called from sub_408EBE

In sub_408EBE (0x00408EBE), the comparison:

File Size Comparison Comparison: v10.QuadPart < 0x180000

1
2
3
v7 = (a5 & 1) != 0 || v10.QuadPart < 0x180000uLL
   ? sub_408782(...)    // Small file: FULL encryption
   : sub_408C42(...);   // Large file: PARTIAL encryption
ValueFormat
0x180000Hexadecimal
1572864Decimal
1.5 MBHuman readable

Why 1.5 MB?

  • Files under 1.5 MB are encrypted entirely β€” ensuring complete destruction
  • Larger files (databases, archives, VMs) only have portions encrypted
  • This drastically speeds up encryption while still rendering files unusable
  • A 10 GB database encrypted in chunks is just as unrecoverable as fully encrypted

Answer: 1572864


Summary

QuestionAnswer
Q1 - Hashing AlgorithmCRC32
Q2 - .cdata Checksum0xD55F8833
Q3 - Malware Versionv2.9.1
Q4 - Masqueraded DLLole32.dll
Q5 - First API CalledCreateProcessW
Q6 - Process List Decrypt Address0x004022FB
Q7 - Security Disable Commandnetsh advfirewall set currentprofile state off
Q8 - Persistence Function0x00401236
Q9 - C2 ProtocolHTTP
Q10 - Drive Monitor Thread0x00401CC5
Q11 - File Size Threshold1572864

Challenge completed. Stay safe, and always analyze malware in isolated environments.

This post is licensed under CC BY 4.0 by the author.