Trustwave's 2024 Retail Report Series Highlights Alarming E-Commerce Threats and Growing Fraud Against Retailers. Learn More

Trustwave's 2024 Retail Report Series Highlights Alarming E-Commerce Threats and Growing Fraud Against Retailers. Learn More

Services
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.

Solutions
BY TOPIC
Microsoft Security
Unlock the full power of Microsoft Security
Offensive Security
Solutions to maximize your security ROI
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
Partners
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

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.

BSL_11359_b53035fc-9518-48de-bfcb-a4eefa11484c

 

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.

8614_31ebc714-0361-4439-93f8-5f530e9e9a5f

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

11847_cc678767-9f98-4727-be27-3740982cfef8

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

11856_ccd9f484-46e3-426a-9514-c93676b41b34
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.

BSL_12157_dc9d0d62-2d10-4981-bdc5-de1d4ac55085

Scans the Local Address

It scans the local network for possible targets.

BSL_12645_f25d4e92-1b8a-477e-9396-9fbf212362e1

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.

9876_70270b88-ccac-465f-86b8-a5fd7c6d6de2

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.

11058_a69263ec-0c0b-455a-adab-07fb7616699c

Propagation

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.

BSL_11300_b25d5ead-82ed-421a-a303-c4ba9bd12012

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:

        .3ds.7z.accdb.ai.asp.aspx.avhd.back.bak.c.cfg.conf.cpp.cs.ctl.dbf.disk.djvu.doc.docx

        .dwg.eml.fdb.gz.h.hdd.kdbx.mail.mdb.msg.nrg.ora.ost.ova.ovf.pdf.php.pmf.ppt.pptx

        .pst.pvi.py.pyc.rar.rtf.sln.s.ql.tar.vbox.vbs.vcb.vdi.vfd.vmc.vmdk.vmsd.vmx.vsdx.vsv

        .work.xls.xlsx.xvd.zip

    4. Creates a ransom note file.

BSL_8763_38994668-1120-4f9e-a19c-d2239e5a24e18110_1847e9c4-f904-4781-8072-e52d7c4d67b811411_b79bc2ee-ce54-4c51-bedb-109b102d43a2

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.

BSL_11024_a4a75485-04e5-4c0c-8b74-45b24bd6bf6e

Conclusion

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.

ABOUT TRUSTWAVE

Trustwave is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo