Security

Japanese Keyword Hack: The Cleanup Most Guides Leave Half Done

By , Lead SEO & Co-founder 9 min read
A dark server room at night where one rack is overrun by thousands of tiny foreign glowing threads, a technician's cart with a laptop and cutters beside it, half the threads already removed and the cleared side glowing clean cyan, one crimson light

The Japanese keyword hack is the only infection I know of that often brings its own Google account. The attacker fills your site with auto-generated Japanese pages, then verifies themselves as an owner of your site in Google Search Console (Google's free dashboard for site owners), so they can feed Google their spam faster.

That changes the cleanup. Deleting the spam files is step one. You also have to evict a stranger from your Search Console, decide between a 404 and a 410 for thousands of URLs, and understand what the Removals tool can and can't do. Most guides cover the first part and wave at the rest.

This post covers the rest. If you'd rather not spend your evening in .htaccess files, you can describe what Google is showing you in a short questionnaire, and I reply with a plan and a fixed quote within one business day.

What the Japanese keyword hack looks like

You usually notice it one of three ways:

  • A site:yourdomain.com search in Google shows pages with Japanese titles you never wrote, often selling knock-off brand goods.
  • Search Console's Performance report suddenly lists queries in Japanese characters.
  • Search results show "This site may be hacked" under your listing.

Google's own guide to fixing the Japanese keywords hack describes the pattern: auto-generated Japanese text in randomly named folders, usually stuffed with affiliate links. The same guide warns about a nasty trick. Hackers may show you a fake 404 page when you visit a spam URL, while Googlebot (Google's crawler) gets the spam. In Google's words, "Hackers will try to trick you into thinking the page is gone or fixed when it's still hacked."

So your browser is not a reliable witness here. Use Search Console's URL Inspection tool and run a live test on a few of the spam URLs. That shows you what Google actually receives.

Step 1: Find and remove the rogue Search Console owner

This is the step nobody checks, so do it first.

In Search Console, open Settings > Users and permissions. Look at every owner. Google's help page is blunt about it: "If you've found an owner that you don't recognize, you might have been hacked."

Removing the owner is not enough on its own. Here's the catch Google spells out on the same page: as long as their verification token (the small file, meta tag or DNS record that proves ownership) stays on your site, a deleted owner can re-verify. They'd be back by morning.

Here's the full sequence:

  1. Remove the unknown owner in Users and permissions.
  2. Click Unused ownership tokens on that same page. It lists tokens left behind by removed owners. Remove theirs. (Google warns that some tokens are shared with other services, so only remove ones you can tie to the stranger.)
  3. Delete the token from the server. It's often an HTML file in your site root named something like google1234abcd.html.
  4. Check .htaccess for rewrite rules that generate fake verification files on the fly. Google's guide mentions this exact trick. A simple file search won't find a file that doesn't exist until someone asks for it.
  5. Test it. Request a made-up token URL, such as yourdomain.com/google0000test.html. Google's guide says a 404 there means the dynamic token is likely fixed.

While you're in there, open the Sitemaps report. Attackers often submit their own sitemaps (lists of URLs they want crawled). Note every sitemap you didn't create. You'll deal with them after the cleanup.

Step 2: Clean the files, then the .htaccess, then everything else

The Japanese keyword hack is mostly a file problem. The spam pages are usually generated by a PHP script (a small program on your server) plus rewrite rules that route spam URLs to it.

The short version of the file cleanup:

  1. Back up everything first, including the infected copy. Evidence helps.
  2. Replace every .htaccess file with a clean default. There can be more than one. Look in subfolders too.
  3. Reinstall WordPress core, themes and plugins from official sources.
  4. Hunt the generator script. It often sits in a random folder, or hides behind a normal-sounding name. Google's guide suggests looking for obfuscated code that uses functions like base64_decode, eval or gzinflate. My post on what eval(base64_decode) in a PHP file means shows how to read that code without running it.

The full cleanup order, from containment to Google, is in my step-by-step guide to fixing a hacked WordPress site. This post stays on the parts specific to Japanese spam.

Step 3: 410 vs 404 for Japanese spam URLs

Once the generator is gone, those thousands of spam URLs need to return an error status, so Google drops them. You'll see forum threads argue for hours about 404 (not found) versus 410 (gone for good).

Here's what Google's documentation actually says. Its page on HTTP status codes and indexing states that "All 4xx errors, except 429, are treated the same," and that previously indexed URLs returning a 4xx get removed from the index.

So on paper, 404 and 410 do the same job. I still prefer 410 for hack spam, for two practical reasons:

  • It's a deliberate signal. A 410 says "this was removed on purpose." A 404 can also mean a broken link you'd want to fix, so your own crawl reports stay noisier.
  • It lets you answer by pattern. One rule can return 410 for every spam URL at once. That's far faster than deleting pages one by one, and it keeps answering even if the attacker's sitemap keeps sending Google new spam URLs.

Vlad's take: don't lose a day over this. Any 4xx works. What matters is that every spam URL returns one, and that your real pages don't.

A pattern rule for query-string spam

Japanese spam often uses odd query strings (the part of a URL after ?) on your homepage, like /?a8f3k2=10482. WordPress happily serves the homepage for those, with a 200 OK status, so they never die on their own. A rule like this returns 410 instead:

