Skip to content
Technology for businesses since 2008

Help center · Security

Signs your WordPress site was hacked and what to do first

The most common signs that a WordPress site has been hacked are: visitors redirected to another address (often only people who arrive from Google or on a phone), spam pages you did not create showing up in Google, an unknown administrator user, files changed even though nobody touched them, a sudden drop in visits, and warnings from Google, the browser, or your hosting provider. A single sign does not always prove a hack, but two or more together call for immediate action.

In the first few hours, the most important thing is to keep a copy of the site, change the passwords, and not delete anything blindly. Cleanup comes later, with a calm head, and it is easier when the evidence of the hack is still in place.

This article covers a table of signs, what each one may indicate and how to check it, and a checklist for the first few hours. Menu names in cPanel and WordPress may vary depending on the version and the theme of the panel.

Why the site owner often doesn’t notice

People who hack a site usually want it to keep working, just in service of someone else. That is why malicious code is written to hide from the owner: it may only appear to visitors who arrive from Google, to people using a phone, or to people who are not logged in to WordPress. If you open your site directly on your computer, it looks normal, and the problem is only discovered when a customer complains or when Google shows a warning.

So “my site looks fine to me” is not proof that it is clean.

Signs of a hack: what each one may indicate

Sign What it may indicate How to check
Redirect to another site, only for visitors coming from Google or from a phone Code injected into the .htaccess file, into PHP files, or into the database, which only acts under certain conditions Search for your site’s name on Google, in an incognito window, and on your phone using mobile data, then click the result. Compare it with a direct visit
Spam pages (medicines, gambling, fake products) in Google results Pages created on your domain without your knowledge Search for site:yourdomain.com on Google and look for titles you do not recognize
An administrator user you did not create The attacker left a way back in for later In WordPress, open Users and filter by Administrator. Check the creation dates, if your admin theme shows them
Changed or new files with strange names Malicious PHP files (sometimes called “shells”) or code inserted into existing files In the cPanel File Manager, sort by modification date. Be suspicious of .php files inside wp-content/uploads
.htaccess with rules you did not write Conditional redirects created by the attacker Open the file in the site’s root folder and look for RewriteCond lines that mention Google, HTTP_REFERER or HTTP_USER_AGENT, and external addresses
Emails about a password change, a new user, or a login you did not make Someone accessed the account, or tried to Read the date and IP address in the notice, if there is one, and check whether the action was yours
Sudden drop in visits Google may have removed pages from its index or flagged the site, or visitors are being diverted Compare the period in Google Analytics and Search Console. Check for a warning under Security & Manual Actions
“Dangerous site” or “Deceptive site” warning in the browser or on Google Google or the browser detected malware, phishing, or injected code Check the security issues report in Search Console. See the article site marked as dangerous
Site slow for no clear reason, or offline now and then Malicious code consuming server resources, for example to send spam or mine cryptocurrency Check resource usage in cPanel and compare it with your site’s normal usage. Slowness has many causes, so do not conclude from this alone
Server or hosting alerts about suspicious files The security scan found malicious code Read the email carefully: it usually names the files and what was done to them
Folder or file recreated after you deleted it A second file, or a scheduled task, recreates the first one In cPanel, check Cron Jobs and look for commands you do not recognize
Many bounced emails or spam complaints sent in your domain’s name The site or an email account is being used to send messages Check the email accounts and the sending queue, if the panel shows it. Also review your domain’s authentication settings

If several of these signs appear together, treat it as a hack until proven otherwise. If only one appears and you are not sure, check the others: a quick investigation costs less than keeping a compromised site.

What to do in the first hours

Order matters. Follow the steps in sequence.

1. Breathe and don’t delete anything

The temptation is to delete the strange file right away. Avoid it. Deleting blindly can:

  • take the site down, if the file was a legitimate part of a plugin or theme;
  • erase the trail of how the attacker got in, which makes reinfection almost certain;
  • leave a “back door” behind, because there is almost always more than one malicious file.

2. Preserve a copy

Before making any change:

  1. In cPanel, create a backup with JetBackup or the cPanel Backup tool, or download the site’s files through the File Manager (compressed) or by FTP.
  2. Export the database through phpMyAdmin or the panel’s backup tool.
  3. Store the copy outside the server, in a folder marked “infected” so it is not restored by mistake.
  4. Write down what you saw: screenshots, the addresses of the spam pages, and the date and time of the warnings.

This copy is for investigation. It is not a backup to restore, because it contains the problem. To understand the difference between an investigation copy and a real backup, see site backup.

3. Change the passwords, in the right order

