The order of disposal after a website is injected with malicious code, whether to cut off the entry first or clean the files first.

📅 October 9, 2026 👁️ 18

Discover that the site has been hacked or **malicious scripts, the correct emergency handling sequence is to cut off the entry first, then clean the files. The judgment basis is very simple: deleting files when the entry is still effective is equivalent to dragging water while not turning off the tap. The standard sequence is four steps: cut off the access path and write path still in use, clean up malicious files, repair the exploited entry vulnerability and review in the same round, and finally rotate all possible leaked credentials. The typical consequence of executing out of order is recurrence within a few days after cleaning up.

Four steps of handling sequence

The first step is to stop the entry that is in effect. Change the suspicious write directory to read-only, disable exploited features, limit unnecessary ports from being exposed at the entry layer, and at the same time retain the scene snapshot to avoid not being able to backtrack later. The goal here is not to 'make the site look clean', but to make the attacker lose the ability to write again.

The second step is to clean up files. There are hundreds or even thousands of system or application code files, and it is unreliable to identify them manually one by one. Professional practice recommends using automated detection and processing capabilities directly, first scanning the Web directory, and then conducting a comprehensive review: scheduled tasks, temporary directories, and abnormal network connections are the most likely places to leave secondary entry points. Only handling the reported file is the most common mistake at this step.

The third step is to repair the entry and review. After cleaning, you must answer 'How did it come in?' Upload missing validation, writable template, unpatched injection defects, weak passwords, or reused credentials are common answers. After the repair, confirm the repair status item by item from a vulnerability management perspective, rather than just looking at the page recovery.

The fourth step is to rotate credentials and rebuild monitoring. Passwords, interface signature keys, database accounts, any content that may appear in configuration files or has been read, should be treated as leaked. When going online, enable monitoring for captured anomalies, file changes, and login failures, otherwise the next discovery will still rely on visitor reports.

Why clearing files alone will always recur

Three reasons overlap. First, the entry has not been repaired, and the write permission is still in place; second, Webshells are often not just one place, and after deleting the main file, the residual bypass scripts will rebuild it; third, if the credentials have been leaked, the competition between the cleaning action and the attacker's ability to re-enter is just a race against time. The professional document states this clearly: it depends on emergency response to investigate the cause of the intrusion, find vulnerabilities, and clean up the malware to ensure the system is secure and reliable before strengthening protection to avoid secondary intrusion or repeated trojan horse attacks.

By the way, here's a counterintuitive point: deleting and reinstalling the entire site also belongs to just cleaning the files. A reinstall without a traceability conclusion only brings uncertainty into the new environment.

What do the four layers of reinforcement do?

Reinforcement should be done layer by layer, and the things that each layer blocks are different.

Limit the exposed surface at the entry layer: the security group and firewall only allow necessary ports, do not put database Web management tools on the public network, and do not directly open back-end management systems to the public network. This is especially true for content sites, as many intrusion paths are not complex vulnerabilities, but accessible management pages.

Application layer attack behavior: Web application firewall handles injection, abnormal upload, and common scanning. The content management system itself also bears a part: AnQiCMS built-in JWT authentication, and in the README, the content sensitive word filtering and anti-capture interference code are included in the defense mechanism against SQL injection and XSS attacks; the form side can also connect to reCAPTCHA verification code, blocking machine submissions for registration and comments at the entrance. These mechanisms belong to the daily defense line and cannot replace the traceability in the emergency stage.

Version layer narrows the known defect window: Keep an eye on and update the latest version and security patches released by the official, avoid using versions that have stopped being maintained. Staying on the old branch is equivalent to publicly exposing your exposure in the announcement.

Data layer retains the ability to recover: AnQiCMS supports the backup and recovery of data and static files. The backup should be accepted according to 'recoverable' rather than 'done', and only exporting unverified backups does not have the value of rollback in emergencies.

The position of backup and recovery in emergencies

Backups play two roles in emergencies: rollback points and forensic materials. Rollback points allow for a known clean version to revert to when cleanup fails; forensic materials provide a basis for determining the time of intrusion, comparing the differences between backups and the working directory often allows for the direct identification of modified files.

Therefore, after the event, the backup strategy should be adjusted: increase the number of retained copies of key directories, incorporate recovery drills into routine inspections, and ensure that the backup files themselves are not on the same writable entry point as the work site. If the backup directory can be directly accessed via a Web path, the event handling is just a change of position for the risk.

