What the Japanese keyword hack is, and how to confirm you have it
The Japanese keyword hack is a spam attack in which someone gets into your WordPress site and creates thousands of pages full of auto-generated Japanese text, usually selling fake branded goods through affiliate links. Google indexes those pages under your domain, so Japanese titles appear when people search for your site, and some visitors arriving from Google get redirected to a spam shop. The fix is to remove the attacker's access and files, then clean up what Google has indexed.
Confirm it in three ways before you change anything:
- A site: search. Search Google for
site:example.inand page through the results. Spam pages usually sit in random-looking folders, such as/abc123/?id=48291, with Japanese titles. Trysite:example.inon Bing too. - Search Console. Open the Security issues report. If Google has detected hacked content, it is listed there with sample URLs. Also check Settings > Users and permissions for an owner you do not recognise. Attackers often verify themselves as owners so they can submit their own sitemaps.
- Cloaking. Many infections show the spam only to Googlebot, or only to visitors who arrive from a Google results page. You open the URL directly and see a normal 404 or your home page. Put one of the spam URLs into the URL Inspection tool and view the crawled page to see what Google indexed, then select Test live URL to see what your server sends Googlebot right now.
If the spam only appears when you click from Google on a phone, while typing the address works, that is cloaking too. Do not take "it looks fine in my browser" as proof the site is clean.
The first hour: preserve, lock out, change secrets
Resist the urge to start deleting files. Work in this order:
- Take a copy of the infected state. Download the files and export the database, or take a snapshot if you are on a VPS. You may need it to work out how the attacker got in, and it is your fallback if a clean-up step breaks something. Label it clearly so nobody restores it by mistake.
- Change every password that touches the site. Hosting control panel, cPanel, every WordPress administrator, FTP and SFTP accounts, the database user (then update
DB_PASSWORDinwp-config.php), and the email account that receives password resets. Do it from a computer you have scanned for malware, because a keylogger on your own laptop would hand the new passwords straight back. - Log everyone out. Replacing the secret keys and salts in
wp-config.phpinvalidates every login cookie. With WP-CLI:wp config shuffle-salts. - Remove unknown owners from Search Console, and delete their verification token. Google's own clean-up guide notes this is usually an HTML file in the site root, or a rewrite rule in
.htaccessthat fakes one for anygoogle*.htmlrequest. - Consider maintenance mode if the site is redirecting your customers to spam. A short "back soon" page is better than sending them to a scam shop.
Find the infection
The spam pages are the symptom. The real problem is the code that creates them and the back door that lets the attacker return. Check each of these places. The commands below use WP-CLI, which you can run on a VPS or on any hosting plan that gives you SSH access. Run them from the WordPress folder, and add --skip-plugins --skip-themes to each one (for example wp core verify-checksums --skip-plugins --skip-themes). WP-CLI normally loads WordPress, including the infected plugins and theme, and those flags stop that code running, hiding itself or changing the output while you inspect the site. Code injected into wp-config.php or mu-plugins still loads, so if WP-CLI crashes or behaves oddly, inspect the files directly.
Administrator accounts
wp user list --role=administrator --skip-plugins --skip-themes
Delete any administrator you did not create, after checking its registration date. Attackers often pick names that look like plugins or support staff.
Modified core files
wp core verify-checksums --skip-plugins --skip-themes
wp core verify-checksums --include-root --skip-plugins --skip-themes
This downloads the official checksums from WordPress.org for your installed version and lists every core file that does not match. The --include-root option also warns about files in the root folder that are not part of WordPress, a common place for a dropped script or verification token. (--include-root needs WP-CLI 2.8 or newer; check with wp cli version.)
Modified plugins
wp plugin verify-checksums --all --skip-plugins --skip-themes
This compares plugin files against WordPress.org's checksums. Premium plugins that are not hosted on WordPress.org cannot be checked this way, so treat them as suspect and reinstall them from the vendor's download.
PHP files where they do not belong
The uploads folder should hold images and documents, never PHP. List any PHP files there, and any PHP files changed recently:
find wp-content/uploads -type f -name "*.php"
find . -type f -name "*.php" -mtime -30
find . -type f -name "*.php" -ctime -30
Set the number of days to reach back to before the first spam URL appeared, not just the last few weeks. Attackers often use touch to make a file's modification time (-mtime) look old. The change time (-ctime) cannot be set back that way, but it also changes when you restore or copy files, so treat both as clues rather than proof.
Open anything suspicious in a text editor rather than a browser. Signs of injected code include one extremely long line, and functions such as eval, base64_decode, gzinflate, str_rot13 or strrev wrapped around unreadable strings. Common targets include index.php, wp-load.php and a theme's 404.php.
.htaccess, wp-config.php and cron
- .htaccess: look for every
.htaccessfile, including those in subfolders. Rewrite rules that send search-engine visitors or certain user agents elsewhere are how the redirects and cloaking work. Replace the root file with the standard WordPress block, unless you know you added custom rules. - wp-config.php: look for
includeorrequirelines pointing at unfamiliar files, and for code above the opening comment. - WordPress cron:
wp cron event list --skip-plugins --skip-themesshows scheduled hooks. An unfamiliar hook can recreate files after you delete them. In cPanel, also check Cron Jobs for commands you did not add.
The database
Spam can live in the database as well as in files. Check that siteurl and home are correct, and look in the options table (wp_options, or <prefix>options if $table_prefix in wp-config.php is not wp_) for options with unfamiliar names holding long encoded values. wp option list --search="*keyword*" --skip-plugins --skip-themes searches option names without opening the database. Search the posts table for injected <script> tags or hidden links. If you are not comfortable editing the database, restoring a clean backup is usually safer.
Clean or restore
You have three options. Pick based on how long the site has been infected and whether you have a backup from before that date.
| Option | When it fits | Watch out for |
|---|---|---|
| Restore a clean backup | You know roughly when the hack started and have a backup from before it | Content added since is lost. The hole is still open, so patch before going live. |
| Reinstall code, keep content | No clean backup, but the database looks intact | Every file outside core, plugins and themes must be checked by hand, especially uploads. |
| Rebuild | Infection is old, widespread, or keeps coming back | Takes longer, but you export only posts, pages and media, not code. |
To reinstall code from official sources while keeping your content:
wp core download --skip-content --force --version=$(wp core version --skip-plugins --skip-themes) --skip-plugins --skip-themes
for p in $(wp plugin list --status=active --field=name --skip-plugins --skip-themes); do
v=$(wp plugin get "$p" --field=version --skip-plugins --skip-themes)
wp plugin install "$p" --version="$v" --force --skip-plugins --skip-themes
done
The first command replaces WordPress core files without touching your themes and plugins. The --version part keeps the version you already run; leave it out to upgrade at the same time. It overwrites core files but does not delete extra files an attacker dropped into wp-admin or wp-includes. Delete those two folders first, or delete every file that verify-checksums reports as "File should not exist".
The loop reinstalls each active plugin from WordPress.org at the version you already have, so nothing is upgraded by surprise. Run it again with --status=inactive. Without --version, wp plugin install --force fetches the latest release and updates every plugin at once. Premium plugins fail here, so reinstall them from the vendor. Must-use plugins and drop-ins cannot be reinstalled this way either: check wp-content/mu-plugins and the drop-in files (advanced-cache.php, object-cache.php, db.php in wp-content) by hand, because they are common places for malware to hide. Do the same for your theme, and delete themes and plugins you no longer use rather than leaving them deactivated. Remove PHP files from uploads and any unknown files found earlier. Then run the checksum commands again until they come back clean.
If a reinstall leaves you with a blank page or a version clash, see the WordPress white screen of death fix.
Close the hole so it does not come back
Google's guide warns that a site cleaned without fixing the cause is often hacked again quickly. The usual ways in:
- Outdated plugins and themes with known vulnerabilities. Update everything, and remove what is abandoned by its developer.
- Nulled themes and plugins. Pirated copies of paid products are a common source of infection, because the "free" download often contains a back door. Replace them with genuine copies or free alternatives.
- Old PHP. PHP 8.1 and older no longer receive security fixes from the PHP project, and PHP 8.2 gets them only until 31 December 2026. WordPress.org recommends PHP 8.3 or newer. See what is PHP for how to check and change the version in cPanel.
- Weak or reused passwords on admin accounts. Add two-factor authentication for every administrator, which the WordPress hardening guide recommends.
- Plain FTP. FTP sends your password unencrypted. Use SFTP, as explained in FTP vs SFTP vs FTPS.
- Loose file permissions. WordPress's hardening guide uses 755 for folders and 644 for files, with
wp-config.phpreadable only by you and the web server.
Also add define( 'DISALLOW_FILE_EDIT', true ); to wp-config.php. It switches off the theme and plugin editor in the dashboard, so a stolen admin login cannot be used to paste code straight into PHP files. It does not stop an admin uploading a malicious plugin or theme ZIP. To block that as well, use define( 'DISALLOW_FILE_MODS', true ); and update plugins through WP-CLI or the host instead.
Clean up Google after the site is clean
Only start this once the checksums pass and the spam URLs no longer load. Otherwise Google will find the pages again.
- Make spam URLs return 404 or 410. Google's documentation says it treats all 4xx codes except 429 the same way: the URL is removed from the index. So 404 and 410 both work, and you do not need to pick one for speed. Check that the URLs do not show a "not found" message with a 200 status, which Search Console reports as a soft 404. Test as a normal visitor, as Googlebot and as a visitor from Google, because cloaked spam may only show to the last two:
Then confirm with Test live URL in the URL Inspection tool, since some infections check Google's real IP addresses.curl -I https://example.in/spam-path/ curl -I -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" https://example.in/spam-path/ curl -I -e https://www.google.com/ https://example.in/spam-path/ - Delete spam sitemaps. In Search Console, open Sitemaps and remove any sitemap you did not submit. Resubmit your real sitemap.
- Hide the worst URLs temporarily. The Removals tool hides URLs or a URL prefix from Google results for about six months. It does not remove them from the index for good, so the 404s still have to be in place.
- Request a review. If the Security issues report lists a problem, select Request Review and describe what you found and what you fixed. Google says reviews can take from several days to a few weeks. Do not resubmit while one is pending.
Expect spam URLs to linger in search results for some weeks while Google recrawls them. Watch the site: results and the Pages report in Search Console. If new spam URLs keep appearing after the clean-up, something is still recreating them.
If you are on Bigdomainhost
WordPress hosting and Web & cPanel hosting include Imunify360 malware scanning and a web application firewall, and the WordPress plans add a WordPress-aware firewall that blocks the usual wp-login and XML-RPC attacks. Both include daily backups kept for 30 days that you restore yourself from cPanel (JetBackup on Web & cPanel hosting, file by file or all at once), which is the quickest route back if you know when the hack started. PHP versions are selectable per domain in cPanel.
What you do yourself: the clean-up, changing your passwords, and the Search Console steps, because only the site owner controls those. Scanning and the firewall reduce the risk, but they do not replace updating plugins and removing nulled code. If you cannot find your restore points or the scan results in cPanel, ask support. On a KVM VPS, take a snapshot of the infected server before cleaning so you can always go back.
This guide was written with AI assistance and checked against the official documentation listed in its sources on 23 November 2026.
Sources (checked )
- web.dev (Google): Fix the Japanese keyword hack
- Google Search Console Help: Security issues report
- Google Search Console Help: Removals and SafeSearch reports tool
- Google Search Central: How HTTP status codes and network errors affect Google Search
- WordPress Developer Resources: wp core verify-checksums (WP-CLI)
- WordPress Developer Resources: Hardening WordPress