When your website is hacked, the first thing you need to do is limit the damage without panicking, isolate the site, renew all access, restore from a clean backup, remove harmful code, and implement permanent security measures. The goal in the critical first 24 hours is to cut off the attacker’s access, prevent further harm to your visitors and data, avoid sending false signals to search engines, and bring your site back online in a verified manner.
A website hack doesn’t just mean a different image is placed on the homepage. Attackers often prefer to remain unnoticed; they create spam pages, alter payment forms, add admin accounts, leave hidden redirect codes in the database, or use your server for sending emails. Therefore, the recovery process is not just about deleting files. A systematic intervention is required to preserve evidence, verify the cleanup, and prevent recurrence.
In this guide, we will explain the first 5 emergency recovery steps to take when your site is hacked, simplifying technical details while keeping them practical. The same main principles apply regardless of whether you're using WordPress, custom software, an e-commerce platform, or a corporate website: isolate, cut access, revert to a clean source, verify, and reinforce.
Signs That Your Website Has Been Hacked
Hacking doesn’t always start with a visible crash. Some attacks can go unnoticed for weeks. If any of the following signs are present, the site should be treated as a security incident rather than a normal error.
- Seeing gambling, pharmaceutical, cryptocurrency, or adult content titles appearing under your site in Google search results.
- Receiving warnings in the browser about malicious sites, phishing, or insecure connections.
- Being unable to log into the admin panel or seeing unfamiliar admin users.
- A sudden increase in CPU, RAM, disk, or email sending traffic on the server.
- Unexpected changes in .htaccess, index.php, wp-config.php, or theme files.
- Visitors being redirected to different domain names.
- Bulk emails being sent from your hosting account without your knowledge.
- Security plugins being disabled or log records being deleted.
For instance, if a blog that usually receives 2,000 visitors a day suddenly generates 30,000 requests, it is often not due to a real increase in users but bot activity, brute force attempts, or malicious scripts running. Similarly, if a 10 MB theme grows to 80 MB within a few days, it may indicate the presence of uploaded backdoor files.
The First 30 Minutes After a Hack: Focus on Evidence and Control
Your first reflex should not be to delete everything. Randomly deleting files can erase traces of the attack, complicate cleanup, and lead to restoring from the wrong backup. First, take a snapshot of the current situation: date, time, alerts seen, affected URLs, suspicious users, recent updates, and hosting logs. This information allows both the technical support team and security experts to diagnose quickly.
It is especially important to maintain an incident log for sites that handle e-commerce, memberships, or personal data. It should be noted which data may have been affected, when the attack started, and which IP addresses attempted access. When seeking support for sites hosted on Hostragons, sharing the domain name, affected folder, time frame, and error messages you received will shorten the response time. For more information on hosting infrastructure selection, you can check Secure Web Hosting Packages.
| Time Frame | Priority Goal | Action to Take | Mistake to Avoid |
|---|---|---|---|
| First 0-30 minutes | Limit damage | Isolate the site, document evidence, preserve logs | Randomly deleting all files |
| 30-90 minutes | Cut access | Renew passwords, API keys, and admin sessions | Changing only the WordPress password |
| 1-4 hours | Revert to a clean source | Restore from a verified backup or quarantine infected files | Assuming a backup taken after the hack is clean |
| 4-24 hours | Verification and reinforcement | Scanning, updating, WAF, permissions, monitoring, and search engine checks | Thinking the job is done as soon as the site is back online |
Step 1: Isolate Your Site and Limit Damage
The first emergency recovery step when your site is hacked is to prevent the attacker and harmful code from causing further damage. This stage is akin to turning off the gas valve before extinguishing a fire. The site does not have to be completely shut down; however, visitors must be prevented from being exposed to harmful redirects, fake payment forms, or infected files.
Switch to Maintenance Mode or Temporarily Restrict Access
If you are using WordPress, you can display a maintenance mode page, send a temporary 503 response in custom software, or allow access only from specific IP addresses. The 503 code informs search engines that the site is temporarily unavailable; this is a more accurate signal than showing a 404 or blank page. If the site is distributing phishing or malware, it is safer to completely restrict access.
- Do not leave the admin panel open to the public; use IP restrictions.
- Temporarily disable PHP execution in file upload folders.
- If email sending is being abused, stop SMTP access.
- If the payment page is affected, temporarily disable virtual POS and payment integration.
Preserve Logs and Current File Status
During isolation, access logs, error logs, FTP logs, and control panel transaction history must be preserved. In many attacks, the initial entry point is an outdated plugin, weak FTP password, compromised admin account, or write permission error. Without logs, it becomes difficult to find the root cause. This can result in your cleaned site being hacked again a few days later.
At this stage, it is also beneficial to download the files from the server to your local computer and examine them in a secure environment. However, since the downloaded files may contain harmful code, work should be done on a machine with antivirus protection. If there are backup options in the hosting control panel, the backup taken at the time of the incident should be stored only for analysis purposes; it should not be used directly as a clean backup. For regular backup strategies, you can check Hosting Solutions with Automatic Backup.
Step 2: Renew All Access, Passwords, and Keys
Many site owners only change the admin panel password after a hack. However, the attacker’s entry point may be FTP, database user, hosting panel, SSH key, email account, API token, or third-party integration. Therefore, the second emergency step is to comprehensively reset all credentials.
Which Passwords Should Be Changed?
- Hosting control panel password.
- FTP, SFTP, and SSH user passwords.
- Database user password and connection configuration.
- CMS admin accounts and all editor accounts.
- Email accounts, especially those sending from the domain.
- API keys, payment system tokens, CDN, and DNS panel access.
- Keys for Git, deployment, automation, and backup services.
A strong password should be at least 16 characters long, unique, and unpredictable. Using the same password on another platform directly puts your site at risk in data leaks. Two-factor authentication should be activated on every panel where possible. Especially for the admin account, 2FA significantly reduces the impact of brute-force attacks.
Close Suspicious Users and Active Sessions
If there are unfamiliar users in the CMS, simply deactivating them is not enough; their role, creation date, and actions taken should be noted before deletion. In WordPress, security keys can be renewed to terminate all user sessions. In custom software, the session table can be cleaned. In e-commerce sites, it is primarily the staff accounts with administrative privileges that should be checked, not customer accounts.
Consider this example: The attacker may have accessed an old editor account and uploaded a web shell through a plugin that allows file uploads. If you only change the main admin password, the attacker’s editor account remains active. Therefore, the authority matrix should be examined, and unnecessary admin and editor roles should be reduced. Domain, DNS, and SSL management must also be secure; for this, Domain Management and DNS Security and SSL Certificate Solutions links may be helpful.
Step 3: Restore from a Clean Backup or Quarantine Infected Areas
The fastest and safest recovery method is to revert to a verified clean backup taken before the attack. However, the critical point here is the word clean. A backup taken yesterday may be infected if the attack started a week ago. Therefore, backup dates, log records, and file modification times should be evaluated together.
How to Select a Clean Backup?
First, determine when the signs of hacking were first observed. For instance, if a security warning from Google Search Console came on March 12, but suspicious POST requests appear in server logs from March 5, the March 12 backup is not reliable. Backups from March 4 or earlier should be analyzed. Before restoring from backup, backup files should be scanned for security.
- The backup date should be before the estimated start of the attack.
- The backup should not contain unfamiliar admin users.
- File integrity should be checked; core CMS files should be compared with the original package.
- Look for hidden iframes, base64 code, suspicious scripts, and spam content in the database.
- After restoration, all software updates should be carried out.
What If There Is No Backup?
If there is no clean backup, recovery must be done more cautiously. First, the site copy should be moved to a staging or temporary area. Suspicious files should be quarantined, core CMS files should be re-uploaded from official sources, and themes and plugins should be replaced with clean packages. The user uploads folder is one of the areas where attackers often hide; executable files like .php, .phtml, and .phar should be especially checked here.
Cleaning the database is as important as cleaning files. Malicious redirects can sometimes be hidden not in files but in site settings, widget areas, theme options, or post contents. When searching in large databases, expressions like script, iframe, eval, atob, base64_decode, gzinflate, shell_exec, and document.location can be checked. However, not every base64 expression is malicious; incorrect deletions may disrupt the functioning system. Therefore, a copy of the database must be taken before proceeding with any operations.
Step 4: Clean Malicious Code, Update, and Close Vulnerabilities

