WordPress or WooCommerce site hacked: what to do in the first hour
You open your own website and it sends you to a pharmacy page. Or a customer writes that the browser shows a red warning. Or you find an administrator in the user list that you never created. The first reaction is to delete something quickly. This is the wrong first move: the order of steps matters more than speed. Below is the order that the official WordPress.org guide “Help, I think I’ve been hacked” recommends, with a few notes for online shops from my own work.
1. Check the signs
The guide lists these indicators of a hack: the site is blacklisted by Google or Bing, your host has disabled the site, the site is flagged for distributing malware, visitors’ antivirus warns about it, you are told your site attacks other sites, new users appear that you did not create, or the site is visibly defaced. One sign is enough to take it seriously.
2. Stop and write things down
Before touching anything, note what you see, when you noticed it (with the time zone) and what changed recently: a new plugin, a theme edit, a widget. Also note your hosting environment. This record helps later when you look for the way in.
3. Scan the site and your own computer
The guide suggests using several scanners together, because no single one finds everything, and running a full antivirus scan on your own computer too. Passwords often leak from the computer of whoever administers the site, not from the site itself.
4. Ask your host
On shared hosting the problem may reach beyond your site. Ask the host whether it sees a hack or an outage, and what its backup policy is.
5. Change access, then clean
The guide is clear on the order: change all passwords for every access point (FTP or SFTP, wp-admin, the hosting panel, MySQL) and for all users who have access. Then regenerate the security keys in wp-config.php from the WordPress key generator, which logs out every active session. After that make a backup of the current state, even though it is infected: it is evidence and a reference.
6. Clean with fresh files, not with a button
The guide says to reinstall the core files manually, with the same WordPress version, over SFTP, and not with the reinstall option in the admin panel. It names /wp-admin and /wp-includes. Then go through /wp-content (themes and plugins), the .htaccess file, which is often used for nefarious purposes, and the files index.php, header.php, footer.php and functions.php, because a change in them affects every page request. The database is part of the cleanup too.
7. Update, then change passwords again
When the site is clean, update WordPress, because older versions are more prone to hacks. The guide also says to change the passwords again after you are sure the site is clean, and to consider a new database user and password. At the end, find out how the attackers got in; otherwise they come back.
What a shop owner should add
These points are not from the guide, they are from my own practice with online stores:
- Check the payment settings and the admin email address. A changed payout account or notification address is worth more to an attacker than a redirect.
- Check the latest orders and the list of administrators, and look at the order emails that really went out.
- Request a review in Search Console only after the site is clean, not before.
If you do not want to do this alone, see website virus and malware removal or speed, security and servers for WooCommerce and WordPress. Every job starts with a check and a written quote.
Sources: the WordPress.org documentation, Help, I think I’ve been hacked.