Website Malware Analysis and Cleanup Case

Published: 2026-09-09

Symptom: Direct access to the website through a browser is completely normal. In search engines, site:domain shows a large number of illegal pages involving pornography, gambling, gray-market industries, etc., which are completely unrelated to the website's original content; this is crawler hijacking and malicious code injection.

I. Case Background

Access by ordinary website users is completely normal, with no pop-ups, no redirects, and no abnormal browsing experience. When using Baidu site:domain to query indexed pages, a large number of unfamiliar URLs appear, and the titles and descriptions are all spam content such as pornography, gambling, and gray-market industries.

Key point: Opening these abnormal links directly in a browser still displays the website's normal content; only when search engine spiders crawl them is malicious content returned.

II. Symptom Reproduction

Use curl to simulate the Baidu spider UA to access the website and reproduce the attack effect:

curl -A "Baiduspider" https://your-domain
  • Access with an ordinary browser UA: returns the website's normal source code

  • Simulated spider UA access: inconsistent with the website content; it is all malicious spam information.image.png

III. Attack Principle

After intruding into the website, the hacker implants UA-recognition malicious code:

  1. Determine the visitor's User‑Agent identifier;

  2. For ordinary visitors, return the website's normal pages;

  3. When identifying search engine spiders such as Baidu and Bing, output pornographic and gambling spam content, stealing the website's weight for black-hat traffic diversion. Malicious code often uses base64 encryption, or normal code includes third-party code; it is difficult to discover by visually inspecting the source code.

IV. Troubleshooting Process — Recommended: Use the AI Assistant

Virtual Hosting AI Assistant.Log in to the Management Center, enter the Virtual Hosting Control Panel, and find the "AI Assistant" entry in the left navigation bar to use it;

Scan and remove Trojans/viruses, patch vulnerabilities, add new features, redesign the website... Open the hosting control panel and say one sentence; the AI Assistant will help you get it done online!

image.png

image.pngimage.png


  1. Website source code troubleshooting: Focus on checking global public files, template headers, and configuration files. Search keywords: Baiduspider, spider, user‑agent, base64_decode, etc.  Check file modification times, locate files changed by non-maintenance operations, and unfamiliar PHP scripts newly added in directories. Most hackers plant backdoors, and the code is generally encrypted. If suspicious encrypted files are found, you can rename them first.

  2. Log tracing: Check website access logs and FTP login logs, locate the intrusion time and attacking IP, and confirm the intrusion source (program vulnerability / weak password).

image.png    image.png

image.png

V. Cleanup and Handling Steps

  1. Delete malicious backdoors and encrypted hijacking code, and restore tampered website files;

  2. Restore the server's original configuration, and clear abnormal pseudo-static rules and content replacement;

  3. Reset all account passwords for the backend, FTP, and database; update the website program and plugins, patch website vulnerabilities, and update patches;

  4. Submit dead link removal and snapshot updates on the Baidu Webmaster Platform, resubmit the sitemap, and guide search engines to recrawl;

  5. File security protection: tighten directory read/write permissions; you can refer to:https://www.west.cn/faq/list.asp?unid=733 ;

VI. Case Summary

This type of spider-targeted malicious code injection is highly covert and cannot be perceived by ordinary users. The main harm is polluting search engine snapshots, causing website weight reduction and site penalty (K-site).

Troubleshooting cannot only check whether browser pages are normal. It is necessary to regularly perform site searches and simulate crawler UA for crawl testing to promptly discover such hijacking attacks.