Simply restoring your site is not enough. If you do not find out how the attacker gained access, they can re-access through the same vulnerability. The fourth step aims to complete the cleaning of files and the database, close software vulnerabilities, and correct configuration errors.
File System Checklist
- List the most recently modified files by date and examine unexpected changes.
- Compare core CMS files with the official version.
- Check for executable files in upload folders.
- Inspect hidden files; files like .user.ini, .htaccess, and similar files can be used for redirection.
- Narrow down file permissions; the general rule is 644 for files and 755 for folders.
- Remove unnecessary themes, plugins, old backup zips, and test folders.
Unused plugins in WordPress should be deleted, not just deactivated. An old slider, form, or file manager plugin can pose a risk even if it appears deactivated because the files still reside on the server. Additionally, nulled themes and unlicensed plugins often come with backdoor codes embedded in them. This choice, which may seem financially advantageous in the short term, can jeopardize brand reputation and customer data.
What Should Be the Order of Updates?
During the cleanup, the core system should be updated first, followed by the theme, and then the plugins. If the PHP version is outdated, it should be upgraded to a current and supported version after compatibility testing. Sites still running on old PHP versions by 2026 are at serious risk because they do not receive security patches. It is essential to have up-to-date PHP, isolated account architecture, regular backups, and firewall support on the hosting side. For options on this topic, you can check Hostragons Web Hosting.
Also, ensure that the SSL certificate is valid. SSL alone does not protect your site from being hacked; however, it encrypts the data transmitted between the user and the server and helps reduce the impact of fake forms. SSL is mandatory, especially on login, payment, and membership pages. You can evaluate Buy SSL Certificate for certificate options.
Step 5: Verify, Monitor, and Establish Permanent Protection Before Going Live
The fifth step is to verify that the site has indeed been cleaned and to prevent the same incident from happening again. If this stage is skipped, the same alerts may return a few days after the site is launched. Verification should encompass both technical scanning and business processes.
Pre-Launch Checks
- The homepage, login page, payment page, and popular URLs should be tested from different devices.
- Google Search Console security issues and manual action reports should be checked.
- The sitemap and robots.txt file should be reviewed.
- Recurring 404, 500, POST, and login attempts in server logs should be analyzed.
- Email sending reputation should be checked; if blacklisted, the removal process should be initiated.
- Payment forms, contact forms, and file upload areas should be tested.
If Google or browsers have flagged your site as harmful, you will need to submit a reconsideration request after cleaning. In this request, it should be clearly stated what has been cleaned, which vulnerabilities have been closed, and what measures have been taken. Instead of vague and short explanations, concrete information should be provided, such as “the old file manager plugin was removed, all admin passwords were renewed, PHP execution was disabled in the upload folder.”
Applicable Measures for Permanent Protection
Security is not a one-time task; it is an ongoing process. Even for a small corporate site, creating a monthly maintenance plan can significantly reduce the risk of hacking. At a minimum, weekly update checks, daily backups, strong password policies, and log monitoring should be implemented. For high-traffic sites, WAF, CDN, advanced bot protection, and external security scanning are recommended.
| Measure | What Does It Do? | Recommended Frequency | Priority |
|---|---|---|---|
| Automatic backup | Provides a clean restore point | Daily or weekly | Very High |
| 2FA | Prevents stolen passwords from being used alone | Continuous | Very High |
| CMS and plugin updates | Closes known vulnerabilities | Weekly check | High |
| WAF and bot protection | Filters harmful requests before reaching the application | Continuous | High |
| File integrity monitoring | Alerts on unexpected file changes | Daily | Medium-High |
| SSL and secure DNS | Supports data transmission and domain security | Continuous | High |
In corporate sites, the sharing of responsibilities should also be documented. Who will perform updates, who will check backups, who will be notified when a security alert is received, and under what circumstances the site will be put into maintenance mode? These questions should be answered in advance, not during a crisis. This way, when your site is hacked, the team implements the pre-determined plan without panic.
Additional Recovery Steps for SEO, Reputation, and User Trust
Even if a hacked site is technically cleaned, additional checks are required on the SEO side. Attackers often generate thousands of spam URLs. If these pages have entered the search engine index, after cleaning, strategies for 404, 410, or appropriate redirects should be determined. Redirecting all spam URLs to the homepage is not always correct; Google may view this negatively as a quality signal.
Pages indexed in Search Console, security issues, manual actions, and sitemaps should be checked. After cleaning harmful content, the sitemap can be resubmitted. However, it is essential to ensure that spam pages have truly been removed first. If harmful titles appear in brand searches, a request for a re-scan of clean pages may be necessary.
For user trust, transparent but non-panic-inducing communication is essential. If user data, payment information, or membership accounts may have been affected, legal obligations and data protection processes should be considered. The situation may differ for a simple promotional site; however, in e-commerce and membership systems, the scope of the incident should be assessed professionally.
Common Mistakes to Avoid
Some mistakes made during the recovery process can cause more damage than the attack itself. The most common mistake is thinking the problem is over once the site is back online. If a backdoor file remains, the attacker can log in again later. The second mistake is restoring backups without validation. An infected backup can redeploy harmful code.
- Not taking a backup before cleaning.
- Only deleting the visible harmful file and not investigating the root cause.
- Continuing to use outdated plugin or theme versions.
- Granting unnecessary full access to all admin users.
- Deleting log records or overwriting them without examination.
- Assuming the site is entirely secure because there is SSL.
- Downloading themes and plugins from cheap or uncontrolled sources.
In particular, granting overly broad permissions regarding file permissions makes the attacker’s job easier. While 777 permissions may seem like an emergency solution, they pose serious risks in a production environment. The principle of least privilege should be applied; write permissions should be limited to only those folders that genuinely need them.
Brief Emergency Response Summary
When your site is hacked, it is crucial to maintain the order of operations for a successful recovery: first, isolate the site, then renew all access, restore from a clean backup or conduct a controlled cleanup, close vulnerabilities, and perform verification before going live. This approach reduces both technical risk and potential SEO and reputation loss.
With Hostragons, you can enhance your website's resilience through secure hosting infrastructure, SSL certificates, domain management, and backup solutions. If you need to review your existing hosting structure, you can start with Hostragons Hosting Packages and Domain Lookup and Domain Management. Remember that your primary goal before making a purchase decision is to establish a proper balance of speed, security, backup, and support.
Frequently Asked Questions
Should I take my site offline immediately when it is hacked?
If your site is distributing malware, redirecting users to other sites, or affecting payment forms, you should restrict access immediately. In lighter cases, maintenance mode 503 or IP restrictions can be used. The goal is to protect visitors while informing search engines that this is a temporary situation.
Is reverting to a clean backup always sufficient?
No. A clean backup provides quick recovery; however, if the method of access for the attacker is not determined, the site can be hacked again. Passwords should be changed, updates should be made, file permissions should be checked, and any vulnerabilities caused by plugins, themes, or configuration errors should be addressed after restoring from backup.
Does a hacked site lose its SEO ranking?
In short-term and properly managed incidents, permanent SEO loss may not occur. However, if spam pages enter the index, Google shows a security warning, or the site remains offline for a long time, rankings may be affected. After cleaning, Search Console checks, requests for reconsideration, and spam URL cleaning should be conducted.
Why does my WordPress site keep getting hacked repeatedly?
Common reasons for repeated hacks include remaining backdoor files, outdated plugins, weak passwords, unnecessary admin accounts, faulty file permissions, and infected backups. Instead of only deleting visible harmful code, root cause analysis should be conducted, and all access credentials should be renewed.
Does hosting choice affect site security?
Yes. Isolated account structure, current PHP support, routine backups, firewalls, malware scanning, quick technical support, and SSL compatibility directly impact security. Secure hosting does not eliminate all risks; however, it reduces the attack surface and speeds up the recovery process.