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

Services
Capture
Managed Detection & Response

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

twi-managed-portal-color
Co-Managed SOC (SIEM)

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

twi-briefcase-color-svg
Advisory & Diagnostics

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

tw-laptop-data
Penetration Testing

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

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

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

tw-officer
Digital Forensics & Incident Response

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

tw-network
Firewall & Technology Management

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

Solutions
BY TOPIC
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
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
SpiderLabs Blog

Digging Deep into Magecart Malware Part II

Magecart is the name given to notorious groups of hackers that target online shopping carts, usually Magento. We provided an overview of the group's malware last year and earlier this year, we shared details of a specific Magecart malware case we encountered during the course of an investigation. In this second installment of “Digging Deep into Magecart Malware”, we highlight a couple more Magecart attacks that we encountered during investigations. In our first case, we discuss how the Magecart attackers were able to compromise an e-commerce website and install a server-side PHP script to intercept customer data from the store’s checkout page. And in the second case, we take a closer look at a domain used to exfiltrate data by the attacker that we believe was a compromised server.

Episode I

Most of the time, Magecart attacks we have encountered are malicious client-side JavaScripts that are inserted into a compromised e-commerce website. Commonly, these “card skimming” JavaScripts are heavily obfuscated and hosted at a third-party web server which may either be compromised or hosted by the attackers themselves. However, there are few attack types we encounter that use server-side PHP scripts to intercept sensitive data. Take for example this PHP script:

Figure 1: Malicious PHP Script that intercepts the customer and credit card data from the checkout page

Figure 1: Malicious PHP Script that intercepts the customer and credit card data from the checkout page

 

This script was found in a seemingly innocent path in an undisclosed e-commerce web server.

Figure 2: Malware path in the web server

Figure 2: Malware path in the web server

 

The PHP script was planted by the attacker to intercept information, including credit card details and billing information entered by their customer in the checkout page. The information collected is as follows:

  • Customer name
  • Email address
  • Physical address
  • Telephone number
  • Credit card information

Each of the items are delimited with a vertical bar character “|” then encoded with simple Base64 encoding. This encoded data is then saved to a fake image file of which the path was set to ‘/media/wysiwyg/<compromised website domain>5944.jpg

How did the attackers exfiltrate this data? Well, they planted a web shell to access the files, specifically WSO version 4.2.5. WSO is a full-featured PHP web shell that is used by attackers to maintain persistent access to a compromised web server.

Figure 3: WSO web shell's console

Figure 3: WSO web shell's console

 

So how did the e-commerce website got compromised, you may ask? – the attacker exploited a vulnerability in a Magento utility installed in the webserver called Magento Mass Importer (Magmi). The attack exploited a local file inclusion (LFI) vulnerability in a PHP script component that allowed the attacker to retrieve the credentials for the e-commerce website’s Amazon Relational Database Service (AWS RDS) instance. It also allowed the attacker to execute a Wget command to download a web shell into the webserver that enables the upload additional malicious PHP scripts.

 

Figure 4. Web server log shows a "Local File Inclusion" attack

Figure 4. Web server log shows a "Local File Inclusion" attack

 

On a side note, this was not the first vulnerability in Magmi that was discovered, we also reported back in October 2015 of another vulnerable component “download_file.php” which was also vulnerable with LFI.

Figure 5. a vulnerability in download_file.php discovered by SpiderLabs

Figure 5. a vulnerability in download_file.php discovered by SpiderLabs

 

Moving on, the technique of dumping stolen data to a local drive and then exfiltrating it later on, is nothing new. In 2016, it was reported that over 6000 online stores were infected with the Visbot malware that uses a similar technique. Visbot, however, uses stronger asymmetric encryption to encrypt stolen data and the fake image file, where the dumped data is saved in one of the compromised web server’s publicly accessible folders. In our case, the attacker had complete access to the webserver by planting a web shell and they also opted to use a simpler Base64 algorithm for encoding the stolen data.

Episode II

Another case we encountered was a Magecart infection in a couple of online stores based in Australia. These two e-commerce websites were hit with malicious “card-skimming” JavaScripts. Both incidents involved JavaScripts injected into the websites that were externally hosted at the same domain: darvishkhan[.]net

Figure 6: Injected Magecart JavaScript in compromised e-commerce website

Figure 6: Injected Magecart JavaScript in compromised e-commerce website

 

With the usual Magecart tactic, the JavaScript skims customer information and credit card details from the checkout page and the stolen information is then encoded twice with Base64. The data is then exfiltrated through an HTTP POST tunnel to the attacker’s domain.

Fig7

Figure 7: HTTP POST header and body containing the exfiltrated information
 

Fig8

Figure 8: Decoded exfiltrated data

 

We took a closer look at this exfil domain darvishkhan[.]net and found another infected e-commerce website based in Mexico.

 

Figure 9: Injected Javascript in an Mexican e-commerce website

Figure 9: Injected Javascript in a Mexican e-commerce website
 

The darvishkhan[.]net domain was also mentioned in a blog from a Korean security firm ESTSecurity. The domain once hosted a malicious file which ESTSecurity linked to Lazarus APT group. 

However, this exfil domain seems to be a compromised website based in Iran which sells musical instruments.

Figure 10: Brick and mortar shop of darvishkhan.net

Figure 10: Brick and mortar shop of darvishkhan.net

 

Using a compromised webserver help attackers hide and make them more difficult to track. It also helps that they used legitimate looking names in their JavaScripts such as “google.tag.min.js” or “gtm.min.js”. As this server is also an e-commerce website, it is also possible that customer information in this website may have also been compromised. On that note, we have notified darvishkhan.net regarding this issue but haven't heard from them yet.

Episode I IOCs:

File

SHA256

Skimmer PHP

31AC68194FA993214E18AA2483B7187AAD0CB482667EC14A7E9A0A37F8ED7534

Skimmer PHP

8B30223133EFAA61DDABF629E3FD1753B51DDB1E5E3459F82A72BA31F78BD490

WSO Webshell

06305ACBF12150DCC8DAE68E1F7A326558661F1EDC9F49149D38C7450DC37654

 

Episode II IOCs:

  • hxxps:// darvishkhan [dot] net/wp-includes/js/dist/gtm.min.js
  • hxxps:// darvishkhan [dot] net/wp-content/plugins/zendesk/google.tag.min.js
  • hxxps:// darvishkhan [dot] net/wp-content/plugins/zendesk/index.php

 

Thanks to Alejandro Baca and Damian Lazarus for providing us additional information

Latest SpiderLabs Blogs

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

The Secret Cipher: Modern Data Loss Prevention Solutions

This is Part 7 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here. Far too many organizations place Data Loss Prevention (DLP) and Data...

Read More

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

Overview A command injection vulnerability has been discovered in the GlobalProtect feature within Palo Alto Networks PAN-OS software for specific versions that have distinct feature configurations...

Read More