Hackers abused swap files in e-skimming attacks on Magento sites
Threat actors abused swap files in compromised Magento websites to hide credit card skimmer and harvest payment information.
Security researchers from Sucuri observed threat actors using swap files in compromised Magento websites to conceal a persistent software skimmer and harvest payment information.
The attackers used this tactic to maintain persistence and allowing the malware to survive multiple cleanup attempts.
The researchers discovered a suspicious script in the compromised website’s checkout page that had all the usual indicators of malware. The script included base64 encoded variables and hex encoded strings. The experts decoded the script and determined that it was used to capture credit card details.
![software skimmer Magento swap file](https://i0.wp.com/securityaffairs.com/wp-content/uploads/2024/07/image-26.png?resize=770%2C237&ssl=1)
When the checkout button is clicked, a script captures credit card data using the querySelectorAll function. This script also harvest sensitive information like name, address, and card number. The stolen details are sent to the domain amazon-analytic[.]com, registered in February 2024, which has been used in other credit card theft cases. Attackers often use well-known brand names in domain names in an attempt to evade detection.
Upon analyzing the malicious script, the experts noticed an interesting “swapme” file reference. Although initially invisible, using the vi
command revealed a swap file containing the same malware as the infected bootstrap.php
. Attackers used this swap file to keep malware on the server and evade detection. After removing the swap file and clearing caches, the checkout page was clean.
“The swapme part of the file name clued us in that there might be some swap lingering around. When files are edited directly via ssh the server will create a temporary ‘swap’ version in case the editor crashes, which prevents the entire contents from being lost.” reads the report published by Sucuri.
“While we could not see any ~swapme file with the ls command, running a vi command on bootstrap.php-swapme to directly edit the swap file revealed that the file was indeed there, and it contained the exact same contents as the infected version of bootstrap.php. It became evident that the attackers were leveraging a swap file to keep the malware present on the server and evade normal methods of detection.”
The abuse of the swap file system by attackers underscores the necessity of deeper security measures beyond basic scans. The presence of a swap file suggests that the attackers initially accessed to the compromised wesites via SSH or a terminal session. To prevent such persistent malware infections, restrict sFTP, SSH, FTP, and CPanel access to trusted IPs, configure FTP and SSH restrictions on the hosting server, and use website firewalls for additional protection. Experts also recommends of regularly updating your CMS and plugins to avoid vulnerabilities exploited by automated attack tools.
Follow me on Twitter: @securityaffairs and Facebook and Mastodon
Pierluigi Paganini
(SecurityAffairs – hacking, swap files)