Maintenance
Stopping SEO Spam Hacks From Coming Back After a Cleanup
Japanese keyword, pharma and casino spam hacks have a habit of returning weeks after a cleanup. Here is why they come back, what a cleanup that holds involves, and how to clear the spam from Google and catch any reinfection early.

SEO spam is the hack that refuses to stay gone. Thousands of pages selling replica goods, pharmacy products or gambling appear under your domain in Google, someone cleans them up, and a few weeks later they are back, sometimes with a different keyword set. Each round costs more search visibility and more trust from Google, and the frustrating part is that the cleanup usually looked thorough.
Repeat infections are a large share of the cases that reach our hacked website cleanup and security team, and the reasons they come back are remarkably consistent. This article is about breaking that cycle: what a cleanup has to remove beyond the visible spam, how to clear the damage from search results, and how to notice quickly if anything returns. If you have only just discovered a hack, the priority is containing it and preserving evidence; this article picks up after that.
How SEO Spam Hacks Work
The attacker is not interested in your site's content. They want its reputation with Google. Common variants include:
- The Japanese keyword hack, which generates large numbers of pages with Japanese text and links to counterfeit shops.
- Pharma and casino hacks, which inject links or whole pages targeting those keywords.
- Cloaking, where real visitors see your normal page but search engine crawlers are served spam. This is why the site often looks fine in a browser while search results are full of junk.
- Injected sitemaps, sometimes submitted through a Search Console account the attacker has verified for your domain, so Google finds the spam pages faster.
The generator behind these pages is usually a small PHP script, a few rows in the database, or a rewrite rule. Deleting the visible pages without removing the generator achieves very little.
Why the Spam Comes Back
When an infection returns, one of these is almost always the cause:
- The entry point was never closed. A vulnerable plugin, a nulled premium theme, an abandoned extension or a reused password let the attacker in. Removing the spam without fixing that leaves the door open for the same automated tool to walk back in.
- A backdoor survived. Attackers leave several ways back in: obfuscated PHP in the uploads folder, a fake plugin with a believable name, code appended to a theme's functions.php, a must-use plugin, a modified .user.ini or .htaccess that loads a file before every request, or encoded code stored in the database options table.
- A hidden administrator or scheduled task remained. One extra admin account, or a cron job that re-downloads the payload every night, undoes the cleanup automatically.
- A neighbouring site was infected. On shared hosting, several sites often run under the same system user. An old staging copy or a forgotten second site in the same account can reinfect the main one.
- The backup was already infected. Restoring a copy from before the spam appeared does not help if the backdoor was planted earlier.
A Cleanup That Holds
On WordPress, which is where we see most of these cases, a cleanup that holds looks like this:
- Find the entry point first. Access logs show which URLs received suspicious POST requests around the time the first spam files appeared. Matching that against plugin versions usually identifies the vulnerability.
- Replace, do not repair. Reinstall WordPress core, every plugin and the theme from clean sources rather than editing infected files. wp core verify-checksums and wp plugin verify-checksums in WP-CLI flag modified files for anything from WordPress.org; premium plugins need fresh downloads from the vendor.
- Search everything that cannot be reinstalled. The uploads folder should contain media, not PHP. The database needs checking for injected options, posts and users. Custom theme code needs a line-by-line review against version control or a known-good copy.
- Clear every account. Remove unknown CMS users, reset all passwords, regenerate WordPress salts, rotate database and SFTP credentials, and remove any Search Console owners you do not recognise.
- Check the whole hosting account, including staging copies, old installs and cron jobs at the server level.
Where the site is built on custom code or a heavily modified theme, rebuilding it cleanly from version control is sometimes faster and safer than auditing it file by file; our WordPress development team handles both.
Clearing the Spam From Search Results
A clean site can keep showing spam in Google for weeks unless you help the search engine catch up:
- Let spam URLs return 404 or 410. Do not redirect them all to the homepage; Google tends to treat mass redirects of irrelevant URLs as soft 404s, and the spam stays associated with your site for longer.
- Use the Removals tool in Search Console to hide the worst URLs or URL prefixes temporarily while Google recrawls them.
- Submit your genuine sitemap again and delete any sitemaps the attacker submitted.
- Request a review from the Security Issues report if Google flagged the site, and only once the cleanup is verified.
- Check titles and descriptions of your real pages in search results; injected metadata on legitimate pages is easy to miss.
Recovery of rankings is gradual and not guaranteed to be complete. Our technical SEO team can track recrawling and fix any indexing problems the hack left behind, and the technical SEO checklist covers what a healthy site should look like afterwards.
Hardening So the Next Attempt Fails
- Remove plugins and themes you are not using, including deactivated ones, and replace anything abandoned by its developer.
- Never use nulled or pirated premium plugins; they are a common source of pre-installed backdoors.
- Block PHP execution in the uploads directory at the web server level.
- Set DISALLOW_FILE_EDIT in wp-config.php so the built-in theme and plugin editor cannot be used to plant code.
- Enforce two-factor authentication for every administrator and limit admin accounts to the people who need them.
- Put a web application firewall in front of the site and keep server software current; our server management service covers PHP versions, permissions and isolation between sites.
Monitoring That Catches a Return Early
Even a good cleanup deserves a period of close watching. File integrity monitoring that alerts on new or changed PHP files, email notifications when an administrator account is created, Search Console alerts for new owners and security issues, and a regular site: search for unfamiliar URLs will spot a reinfection within hours rather than weeks. These checks are built into our website maintenance plans, and an independent review, as described in what a website security audit covers, is worth considering if the entry point was never conclusively identified.
If spam keeps reappearing on your site despite earlier cleanups, get in touch with your domain and a rough timeline of the infections. We will find out what is bringing it back.
Frequently Asked Questions
Why can I not see the spam pages when I visit my own site?
Many SEO spam hacks use cloaking. The injected code checks the user agent or IP address of each request and serves spam only to search engine crawlers, while normal visitors and logged-in administrators see the real site. The URL Inspection tool in Google Search Console shows the page as Googlebot fetches it, which usually reveals what is really being served.
Will my rankings recover after an SEO spam hack is cleaned?
Usually they recover substantially once the spam is removed and Google has recrawled the affected URLs, but it is gradual and there is no guaranteed timescale or full recovery. Sites that were reinfected several times, or that carried a manual action, tend to take longer. Keeping the site clean and returning proper 404 or 410 responses for the spam URLs helps the process along.
Is it safe to reuse our premium plugin files after a cleanup?
Not the copies that were on the infected server. Download fresh copies of every premium plugin and theme from the vendor using your licence, and replace the old folders entirely. If the plugins were obtained from unofficial sources or nulled, replace them with licensed versions or alternatives, because those packages frequently contain backdoors from the start.
Do we need to move to a new hosting account after repeated infections?
Not always, but it is worth considering. If the site shares a hosting account with several old or unmaintained installs, or the host does not isolate sites from each other, a fresh, isolated account with only the cleaned site on it removes a whole class of reinfection routes. It also gives you a clean baseline for file monitoring.