If the attacker has a password, any cleanup is pointless. Change them from a trusted computer:

  1. Email password for the account that receives password resets, because whoever controls the email controls the other passwords.
  2. cPanel password (or the hosting client area).
  3. FTP and SSH passwords. Delete the FTP accounts that are no longer used.
  4. Database password, also updating the wp-config.php file.
  5. WordPress user passwords, starting with the administrators. Remove any administrators you do not recognize.

Use long, unique passwords. The full guide is in site passwords and access, and protecting the WordPress login page is covered in how to protect the WordPress login.

4. Contain the damage

If the site is redirecting visitors, stealing data, or sending spam, consider putting it in maintenance mode while you investigate. If it is a store, let your team know and pause sensitive features, such as payments, until you understand what happened. If customer data is involved, talk to whoever handles legal matters or data protection at your company: there may be notification obligations.

5. Find the cause before cleaning

Cleaning up without finding out how the attacker got in usually ends in reinfection. The most common entry points are:

  • outdated plugins and themes with a known security flaw;
  • pirated plugins and themes, which often come with malicious code (see pirated plugins and themes in WordPress);
  • weak, repeated, or leaked passwords;
  • old users and accesses that were never removed;
  • file permissions that are more open than necessary (see file permissions in cPanel).

The site’s access logs, available in cPanel under Raw Access or a similarly named tool, help you see when the first suspicious file appeared and which addresses accessed it.

6. Clean, update, and check

With the copy saved, the passwords changed, and the cause identified, the cleanup can begin:

  1. Reinstall the WordPress core, themes, and plugins at the same version, from official sources.
  2. Remove plugins and themes you do not use.
  3. Look for .php files in wp-content/uploads, changes to .htaccess, and unknown cron jobs.
  4. Look for code inserted into the database, in posts, options, and widgets.
  5. Update everything that is left and turn on two-step verification.
  6. Check the site again through Google, in an incognito window and on a phone.

If you use an AI assistant to understand code snippets, see how to use AI to remove viruses from a WordPress site and what should never be pasted into it.

7. If Google issued a warning, request a review at the end

The review request should only be sent after the site is clean and the vulnerability is closed. The step-by-step guide is in site marked as dangerous.

cPGuard and email alerts

MigraCloud provides cPGuard, a security solution for servers running cPanel. It automatically cleans and quarantines suspicious files and sends email alerts to the customer when it detects something. If you received one of these emails, read it carefully and keep it, because it helps date the hack.

cPGuard does not catch everything: a leaked password, a flawed plugin, or a user created through a legitimate access can go unnoticed. The absence of an alert is not proof that the site is clean, so the signs in the table still apply. If a file was moved to quarantine and the site stopped working, contact support before reinstalling plugins or themes.

When to call a professional

Get help when:

  • the site is a store, takes payments, or holds customer data;
  • the infection came back after a cleanup;
  • you do not have a copy from before the hack and do not know how it happened;
  • the site is offline and every day it stays down costs sales;
  • you do not feel safe working with files and the database.

MigraCloud handles cleanup and investigation: see the page Virus and malware removal from a hacked site or contact us.

Frequently asked questions

My site looks fine to me. Could it still be hacked?

Yes. Malicious code often only shows up for people who arrive from Google, use a phone, or are not logged in. Search for the site’s name on Google in an incognito window and on a phone using mobile data, and also check site:yourdomain.com.

I saw an administrator I don’t know. Can I just delete it?

Before deleting, take a screenshot and note the creation date, since it helps you find out when the hack started. Then remove the user, change the passwords of the other administrators, and find out how the account was created. Deleting without investigating removes the access, but it does not close the vulnerability.

Should I delete the suspicious files I found?

Not right away. Make a copy first. A file that looks strange may be part of a legitimate plugin, and there is almost always more than one malicious file. Deleting only what you saw leaves the others in place.

Can I just restore a backup and be done with it?

Only if the backup predates the hack and the vulnerability is closed afterward. If you restore without changing the passwords and updating what is vulnerable, the attacker gets back in the same way. See site backup.

Does a slow site mean I have been hacked?

Not necessarily. Slowness has many causes, such as heavy plugins, a lack of caching, and traffic spikes. It is only a sign of a hack when it comes with other signs, such as unknown files, unexplained increases in resource usage, or security warnings.

I got an email from cPGuard. What should I do?

Check which files were mentioned and what was done with them. Keep the email, change the passwords, and confirm that the site still works. If something stopped working after a file was quarantined, contact support before reinstalling plugins or themes. An automatic cleanup does not replace investigating how the hack happened.

Will switching hosting fix it?

No. The problem is in the files and the database, and they move along with the site. Without cleaning up and closing the vulnerability, the infection simply moves to a new address.

More on Security

See all →

Help center

Looking for something else?

See all tutorials, organized by topic.