Check 09.10 · Security and infrastructure

Monitor for hacking and content or link injection

Catch injected spam pages, hidden links, cloaking and malicious redirects early with Search Console, site: searches, curl and file checks.

Priority
Critical
Difficulty
Intermediate
Estimated time
2 h to set up, then 15 min a week
Free, no account: your progress is saved in this browser.

Ask an AI to check this point on your site

Opens the assistant with a ready-made question: this check, its goal and your site URL.

For Gemini, Copilot or another assistant, copy the question. The link opens the chosen service directly: nothing goes through this site.

In short

Hacks aimed at SEO do not break the site: they quietly add spam pages, hidden links to third-party sites or redirects reserved for visitors coming from a search engine. The owner sees nothing; Google does. This check is about setting up a routine of checks (Search Console, site: searches, comparing what a bot and a visitor see, file integrity, outbound links) so that you spot an injection within days rather than months.

Why it matters

Injected spam pays off for the attacker because it exploits the trust placed in your domain. Google describes several recurring patterns:

  • Japanese keyword pages: thousands of generated pages in Japanese, with affiliate links to stores selling counterfeit goods. The attacker often adds themselves as an owner in Search Console to submit their own sitemaps.
  • “Gibberish” pages: pages stuffed with meaningless keywords, which redirect visitors to dubious sites.
  • Cloaked keywords and links: pages or blocks of links served only to bots (cloaking), often through a rule added to the .htaccess file.
  • Conditional redirects: a visitor arriving from Google, or on a mobile device, is sent to a gambling or pharmacy site; someone typing the address sees the normal site.

Since the content is often hidden from the logged-in owner or from direct visitors, the injection can last for months. Meanwhile, Google may display the “This site may be hacked” notice in its results, flag the problem in the security issues report (opens in a new tab), or even apply a manual action for third-party spam. Injected pages also consume crawling and can surface in AI-generated answers associated with your brand.

What it improves

  • Detection time A few days instead of several months, so fewer indexed spam pages to clean up.
  • Trust No “hacked site” warning in results and no redirection of your visitors to malicious sites.
  • Indexing Crawling stays focused on your real pages.
  • Brand reputation No association between your domain and spam queries, including in generative engines.
  • Rankings An indirect but real effect, by avoiding the penalties and dilution caused by spam.

How to check

Express check in ten minutes:

  1. In Search Console, open the Security issues report: it should show “No issues detected”.
  2. In Settings > Users and permissions (direct link): no unknown owner.
  3. Search Google for:
site:example.com
site:example.com (casino OR viagra OR cialis OR replica OR loan OR crypto)
site:example.com inurl:.php?

Titles in a foreign language, topics unrelated to your business or URLs you do not recognize signal an injection.

  1. Compare the response seen by a visitor coming from Google with a direct visit:
curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" https://example.com/
curl -s -o /dev/null -w "%{http_code} %{redirect_url}\n" -e "https://www.google.com/" -A "Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" https://example.com/

Both lines should be identical. A redirect that only appears on the second one is a malicious redirect.

  1. Run the home page through Sucuri's free SiteCheck scanner, which flags known malicious scripts and presence on blocklists.

How to implement

Before you start

Set up a routine, with a named owner:

Frequency Check Tool Warning sign
Continuous Security issues, manual actions, new owners Emails from Search Console and Bing Webmaster Tools Any security message
Continuous Files modified outside deployments File scanner or check script New or modified PHP file
Weekly Queries and pages in the performance report Search Console Queries unrelated to the business, unknown pages
Weekly Indexed pages and sitemaps Search Console Sudden rise in the number of pages, unknown sitemap
Monthly Outbound links and public pages Crawler New external domains, invisible links
Monthly Administrator accounts CMS, host, Search Console Unknown account

Make sure Search Console notifications go to an address someone reads, and not only to a former contractor.

With Google Search Console

  • Performance report (direct link): in the Queries tab, sort by impressions over the last 28 days and go through the list. Filter with a regular expression to bring out typical spam, for example casino|viagra|cialis|replica|porn|loan|betting, or Japanese and Chinese characters with [\p{Han}\p{Hiragana}\p{Katakana}]. In the Pages tab, look for URLs you did not create.
  • Pages report (page indexing): a sudden rise in indexed pages with no matching publication is the classic sign of mass page generation.
  • Sitemaps (Sitemaps report): remove any sitemap you did not submit.
  • URL Inspection: on a suspicious page, run a live test and view the crawled HTML. If links or keywords appear in the version seen by Googlebot but not in your browser, the page is cloaking.
  • Users and permissions: remove any unknown owner, then check the ownership verification tokens (HTML file or DNS record) they may have left, otherwise they will be able to add themselves back.

With Bing Webmaster Tools

Bing Webmaster Tools also reports malware detected on a site, in the account notifications. The Search Performance report reads like Google's: unexpected queries and pages. Site Explorer shows the indexed folders; an unknown directory full of URLs is suspicious.

Without paid tools

  • Alerts: a Google Alerts alert on your domain combined with a few spam terms can warn you of newly indexed pages. It complements Search Console without replacing it.
  • Outbound links: crawl the site every month with Screaming Frog (free up to 500 URLs), export the external links and compare with the previous export. A new external domain present on dozens of pages, or a link inside a hidden block, is suspicious.
  • Source code check: search the HTML of your templates for hidden blocks containing links:
curl -s -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" https://example.com/ \
  | grep -i -E -o '(display:\s*none|visibility:\s*hidden|font-size:\s*0|left:\s*-[0-9]{3,}px)[^>]{0,200}' | head

This test with Googlebot's user agent shows what a cloaking script serves to bots that do not check their IP address. It does not reproduce the real Googlebot: for that, use URL Inspection.

Apache

Versions Apache 2.4.

The .htaccess file is the favorite target for conditional redirects. Look for rules that test the referrer or the user agent:

find /var/www/example -name ".htaccess" -newer /var/www/example/index.php -print
grep -R -n -i -E "HTTP_REFERER|HTTP_USER_AGENT|google|bing|yahoo" --include=".htaccess" /var/www/example

A RewriteCond %{HTTP_REFERER} google rule followed by a redirect to an external domain is malicious. If you do not use .htaccess files in subfolders, disable them in the virtual host with AllowOverride None on those folders.

Nginx

Versions Nginx 1.18 and later.

Nginx does not read .htaccess files, which closes a classic door. Still check that the configuration has not changed: keep /etc/nginx under Git or compare its fingerprint at each check.

sudo find /etc/nginx -type f -mtime -7 -print

On the site's files, look for recently modified PHP code and for the functions often used to obfuscate injected code:

find /var/www/example -name "*.php" -mtime -7 -not -path "*/cache/*" -print
grep -R -n -E "eval\(base64_decode|gzinflate\(base64_decode|str_rot13\(|assert\(\$_(POST|GET|REQUEST)" /var/www/example --include="*.php" | head

These commands also work under Apache. Legitimate matches exist (libraries that use base64_decode): examine each file rather than deleting in bulk.

Plesk

Versions Plesk Obsidian 18.0, with Imunify360 or ImunifyAV if the host has installed them.

If the host has installed Imunify360 or ImunifyAV, its dashboard lists the malicious files detected and often allows a cleanup. In Websites & Domains > Logs, filter POST requests to unusual PHP files (/wp-content/uploads/*.php, files with random names): these are often backdoors in action.

cPanel

Versions cPanel & WHM 110 and later (Jupiter theme).

Depending on the host, cPanel gives access to Imunify360, ImunifyAV or a virus scanner in the Security section: run a scan of the home directory. Metrics > Raw Access provides the logs for spotting suspicious POST requests, and Files > File Manager, sorted by modification date, shows recently changed files.

Shared hosting

Without server access, rely on Search Console, site: searches, the curl test for conditional redirects and an external scanner. Ask the host whether it scans accounts (many do) and turn on notifications. Change the FTP and database passwords after any alert.

WordPress

Versions WordPress 6.4 and later, WP-CLI 2.x.

  • File integrity: wp core verify-checksums compares WordPress core against the official files; wp plugin verify-checksums --all does the same for plugins from the official directory.
  • Scanner: Wordfence (free version) scans files, flags changes compared with the official versions and links to domains known for spam or malware.
  • Accounts: check administrators regularly.
wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
wp option get siteurl && wp option get home
wp cron event list --fields=hook,next_run_relative | head -30

An unknown administrator, a modified site URL or a scheduled task with a strange name are signs of compromise. Also check wp-content/mu-plugins/ and look for PHP files in wp-content/uploads/, which should contain only media.

  • Content injected into the database: look for scripts or links added to posts.
wp db query "SELECT ID, post_title FROM wp_posts WHERE post_content REGEXP '<script|display: ?none' AND post_status='publish' LIMIT 20;"

Adapt the wp_ prefix to the one used by your installation.

Shopify

Versions Shopify admin, all plans, November 2026.

The platform manages the server, which rules out file injections. The risks lie elsewhere: compromised staff accounts, malicious apps, code added to the theme. Regularly check Settings > Users and turn on two-step authentication for everyone, review the list of apps and search the theme code for unknown scripts and domains.

Laravel

Versions Laravel 10 to 13.

Deploy from Git and never edit files directly on the server: a simple git status on the server then reveals any added or modified file.

cd /var/www/example && git status --porcelain && git diff --stat

An empty result is compliant. Only storage/ and bootstrap/cache/ should be writable by the PHP process; the rest of the code can belong to another user, read-only for the web server. Finally, check that storage/app/public cannot execute PHP (see the Nginx section of protect private information with access control (opens in a new tab)).

If you detect a hack

  1. Back up the current state for analysis, then isolate the site if visitors are being redirected (maintenance page with a 503).
  2. Change every password: admin, FTP, SSH, database, host, Search Console, and the CMS secret keys.
  3. Find the vulnerability (vulnerable plugin, weak password, compromised account) and fix it, otherwise the site will be reinfected.
  4. Clean up, or restore a clean backup from before the infection, then apply all updates.
  5. Deleted spam pages must return 404 or 410. For a large number of URLs, Search Console's Removals tool temporarily hides the results while they are recrawled.
  6. Request a review (opens in a new tab) if Google flagged the problem.

Good to know: do not block spam pages in robots.txt. Google would no longer be able to see that they return 404, and they would stay in the index longer.

Common mistakes

  • Checking only while logged in as an administrator: many injections hide from logged-in users and direct visitors.
  • Testing without a referrer or a mobile user agent: conditional redirects do not fire and you wrongly conclude that everything is fine.
  • Deleting spam pages without fixing the vulnerability: reinfection within days.
  • Forgetting the owners added in Search Console and their verification tokens.
  • Redirecting spam URLs to the home page: they must return 404 or 410 to drop out of the index.
  • Not reading Search Console emails: the alert often goes to an address nobody checks anymore.

Frequently asked questions

How can I tell whether my site has been hacked for SEO spam?

Type site: followed by your domain into Google and look for titles in a foreign language, topics unrelated to your business or unknown URLs. Check the Security issues report and the list of owners in Search Console. Finally, compare the page seen on a direct visit with the one seen when arriving from Google on mobile: a redirect that only appears in the second case gives a hack away.

Why can't I see the hacked pages when Google indexes them?

Spam injections often use cloaking: the script serves the spam content to search engine bots and the normal page to visitors, or hides from logged-in administrators. Others only redirect visitors arriving from a search engine. Use Search Console's URL Inspection, which shows the HTML actually crawled by Googlebot, and test with curl while simulating a Google referrer.

Should spam pages be blocked in robots.txt?

No. Blocking them in robots.txt prevents Google from recrawling these URLs and seeing that they are gone: they then stay in the index longer. Delete the spam pages so that they return 404 or 410, leave them crawlable, and use Search Console's Removals tool to temporarily hide the most visible ones while they are recrawled.

Can an SEO hack affect what AI says about my brand?

It can. Generative engines that rely on web search use the pages they find indexed on your domain. Injected spam pages can therefore be associated with your brand or cited in answers. No official source details this mechanism for each engine, but detecting and removing injections quickly limits the risk, just as it does for traditional search.

Updated on

Topic checklist (PDF)

And now?

In the “Security and infrastructure” topic

  1. Use HTTPS everywhere
  2. Check SSL/TLS and automatic renewal
  3. Redirect HTTP to HTTPS
  4. Fix mixed content
  5. Configure security headers
  6. Configure HSTS if appropriate
  7. Update the CMS, plugins and dependencies
  8. Remove unnecessary plugins
  9. Automate backups and test restores
  10. Monitor for hacking and content or link injection
  11. Check Search Console security issues
  12. Check manual actions
  13. Monitor uptime and alerts
  14. Protect private information with access control