# What to do if a site was hacked

The malware scan found a web shell or injected code. Stop it, close the way in, and make sure the attacker cannot come back, in about 30 minutes.

A site sends visitors to strange pages, your host warned you, or the malware scan found a file that looks like a web shell. Removing the file is only the start: it came in through a hole that is still open, and the attacker may have kept a way back. This guide closes both.

## What you need

- The server on the Business plan, so you have the **Malware scan**.
- About 30 minutes, and your developer's help if the site is custom code.

## Steps

1. **Scan everything.** Open the server, then **Security** › **Malware scan** and choose **Full scan**. It reads every file of every site and checks WordPress files against the official ones.

2. **Stop code from running in upload folders.** Under **Stop code from running in upload folders**, choose **Turn on for all sites**. A web shell that is still somewhere in an upload folder can no longer run, even before you find it.

3. **Quarantine what was found.** In **To decide**, read why each file was flagged. Select the files and choose **Quarantine**. They move to a locked folder outside your sites, and each site is checked to still answer. Keep **Delete for good** for later, once the site works.

4. **Change the site's passwords and keys.** Whoever placed the file could read the site's settings file. Open the site's **Settings file** (`.env`, or `wp-config.php` for WordPress) and change the database password and the secret keys, then change the same password for the database user under **Databases**. Change your own WordPress and hosting passwords too.

5. **Update everything.** Under **Security alerts**, install the fixes the server and the site wait for. For WordPress, update WordPress, every plugin and theme, and remove the ones you do not use: an old plugin is the most common way in.

6. **Check the WordPress administrators.** Attackers often add one to come back. In **Terminal and files**, in the site's folder, run:

   ```bash
   wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
   ```

   Delete any account you do not know.

7. **Replace the code host access key.** For a site that publishes from GitHub, GitLab or Bitbucket, remove the key the server uses at your code host and connect the site again under the site's **Settings**.

8. **Scan again.** Choose **Full scan** once more. The files you cleaned show under **Solved**.

## What you should see

The malware scan page says "Nothing suspicious found." and the site works as before. If a file you moved turns out to be needed, choose **Put the file back** in **In quarantine**.

## If it goes wrong

- **The site was changed in many places.** Cleaning by hand misses things. Go back to a restore point from before the first suspicious file (the date is in **Technical details**) under the site's **Backups**, then do steps 2 and 4 to 7.
- **A file comes back after quarantine.** Something still writes it: a scheduled job, a plugin, or a hole that is still open. Look for findings about the server itself, finish step 5, and ask your developer to check the site's own code.
- **The scan reports something about the server itself** (a scheduled job, a service, a library forced into every program). The server may be compromised beyond the sites. The safest fix is a new server with your sites restored onto it.
- **A finding is your own file.** Choose **This file is mine** and say why. It is checked again if it ever changes.

## Related

- [Malware scan](https://internal.fuzops.com/docs/malware-scan)
- [Server protection](https://internal.fuzops.com/docs/protection): bans addresses that keep guessing passwords
- [Backups and restore points](https://internal.fuzops.com/docs/backups)
- [Guide: secure a new server](https://internal.fuzops.com/docs/guides/secure-a-new-server)
