04 Jun 2020

Stealing WordPress credentials

Yesterday WordFence published a scary article titled "Large Scale Attack Campaign Targets Database Credentials". Article describes a recent mass-scanning attack of WordPress sites. The purpose of the attack was stealing WordPress configuration files - and therefore usernames/passwords of WordPress admins.

As with the XSS campaigns, almost all of the attacks are targeted at older vulnerabilities in outdated plugins or themes that allow files to be downloaded or exported. In this case the attackers are attempting to download wp-config.php, a file critical to all WordPress installations which contains database credentials and connection information, in addition to authentication unique keys and salts.

Since WordFence is in the business of selling "the best WordPress security", they have little intention to explain how these attacks really work.

Instead, they blatantly advertise their product as a remedy for everything:

All Wordfence users, including sites running the free version of Wordfence, and Wordfence Premium, are protected against these attacks.

That's really not helpful, so let me fix that. smile

Look at the logs

I started by downloading logs from my web server and checking them for the string wp-config.php, like the article suggests. There was not a single error code 200 which would indicate successful exploitation. Lucky me!

However, these types of attacks are not new. There were several attacks in February and April and 3 attacks in May alone. In last 6 months, there have been 1598 attempts using 623 different URIs. That's a lot of data to process and it's quite repetitive, so I'll cover just the latest attack.

Attack on 29-May-2020

322 requests came from a single IP address between 16:59 and 17:01 GMT+2. Apparently, attackers don't give a crap about being stealthy and flying under the radar. Server is located in Poland, hosted by OVH and was most likely hacked.

On 30-May-2020, the same attack was repeated from IP address - server hosted in Vietnam, again most likely hacked.

Initial recon

In this phase attackers fetch main page of the blog and try to download backup files from well-known URIs. First request has user-agent "Go-http-client/1.1", all the rest have user-agent "Mozilla". Yes, just "Mozilla".

For each file name, they try 5 extensions: .zip, .gz, .tar.gz, .rar and .gzip:

I left just one entry for all remaining file names to keep it brief:

I have no idea what "lifewithouthealthinsurance.com.zip" does here. Perhaps attack script f*cked up my domain name during the attack? smile

Testing your specific WordPress theme

Next stage of attack uses name of your WordPress theme and tries to find a vulnerable download script within the theme. Attackers try 2 variations each time - one with the filename, other using php://filter/read. I left just one of the variations for brevity.

User-agent is still "Mozilla".

Backups of wp-config.php

Then attackers try to find backup copies of wp-config.php and log files with sensitive information. These and following attacks alternate between user-agent "Mozilla" and outdated version of Chrome: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.59 Safari/537.36"

Misconfigured scripts in wp-admin folder

Next come attempts to locate buggy scripts in wp-admin folder. There are 2 requests for each vulnerability, one with the filename, other with php://filter/read:

Vulnerable WordPress plugins

Just like earlier - 2 entries for each, one with the filename, other with php://filter/read:

Vulnerable WordPress themes

And last but not least - trying to exploit vulnerable WordPress themes. 2 variations again:


Here you have it, not only "WHAT" is happening during this attack but also "HOW" it's done.

Based on my quick Google results, none of these exploits are new or innovative. But someone has spent a lot of time to put it all together in one tool and use it for mass scanning. Considering that WordPress is the world's most popular CMS with 35%+ market share, such mass scan will probably find a lot of holes in poorly maintained websites.

So, please make sure your WordPress is up-to-date!

Stay safe! smile

5 thoughts on “Stealing WordPress credentials

  1. Very nice analysis.

    Thanks for all the details that "the best WP security" thinks we need not to know, just trusting them :)

    Lesson learnt? I shall not save my backup files in common locations and/or with too common/expected extensions :)

    Best Regards,

  2. Really well written. Thanks :)
    Im a CyberSec enthusiast so this one really interested me.
    Some noticed: the IP from Vietnam pointed to a datacenter of a big company. No idea how can they be so careless and be hacked.

    • It's not the fault of the hosting company. They cannot be responsible for bad security practices of their clients.

Leave a Reply

  • Be nice to me and everyone else.
  • If you are reporting a problem in my tool, please upload the file which causes the problem.
    I can`t help you without seeing the file.
  • Links in comments are visible only to me. Other visitors cannot see them.

Your email address will not be published.

 −  six  =  2