Imagine opening your WordPress site and seeing it infested with spam links! If this has happened to you, then you are the victim of spam link injection – one of the sneakiest and most well-disguised hacks out there.
Now, you could spend your entire day manually removing these links from all your webpages – only to see them return in a few days. We know how frustrating this can be. This is why in this article, we’ll show you the best method of removing spam injections from your site. We’ll also see how you can prevent such website attacks in the future.
But first, let’s see exactly what hackers do to your infected website – using spam link injections.
Signs of a Spam Link Injection
WordPress spam link injection is a hacker’s malicious attempt to infect your top-ranked website pages. By inserting spam links into your website page, hackers try to redirect your website users to their spam websites. They do this to gain a higher ranking for their website pages on any search engine ranking page or SERP.
Here are what hackers do with your infected website:
- Insert spam hyperlinks into website pages. When your users click on these links, they are redirected to unsolicited or spam websites. On other occasions, they insert the spam hyperlinks directly into your database. These links are mostly directed at illegitimate websites selling illegal pharma products.
- Send spam emails to your customers or users – as another form of phishing attacks.
- Display online banners or digital ads for unsolicited products or services on your website.
- Create hundreds or thousands of new web pages on your website.
How does this hack affect your online business? Well, the most direct impact is on your SEO ranking. It may have taken you months or even years to get a higher rank for your website on Google or other search engines. All that effort is wiped out in a matter of days. Besides, your site could be suspended by your web hosting company, or even blacklisted by Google.
This is serious business. So, let’s understand how you go about fixing a website infected by spam link injections.
How to Clean Your Infected Website from Spam Link Injections
As mentioned earlier, it is an arduous task to remove every spam link from your website and database files. To effectively clean your infected site, you can use either of the following methods:
- Automatically: using a security plugin or tool
- Manually: through manual scanning and cleanup of your site and database
Next, let us look at each of these methods in detail – along with their pros and cons.
Method 1 – Automatically Using a Security Plugin
This is a much faster method of detecting and cleaning your site from any spam link injections. Once you have installed the security plugin, the automatic process can be completed in less than 5 minutes.
Thanks to WordPress’s global popularity, there are several free and paid WordPress security plugins available in the market. While we do not recommend free plugins, you can always opt for paid tools like Sucuri, Wordfence, or MalCare. The best part about these tools is that they are easy to install and use – even for novice users with minimal WordPress technical know-how.
For example, here is how you can use the MalCare security plugin for your website:
- Register with MalCare using your email address.
- Next, log into the MalCare dashboard using the registration link sent to your email address.
- Specify your website URL, then install the MalCare plugin automatically.
- Once the plugin is installed, it will automatically scan your specified website for any infections.
- All you need to do next is to click “Auto-Clean,” and the tool will take care of all your infected files – and clean your entire website and database.
This entire process would not take more than 5 minutes. So, in just a few minutes, you can get rid of all those spam link injections from your website.
From our experience, we recommend the MalCare tool as it can find all spam links in just a few minutes – irrespective of the size of your website or database.
Method 2 – Manual Scanning and Cleaning
As compared to using a security plugin, the manual method of scanning and cleaning is far more technical and requires you to have more advanced WordPress know-how – for troubleshooting in case things go wrong.
Here are the steps that you need to perform to scan and remove the spam link infection from your site:
- The first step is to take a complete backup of your site and database. This step is necessary to avoid the risk of losing all your website files if your manual process runs into any problem.
For easy backups, you can install and use a backup plugin like BlogVault designed especially for WordPress websites.
- Next, log into your host account and navigate to the “File Manager” tool in cPanel. Using your File Manager, open the “public_html” folder, which is the WP installation folder.
Here, you can view three crucial folders – wp-admin, wp-includes, and wp-content – that hackers commonly target to insert spam links.
- Next, you need to search for any spam link codes in every file located in these three installation folders.
- Once you find them, you need to delete them from the file.
This should take care of all your spam links directly present on your site.
- The next step is to check for spam links inserted into your database. For that, open the phpMyAdmin tool from your host’s cPanel tool.
- Select and export your database file to be downloaded on your computer.
- Open the database file as a text file – and search for PHP functions like base64_decode, eval, or gzinflate – that hackers commonly use to infect with malicious code.
- Finally, you can clean your database by finding and removing any malicious code from these functions or deleting the infected database record.
- Import the clean database file back to your site using the phpMyAdmin tool.
As you can see, the manual method is rather complicated and time-consuming.
After getting rid of the spam link injection, you have to ensure that your website is never infected again. Next, we shall list some preventive measures to avoid any future attacks on your site.
How to Prevent Future Attacks on Your Website
To prevent future spam link injections on your site, we recommend that you implement the following preventive measures on your site and the WP Core, installed plugins/themes, and your hosting:
- WordPress site:
- Update your WP version to the latest available version.
- Enforce the use of strong user credentials for all your users – including admin users.
- Invest in a reliable backup tool like BlogVault.
- Protect your login page by implementing two-factor authentication and limiting the number of failed logins using the CAPTCHA tool.
- Limit the number of users with “admin” privileges – and assign lesser user roles (like subscriber or editor) to other users.
- Use hardening measures like disabling file editors or changing your security keys.
- WordPress plugins/themes:
- Update each plugin/theme to the latest available version.
- Remove any unused or abandoned plugins/themes from your installation.
- Always download all your plugins/themes from trusted sources – and never use nulled or pirated plugins/themes.
- WordPress hosting:
- If your website is currently hosted on a shared host, consider moving it to a more secure managed hosting platform.
As discussed, spam link injections are among the common types of attacks hackers launch on the site. Considering the effect they have on your website’s SEO ranking, it’s important that you are equipped with the knowledge and tools to remove and prevent these hacks on your site.
looking for a complete WordPress Maintenance Plan?
With all ThriveWP care plans, we include free migration, malware removal, daily/hourly backups, plugin theme and core updates, ongoing support and 24/7 security monitoring and firewall.
The immediate step in case of a hack is to clean your site. Manual scanning and cleaning methods are quite complicated – and not suited for non-technical WP users. On the other hand, a security plugin is easy to implement and saves you both time and effort.
As a step further, we highly recommend investing in a WordPress security plugin to prevent any future attacks on your site. In fact, most plugins even offer most of the preventive measures listed in this article integrated into their offerings. Or, you could invest in an affordable WordPress support and maintenance service like ThriveWP for businesses of all sizes – that does all this and more for you.
Have you had an experience with a spam hack? We would love to hear from you. Share your comments, suggestions or any questions you have – and we will respond to you in good time.