What an SEO spam hack is
Attackers break into WordPress sites to borrow their reputation in Google. Your domain has history and trust; a brand-new spam site doesn’t. So they use yours to publish thousands of pages selling fake goods, pills, gambling, or links to their other sites. The best-known version is the Japanese keyword hack, which fills your search results with Japanese-language product pages. Pharma and gambling spam work the same way.
The spam usually doesn’t appear in your WordPress dashboard, and your visitors don’t see it either. It’s served only to search engines, a trick called cloaking.
The most common variants I see are the pharma hack (pages for viagra, cialis, kamagra and other pills), gambling and casino spam, payday loan spam, the Japanese keyword hack, and Chinese or Russian spam. They all work the same way, and a site “infected with SEO spam” usually has several of them at once.
How to confirm it
- Search Google for
site:yourdomain.com. Then add words like viagra, casino or replica. Pages you never wrote mean an infection. - Open Search Console → Pages. A sudden jump in indexed pages is a classic sign. One site I’ve seen went from about 60 indexed pages to several thousand in a few days.
- Use URL Inspection → Test live URL on one of the spam URLs. If Google sees spam where your browser sees a normal page, the site is cloaking.
- Open Settings → Users and permissions. Any owner you don’t know is a red flag.
Where the spam comes from
| Part of the hack | What it does |
|---|---|
| A spam generator | PHP code, often in the theme, a fake plugin, or a file in the site root, that creates spam pages on request |
| Cloaking code | Checks if the visitor is Googlebot and serves spam only then |
| Spam stored in the database | Thousands of hidden posts, or spam content stored in options or custom tables |
| Rogue sitemaps | Fake sitemap files submitted to Google to get the spam indexed quickly |
| Hijacked Search Console | The attacker verified ownership of your site to control indexing |
| Backdoors | Hidden files that let the attacker put it all back after a cleanup |
How I remove SEO spam
- Find the generator and cloaking code, by comparing what Googlebot sees with what you see, then tracing it back to the code.
- Remove the stored spam from the database without touching your real content.
- Remove the backdoors and anything that would restore the spam, then find and close the entry point.
- Take back Search Console. I’ll help you remove unknown owners and their verification files, delete rogue sitemaps, and submit your own clean one.
- Make spam URLs return 404 or 410, so Google knows they’re gone for good.
- Speed up the cleanup in Google with the Removals tool for the worst URLs, and a review request if Google flagged the site as hacked.
A typical case: a small business notices its traffic dropping and its Google results suddenly showing Japanese product pages. The site itself looks fine. Search Console shows two Gmail accounts the owner has never heard of listed as verified owners, and indexed pages jumped from about 60 to several thousand in one week. The cause is a spam generator hidden in a fake core file plus a cloaking check, installed through an outdated plugin. Removing them, kicking out the fake owners and submitting a clean sitemap stopped the spam the same day. The Japanese pages dropped out of Google over the following weeks.
What recovery looks like
Expect the site to be clean right after the cleanup, and Google to catch up gradually. Spam URLs drop out over a few weeks as Google recrawls them. If Google flagged the site with a “This site may be hacked” warning, the review after cleanup can take several weeks. For more on the recovery side, see hacked website recovery.