What this hack is
Attackers use your site’s good name in Google to rank their own spam. A PHP script on your server creates thousands of pages on your domain (Japanese product listings, fake designer bags, online pharmacies, casino pages) and serves them only to search engines. People who click those results get sent to the attacker’s shop.
Your real pages lose rankings, Google may label your site “This site may be hacked”, and the spam keeps growing until the script is removed.
Confirm it
- Search Google for
site:yourdomain.comand go through several pages of results. Look for foreign text, product names and strange URLs, often in folders you don’t have. - Try
site:yourdomain.com viagra,site:yourdomain.com casinoorsite:yourdomain.complus a brand name like “Louis Vuitton”. - Click one of the spam results. If you see a normal page, a 404 or your home page, the spam is being hidden from you.
Check Search Console first
- Settings → Users and permissions. This hack often adds the attacker as a verified owner so they can submit their own sitemaps. Remove any owner you don’t recognise, then delete their verification method: a
google…htmlfile in your site root, a DNS record, or a rewrite rule in.htaccessthat creates the file on demand. - Indexing → Sitemaps. Delete any sitemap you didn’t submit.
- URL inspection. Paste one spam URL, click Test live URL → View tested page. You will see the spam exactly as Google does.
- Security & Manual Actions. Note any issues listed: you will request a review once the site is clean.
Find the code
The spam generator is usually a few PHP files plus a rule that sends spam URLs to them. Check these places:
.htaccessfiles in the site root and subfolders, for rewrite rules pointing to a PHP file you don’t recognise. Find them all withfind . -name ".htaccess". Moatline doesn’t check.htaccessrules, so do this by hand.- Modified core files. Attackers often add code to
index.phporwp-load.php. Runwp core verify-checksumsor reinstall WordPress core from Dashboard → Updates. - New PHP files in the site root, uploads and odd folders. Recently changed ones are the best lead:
find . -name "*.php" -mtime -30 -not -path "./wp-content/cache/*" - Fake plugins and must-use plugins, and plugin files that differ from the official copy.
The free Moatline Malware Scanner checks files, plugins, must-use plugins, the uploads folder and the database, and names known malware families. Our malware removal guide covers the full cleanup, including passwords and security keys.
When you’re done, open a few spam URLs again: they should now return 404 Not Found for everyone, including in URL inspection.
Clean up Google
- Request a review in Security issues, if Google listed any, describing what you removed and how the attacker got in.
- Submit a clean sitemap with only your real pages.
- Use the Removals tool (Indexing → Removals) for the worst spam folders, such as a whole
/xyz/folder prefix. This hides them for about six months while Google recrawls and drops them for good. - Watch the Pages report over the following weeks. The number of indexed pages should fall back to normal.
Source: Google’s guide to fixing the Japanese keyword hack.
Frequently asked questions
Why can’t I see the spam pages when I visit them?
How long until the spam disappears from Google?
Should I redirect the spam URLs to my home page?
Will my rankings recover?
Scan your site for free
Moatline checks files, the database and page-builder content. Nothing changes unless you click a button.
More guides
- “This site may be hacked” in Google: how to get the warning removed
- WordPress site redirecting to spam? How to find and fix it
- Host suspended your WordPress site for malware? What to do next
- Unknown admin user in WordPress? How to check it, remove it and lock the door
- A website asked you to press Windows + R to “verify you are human”? Here’s what to do
- WordPress fake CAPTCHA malware (ClickFix): how to find and remove it