Skip to main content

How to quickly fix a base64-infected website

Base64 attacks are becoming more and more common these days. They involve exploiting a PHP vulnerability on a website and injecting malicious, base64-obfuscated code. The main targets
of such attacks are poorly coded plugins that feature security holes.
The encoded code is decoded when the infected .php file is loaded and the actual attack is carried out. A popular attack is to forward a website to another page, which grants the attacker an affiliate
bonus.
Here is an example of what a base64 hack looks like in a .php file:
eval(base64_decode
("dGhpcyBpcyBhIHRlc3Q=")); – this code will output "this is a test" when decoded.
A regular base64 code snippet will be significantly longer.
On our web hosting platform, there are several ways to deal with such hacks:

Restore a backup
With our cloud hosting accounts, we offer multiple daily backups, so anyone can easily revert to a previous version of a website with just a click. And we keep backups for up to 30 days.

Here is how to choose the correct backup:
– Log into the Hepsia Control Panel and navigate to the File Manager section;
– Head to the folder pertaining to the hacked website;
– Sort the files by modified date;
This way, anyone can see when the files were last updated. When there
are multiple .php files that were updated 10 days ago, simply load an earlier backup with clean versions of those files.
If there are problems restoring a backup, our support team reps will be happy to assist.

Clean the files manually
To clean the files by hand, simply
download them to a computer and clean them using a text editor. The Windows/OSXcompatibleSublimeText or the
Windows-compatible Notepad++, both of which are available for free, will do a great job.

Once the files are downloaded, load them in the text editor and search for any base64 code. To see if there is any base64 code on the website, use the following search term:
eval(base64_decode.
Once you discover an instance, copy the actual code snippet and search again.
Simply replace the code with an empty space to get rid of it. If there are still any other base64 instances, repeat the procedure until non are left.

Regular expressions can also be used to target base64 code on the website. Again, simply replace the regex matches with an empty space to clear them from the pages.

Here is a sample regex search term: /eval\(base64_decode\((.*)\)\);/i

Keep in mind that this type of search with target all base64 instances. This means that if any plugin or element of the site is
using base64 encoding as well, it will also be removed.

Clean the files over SSH
When using terminal access, all infected files can be cleaned with just a few commands over SSH. If SSH access is not enabled for the account, it can be done with a request in the Upgrades section
of the Hepsia Control Panel.

The first thing that needs to be done is to get a sample of the infected base64 code.

Use this as a reference for cleaning all infected files.
See which files are infected by using the following command:
$ find . -type f | xargs grep
"dGhpcyBpcyBhIHRlc3Q="

This command will search for all files in the current folder that contain the following string:
"dGhpcyBpcyBhIHRlc3Q=".
Here is how the output of that command will look like:
./themes/default/single.php:<?php
eval(base64_decode
("dGhpcyBpcyBhIHRlc3Q=));
./themes/default/search.php:<?php
eval(base64_decode
("dGhpcyBpcyBhIHRlc3Q="));


This will list all the infected files in the current folder and its subfolders. Once the list is ready, it's time to eliminate the code.

We'll use the sed program and our
function will look like this:
find . -name "*.php" -print | xargs
sed -i 's@eval(base64_decode
("dGhpcyBpcyBhIHRlc3Q="));@@g'
Use the search function one more time to make sure that all the files are now clean.
If the search returns no results, the
website has been cleaned.

Preventing base64 attacks
As we've noted, a base64 hack will target a vulnerability in the code. So the best course of action is to always keep apps and plugins updated to the latest versions
available. A good rule of thumb is to only download plugins that are actually needed. If a plugin is not used anymore – remove it from the application.

Also, when downloading new plugins, always keep track of the number of downloads and the update dates. If the last update is more than one year old, the plugin in question may be susceptible to
an attack.

---------
At josidelhosting.com we take care of not just you but your site, cause you having a happy clients is you being happy with us. At discount code for all services; OJAJ
Josidel Hosting

Comments

Popular posts from this blog

Windows 10 now on 600 million machines.

Microsoft CEO Satya Nadella told shareholders that Windows 10 has now passed 600 million monthly active users, picking up 100 million since May of this year. This number counts all Windows 10 devices used over a 28-day period. While most of these will be PCs, there are other things in the mix there: a few million Xbox Ones, a few million Windows 10 Mobile phones, and special hardware like the HoloLens and Surface Hub. The exact mix between these categories isn't known, because Microsoft doesn't say. The company's original ambition (and sales pitch to developers) was to have one billion systems running Windows 10 within about three years of the operating system's launch. In July last year, the company acknowledged that it won't hit that target—the original plan called for  50 million or more phone sales a year , which the retreat from the phone market has made impossible. But at the current rate it should still be on track for somewhere in excess of 700 million use...

WZoneLite – A Pretty Cool WooCommerce Amazon Affiliate Plugin .

Everyone wants to make a million dollars by being a blogger. The promise of riches and internet fame is a big draw to doing it for a lot of people, and I’m sorry to say that the reality of being a blogger (even a professional blogger!) is not quite…as financially lucrative as all that. But that’s not to say that it  can’t be –one of the best ways to start your empire is with an Amazon affiliate plugin. For me, the Amazon Associates program has been one of the biggest earners for me over the years. Not only are there CPM ads like Google Adsense (you know, the normal banner ads we all love to hate), but any time someone clicks a link from your site, you get a percentage of  anything  they buy while the token from your site lasts in their browser. If they buy a song, you get a few cents. If they buy a new MacBook Pro and iPhone? You get…a lot more cents. With that in mind, WZoneLite is a  pretty cool WooCommerce Amazon affiliate plugin that syncs everything together s...

Game-changing SEO trends that will dominate 2018.

Changing nature of the rules of the game. As search engines strive to improve the quality of search results, some ranking factors shift shapes, others fall into oblivion, and completely new ones arise out of nowhere. To help you stay ahead of the game in 2018, here’s a list of the most prominent trends that are gaining momentum, with tips on how you can prepare for each. 1. The rise of SERP features Are you assuming a #1 organic ranking is  the  way to get as much traffic as possible? Think again. Increasingly, SERP features (local packs, Knowledge panels, featured snippets and so on) are stealing searchers’ attention and clicks from organic listings. And it’s only fair if you consider the evolution the Google SERP has been through. It has gone all the way from “10 blue links”… … to something that makes you feel like you’re part of a Brazilian carnival. What can you do about it? With the evolution of SERP features, it’s critical that you (a) track your rankings within...