.htaccess / Apache
# Place above the "# BEGIN WordPress" block in the root .htaccess (Apache 2.4 or LiteSpeed).
# Returns 410 Gone when the whole query string looks like "letters+digits=number".
# Could break: real links with a matching query string, such as some ad or email tracking URLs.
RewriteEngine On
RewriteCond %{QUERY_STRING} ^[a-z0-9]{6,12}=[0-9]{3,8}$ [NC]
RewriteRule ^ - [G]

The [G] flag is Apache's built-in way to send 410 Gone, per the mod_rewrite docs. Your spam pattern will be different, so build the regex (pattern-matching rule) from your own list of spam URLs, not from mine.

Then test it from the command line before you trust it:

Terminal
# Read-only checks. The first should print 410, the second 200.
curl -s -o /dev/null -w "%{http_code}\n" "https://example.com/?a8f3k2=10482"
curl -s -o /dev/null -w "%{http_code}\n" "https://example.com/contact/"

Run your real top pages and any tracking URLs from your newsletters through the same test. A regex that eats a real page is worse than the spam.

Step 4: What the Removals tool can and can't do

The Removals tool in Search Console is the most misunderstood part of this cleanup. It feels like a delete button. It isn't.

According to Google's Removals tool help page:

  • A successful request "lasts only about six months."
  • It hides the URL from Google Search, but Google can still crawl it.
  • To make removal permanent, the page must return a 404 or 410, sit behind a password, or carry a noindex tag.
  • Google says not to use robots.txt as a blocking method.

That last point trips people up. If you block the spam folder in robots.txt, Google can't recrawl those URLs, so it never sees your 410. The spam can sit in the index longer.

So here's how I use it: only for the handful of spam pages that show up when people search your brand name. Those are the ones customers see. The 410 rule does the real work on the other 9,000.

Step 5: Sitemaps, then the review request

Remember the attacker's sitemaps from step 1? Two things to know.

First, delete the sitemap files from your server. Second, removing a sitemap in Search Console doesn't make Google forget it. The Sitemaps report help says that deleting a sitemap from the report means Google "won't forget the sitemap or any URLs listed in it." That's fine, because those URLs now return 410. It's just one more reason the 410 rule matters.

Then submit your own clean sitemap, so Google recrawls your real pages quickly.

Only now request a review in the Security Issues report. Explain what you found, what you removed, and how they got in. Google says hacked-spam reviews may require up to several weeks to process. Requesting too early, before the 410s and the owner removal are done, just restarts the clock. I cover the full de-indexing sequence, including how to see your pages as Googlebot sees them, in my post on getting spam URLs out of Google's index.

Why the Japanese keyword hack comes back

This hack has a reputation for returning. Owners delete the spam, it's back in a week, and they assume the cleanup failed. Usually, three things were missed:

  • The rogue Search Console owner. If they're still verified, they can submit new sitemaps the day your site goes back up.
  • A backdoor outside the obvious folders. A second WordPress install in the same hosting account, a cron job (a task the server runs on a timer) that re-downloads the generator, or a must-use plugin.
  • The original hole. Usually an outdated plugin. If it's still there, the attacker just walks back in.

That second point is bigger than it sounds, so I wrote a separate guide on why WordPress malware keeps coming back, with the hosting-account checks I run on every job.

Final thoughts

The Japanese keyword hack is two problems wearing one coat. One lives on your server. The other lives in Google: a stranger with owner access, thousands of indexed URLs, and a sitemap you didn't write. Clean the server, evict the owner and their token, return 410s by pattern, use the Removals tool only for what customers actually see, and request the review last.

It's tedious but very fixable. My hacked website repair service covers both the server side and the Search Console side. If you'd like that, start with the cleanup questionnaire. Standard cleanups start at $350, and I'll tell you what I see before any work starts.

Japanese keyword hack FAQs

Why are there Japanese characters in my Google results?

Most often, your site was hit by the Japanese keyword hack. An attacker added auto-generated Japanese pages, usually selling knock-off goods, and got Google to index them under your domain. Your own visits may look normal because hackers can show visitors a fake 404 while showing Googlebot the spam. Check with the URL Inspection tool in Search Console, and look for unknown owners under Users and permissions.

Should hacked spam pages return 404 or 410?

Either works for Google. Its documentation says all 4xx errors except 429 are treated the same, and previously indexed URLs that return them get removed. I prefer 410 because it marks the removal as deliberate and fits pattern rules, which can cover thousands of spam URLs with one line. The important part is that every spam URL returns a 4xx and no real page does.

How long does it take for Japanese spam to leave Google?

It depends on how fast Google recrawls the spam URLs, and that's usually weeks rather than days. The Removals tool can hide your most visible spam URLs while you wait, but each removal only lasts about six months. A hacked-spam review can take up to several weeks. Large infections with tens of thousands of URLs take the longest.

Can I just block the spam folder in robots.txt?

I wouldn't. A robots.txt block stops Google from crawling those URLs, so it can't see that they now return 404 or 410. Google's Removals help page specifically says not to use robots.txt as a blocking mechanism. Let Google crawl the spam URLs and get the error status. That's how they actually leave the index.

Is the Japanese keyword hack the same as Japanese spam SEO?

Mostly, yes. "Japanese spam SEO" is a looser name for the same campaign: someone uses a hacked site's reputation to rank Japanese pages for products, then funnels the traffic to affiliate or counterfeit stores. The cleanup is the same either way. Remove the generator and backdoors, evict any rogue Search Console owner, return 4xx codes for the spam URLs, and request a review.

Want a second pair of eyes on your site?

Tell me what's going on in the hacked website repair questionnaire. I reply with a plan and a fixed quote within one business day.

Starting at $350 Start the questionnaire