Common questions

Can we restore the entire site backup first?Can it be restored, but the entry vulnerabilities and credential issues will not disappear with the backup. After recovery, you still need to go through the two steps of tracing and rotation.

How long after cleaning can you confirm safety?Take the review result as the standard: full disk scan with no residue, entry repair with conclusion, credentials have been rotated, monitoring is online, all four items are in place to achieve phased convergence.

Should we notify the search engine?If the site is used for redirection or content injection, repair it first and then submit for review to avoid applying for inclusion review with problem pages.

Related articles

Is the major PHP version website still in the security maintenance period, how to do the three-step self-check?

Confirm whether the PHP major version is still receiving security fixes, which is based on the two end dates in the official support table: the end of active support and the end of only security support. Self-check in three steps: check the actual running version, compare with the support table, and write the end dates into the maintenance record. Distribution data shows that a considerable proportion of sites are still running on the previous generation or even earlier major versions.

2026-10-09

Where does the difference lie between Baota panel deployment and Docker image deployment in website operation and maintenance?

The panel route gathers environment, certificate, database, and site management into one interface, configuration is changed through point selection, the advantages are quick to start and direct troubleshooting; the image route packages the running environment along with the application, and the machine is switched by restarting the container, the advantages are consistent environment and fast rollback. This article describes what they manage individually, three types of convenience, and selects according to three conditions, and gives four places to verify after deployment.

2026-10-09

How to export fields and links when migrating content from WordPress to an independent CMS

When migrating away from WordPress, what is most likely to be lost is not the article content, but the field relationships and old addresses. The categories, tags, and custom fields brought in by the export file should be mapped to the new content model first, then determine the address rules and redirect table for the new site, and import them in batches and check each item. This article gives the five steps of migration, what to check at each step, and the three types of verification methods after the import is completed.

2026-10-09

How to configure the 301 redirect of the old link after website revision so that the position is not lost

The key to not losing position after the revision is not how good the new page looks, but the direction of the old address: each old link points to the corresponding new address one by one, uses a permanent redirect instead of redirecting the whole site to the homepage, and re-promote the new address once the redirect takes effect. This article explains what 301 passes, the four most common types of redirect errors, the troubleshooting order on the day of the revision, and how to maintain the static rules and redirect table in the long term

2026-10-09

How to configure the in-site anchor text so that it does not look like a pile-up, and how to determine the keyword library and distribution range

The key to not stacking anchor text within the site is to first build a keyword library, then determine the scope of distribution: a keyword should point to only one target page, the number of times the same word appears on a single page is controlled, and the rules are effective according to the column rather than the entire site. The essence of automatic anchor text is to replace in bulk, and rule conflicts will overlap, so the configuration order is more important than the switch itself.

2026-10-09

Sudden increase in comment spam, which part is managed by captcha, content review, and frequency control?

When there are more spam comments, three types of protection each manage a section: captcha judgment to determine whether the submission action is initiated by a machine, sensitive word filtering and content review to determine whether the submitted text can be exposed externally, and frequency control to limit the number of submissions from the same source within a short period of time. No section can fill the gap of another, and the wrong order may result in the situation where many switches are turned on but spam still comes in. This article divides it into before submission, during submission, and after submission, and explains the easy-to-miss XSS risk where the content to be reviewed is still rendered in the background.

2026-10-09

How to avoid missing and incorrect changes when renaming columns or batch replacing links.

This is a batch rewrite of the entire site, with risks concentrated on the scope and the irreversible aspects. The safe order is to first make a recoverable backup, then narrow down the scope to a small amount of content for testing, confirm the hit results before executing officially, after execution, establish 301 redirects one by one according to the old address, and finally check that the recycle bin and drafts are not involved. Omissions are often found in navigation and single-page applications, and incorrect changes often come from too broad matching words. This article provides checkpoints for each step.

2026-10-09

What consequences will there be if the regular maintenance of navigation, single-page, and friend links is missed?

Navigation, single-page, and friend links are the three most easily overlooked maintenance items on the site. If the column adjustment does not rearrange the navigation, it will leave isolated pages; addresses and contact information written in single pages will become outdated if not changed for a year; when the detection of link expiration and lack of standards for external text is lacking, problems are usually discovered by the cooperative party. This article provides the operational actions, anchor text and interface capabilities for each of the three, as well as the method of determining the maintenance cycle according to events.

2026-10-09