My Website Has Been Hacked: What Should I Do? A Step-by-Step Recovery Guide
Visitors to your site are being redirected to gambling or pharmacy sites, Google search results show "This site may be hacked" under your listing, or your hosting company has suspended your account. These are the most common signs that your site has been compromised.
In this guide we explain, step by step, how to recover a hacked website and what to do so it does not happen again.
How can you tell your site has been hacked?
- Visitors, especially those arriving from Google or on mobile, are redirected to other sites, while everything may look normal when you log in as an admin. Attackers often exclude administrators.
- Searching Google for
site:yourdomain.comshows hundreds of pages you did not create, often in a foreign language. - There is a warning in the "Security issues" section of Google Search Console, or browsers show a red warning screen when visiting your site.
- There are users, plugins or files in the admin panel that you do not recognise.
- Your server has started sending email and your domain has landed on spam lists.
- Your hosting company has detected malware and suspended your account.
1. Stay calm and record the current state
The first instinct is usually to delete everything and reinstall. But a site rebuilt without knowing how the attacker got in will be compromised again through the same vulnerability within days. So first take a full copy of the site as it is now (files and database) and keep it somewhere separate. This copy is the basis of the investigation.
Temporarily putting the site into maintenance mode or taking it offline stops the malicious content from reaching your visitors.
2. Change all passwords from a clean device
The attacker may have got in with a stolen password. In case there is malware on your computer, change the passwords from a different, clean device:
- Hosting control panel (cPanel or similar)
- FTP and SSH accounts
- The database user (update the site configuration file after changing it)
- All administrator accounts in the content management system
- The domain management panel and related email accounts
Turn on multi-factor authentication wherever possible.
3. Find out how the attacker got in
This is the most important step of the recovery. Places to look:
- Access logs: unusual admin panel logins, file upload requests from unknown IP addresses.
- Recently modified files: PHP files modified or added close to the date of the attack, especially scripts in image and upload folders.
- Outdated software: the versions of the content management system, theme and plugins. An old plugin with a known vulnerability is the most common way in.
- The user list: admin accounts added by the attacker.
4. Remove the backdoors
Once inside, attackers leave backdoors so they can come back even after the vulnerability is closed. These are often hidden in innocently named files, as a few lines of code inside existing files, or as content added to the database. Things to check:
- Unknown files in the root directory and upload folders
- Redirect rules in
.htaccessfiles - Scheduled tasks (cron)
- Scripts hidden in database settings and content
- Admin accounts and user permissions
The safest approach is to reinstall core files, themes and plugins cleanly from official sources, and to move back only your own content (posts, images) after careful review. If you have a backup from before the attack that you are sure is clean, use it as your restore point, but remember to close the vulnerability after restoring it.
5. Close the vulnerability and update
Upgrade everything to the latest version and completely delete themes and plugins you do not use. If the vulnerability the attacker used was in a plugin that is no longer maintained, stop using it. If your site runs on WordPress, apply the measures in our article 12 steps for WordPress security.
6. Tell Google and repair your reputation
Once the site is clean, request a review from the "Security issues" section of Google Search Console. Fake pages created by the attacker will drop out of search results over time; you can speed this up with the "Removals" tool. If your domain is on spam lists, request removal from those lists.
7. Was personal data affected?
If your site has registrations, orders or a contact form, always assess whether the attacker accessed that data. If personal data was affected, you must notify the data protection authority within 72 hours of becoming aware (under Turkey's KVKK, the EU GDPR and many similar laws). More: data breach notification and the 72-hour rule.
To avoid being hacked again
- Update software regularly; turn on automatic updates if possible.
- Keep the number of plugins to a minimum. Every plugin is new attack surface.
- Use strong passwords and multi-factor authentication on admin accounts.
- Take regular backups and keep them somewhere separate from the server.
- Have your site tested through an attacker's eyes. A web application penetration test is the most direct way to find vulnerabilities before attackers do.
If your site does not really need a dynamic content management system, moving to a static setup reduces the attack surface dramatically. On a site with no database and no plugins, most of the common attack routes simply disappear.
If your site is under attack right now, or was hacked again after you cleaned it, contact us for cyber incident response.