CVE-2024-3400: PAN-OS Command Injection Vulnerability in GlobalProtect Gateway. Learn More

CVE-2024-3400: PAN-OS Command Injection Vulnerability in GlobalProtect Gateway. Learn More

Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Offensive Security
Solutions to maximize your security ROI
Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Petya Ransomware: A glimpse of the past, the present, and the future

Ransomware seem to be the trend now and this type of malware will no doubt continue to grow. But do you still remember in the 90's when boot viruses were the norm? These malwares typically infect the boot sector of floppy and bootable drives just to display annoying things. How about 10-15 years ago when most worm malware used exploits to spread either thru SMB or DCERPC? What if you mix everything, the past and the present? You'll end up with Petya and the future.

In the last few days a destructive new Petya ransomware strain arose after earlier variants became notable last year which infected the MBR to display a ransom note. One noticeable behavior of previous Petya variants is that they only encrypted the MFT (Master File Table) to make the file system unreadable. In contrast, the new variant now also uses the typical ransomware file encryption. And in comparison to WannaCry, this new Petya does not just use the EternalBlue exploit for propagation, but also uses shared folders to spread through the network. It also uses legitimate tools like PSExec and WMI to execute Petya malware remotely. It is these features which allowed the malware to spread quickly in an internal network, regardless of whether systems were patched with the MS17-010 patch.

To further appreciate this new exciting malware, we took a deep dive into it to map out exactly what it is doing. Here is the overview of infection process.



Infection Vector

There were initial reports suggesting emails and documents related to the new Petya but based on data from our Spam Research Database there is no evidence of such. Others have suggested that the DLL (perfc.dat) was executed thru an exploited Ukrainian taxation software called MeDoc.

Technical Walkthrough

Even without the main loader from the MeDoc Software, one can execute the DLL by calling the lone exported function using the rundll32.exe with the equivalent ordinal number #1. (These ordinal numbers are a chronological representation of each exported API functions within each DLL).

C:\Windows\system32\rundll32.exe perfc.dat #1

Setting up Privileges

To make sure the malware can perform most of its malicious behaviors, it needs to check and adjust the required privileges of SeShutdownPrivilege, SeDebugPrivilege, and SeTcbPrivilege.


Note that the extent of the privilege that malware can attain will affect how it will perform other malicious behavior and how it can perform a system shutdown.

Detecting AV Process

Petya next performs a process enumeration, and, by using its own propriety algorithm, it computes the hash of each process name that is currently running. It compares each hash with the following hardcoded hash related to AV processes.

0x2E214B44 – AVP.exe

0x6403527E – ccSvcHst.exe

0x651B3005 – NS.exe


Infecting the MBR

If the malware has achieved a "SeDebugPrivilege" it will perform the following:

  1. It checks if the machines have already been infected. If the file path "C:\WINDOWS\perfc" already exists it will terminate the process. This could be a possible "kill-switch" to avoid further infection.10900_9ee64687-91d9-4d50-a5f8-08661fe8265f
  2. It infects the MBR thru \\.\PhsysicalDrive0 and writes the malicious code by chunk.BSL_7689_04079d74-7163-40eb-a59e-287d203465f6

Creates Scheduled Task

It creates a scheduled task to perform a System Shutdown an hour later. Just enough time to finish the propagation routine so as to infect other machines on the network.


Scans the Local Address

It scans the local network for possible targets.


Loads files from the Resource

From the resource section of the DLL, it will load RT_RCDATA #1 and drop it in the user's temp folder as {random}.tmp. At the same time, a thread will be triggered to create a new pipe which will allow for the *.tmp file to connect and send out information.

Currently, we are still investigating this *.tmp file as it behaves like a trimmed down Mimikatz by opening and reading the LSASS memory space.


Another file will be loaded from the resource (RT_RCDATA #3) and will be dropped as dllhost.dat in the windows directory. This file is a legitimate PSEXEC tool from Sysinternals.



There are multiples ways the malware tries to spread itself and one of them is through network shares by performing the following:

  1. Enumerate all available network shares using WNet* APIs.10418_8826fd47-632a-4505-b96e-6a4c11b6d427
  2. It gathers credentials either a hostname or IP address from the Credential Store used by Remote Desktop.BSL_11810_cab082d4-fff4-42cb-bf35-12388dc8aec3
  3. Locate ADMIN$ shares in the local network and attempt copying of itself to those shared folder:BSL_12063_d75de6bf-a6fd-4cbe-abc2-ca75f43d36e7
  4. Attempt to run a copy of itself in the remote host using PSEXEC (dropped as dllhost.dat in %windows%)
  5. Also, it attempts to execute a copy of itself in the remote host using WMIC.exe9468_5b2f24b4-2e4e-4a9c-a92f-5fd7bf9c4b78

Another way to spread is to perform an SMB attack using the EternalBlue exploit.


File Encryption

Petya ransomware performs the following to encrypt the files:

  1. It retrieves all fixed logical drives
  2. A new thread will be created for each drive that will do the following:
    1. Gets a CSP – Microsoft Enhanced RSA and AES Cryptographic Provider
    2. Generates a customized key
    3. Traverse all directories and encrypt files which meets the following criteria:
      • If it is not a Directory or a Symbolic Link
      • If the files are not within the C:\WINDOWS directory
      • If has the following file extensions:


    4. Creates a ransom note file.


Covering the tracks

To cover its tracks and make it hard for forensics, Petya will execute the following:

  1. WEVTUTIL to delete the following event logs:
    1. Setup
    2. System
    3. Security
    4. Application
  2. FSUTIL to delete USN journal which keeps track of the changes within the disk volume.



Whether this is Petya or NotPetya, here in Trustwave SpiderLabs we believe that this malware is tailor-made to avoid a bunch of current security protections. It has used a DLL where the codes are within the export function which helps avoid it being executed in a sandbox. It infects the ever vulnerable MBR. It has several methods to spread without user-triggered events, and even tries to execute itself remotely using non-malicious software. It even covers it tracks to avoid forensics experts digging deep into how the system is being infected. We must admit that this malware has done a pretty good job knitting things together from the past to perhaps create an insight of what's ahead.

Latest SpiderLabs Blogs

EDR – The Multi-Tool of Security Defenses

This is Part 8 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More

The Invisible Battleground: Essentials of EASM

Know your enemy – inside and out. External Attack Surface Management tools are an effective way to understand externally facing threats and help plan cyber defenses accordingly. Let’s discuss what...

Read More

Fake Dialog Boxes to Make Malware More Convincing

Let’s explore how SpiderLabs created and incorporated user prompts, specifically Windows dialog boxes into its malware loader to make it more convincing to phishing targets during a Red Team...

Read More