Security & SSL

Hacked Website: Steps to Recover and Protect It

If your website was hacked, act fast — follow these concrete steps to regain control, clean the infection, and stop it from happening again.

Detailed view of a padlock securing a metal gate with a chain, emphasizing safety and security.

If your website was hacked, you need to act within hours — not days. Every minute the site remains compromised damages your SEO, puts your users at risk, and erodes trust in your brand. The good news: most hacks are fully recoverable if you follow the right sequence.

Signs Your Website Has Been Hacked

Sometimes a hack is obvious — a black screen with "Hacked by X" — but often it's silent. Watch for these warning signs:

  • Unknown users or administrators in your CMS.
  • New PHP files in image or upload folders.
  • Your domain appearing on Google, Spamhaus, or Norton Safe Web blacklists.
  • Your hosting provider sending an unusual-activity alert or suspending your account.
  • Visitors being redirected to gambling, pharmaceutical, or adult sites.
  • Google Search Console showing security warnings or URLs you never created.

Step 1 — Put the Site in Maintenance Mode and Secure Access

The first priority is limiting the damage. Enable maintenance mode in your CMS or serve a static page with HTTP 503 (service unavailable). This prevents more visitors from being affected while you work on the cleanup.

Immediately after, change all passwords:

  • Hosting control panel (cPanel, Plesk, or equivalent)
  • FTP and SFTP access
  • Database
  • CMS (WordPress, Joomla, etc.) — change every admin user's password
  • Email accounts associated with the domain and hosting

Revoke active sessions and, if your CMS supports it, regenerate security keys (in WordPress: wp-config.php → secret keys). This evicts the attacker even if they stole a valid session token.

Step 2 — Identify the Attack Vector

Cleaning without understanding how they got in is like patching a leak without turning off the water. Review your server access logs (in cPanel, typically under /home/user/logs/) and look for:

  • POST requests to files that shouldn't receive them (uploads, image folders).
  • Successful logins from unknown IPs to wp-login.php, xmlrpc.php, or the admin panel.
  • Files modified on recent unexpected dates, using your file manager or the command find . -newer reference.txt -type f.

The most common attack vectors for small and medium sites are: weak or reused passwords, outdated plugins or themes, and nulled (pirated) themes or plugins with deliberate backdoors built in.

Step 3 — Restore from a Clean Backup or Clean Manually

Option A: restore a clean backup

If you have a backup predating the infection, this is the fastest and most reliable option. Restore the files and database, verify the site works correctly, and proceed directly to Step 4 to close the vulnerabilities.

If you're not sure exactly when the hack occurred, check your logs to pinpoint the date and use a backup from before it.

Option B: manual cleanup

When no clean backup is available (or the backup is also compromised), you need to clean file by file:

  • For WordPress: download a fresh copy from wordpress.org and replace the wp-admin/ and wp-includes/ folders entirely. Reinstall every plugin and theme from its official source.
  • Check .htaccess — attackers frequently insert redirect rules here.
  • Search all PHP files for strings like eval(base64_decode(, gzinflate, str_rot13, or preg_replace with a /e pattern: these are classic markers of obfuscated malicious code.
  • Clean the database: export the SQL dump, open it in a text editor, and search content fields for <script, iframe, or suspicious external URLs. Fix and reimport.
Method Speed Security Requires
Restore clean backup High Very high Backup predating the infection
Manual cleanup Low–medium Medium (hidden code may remain) Technical skills or professional help
Security plugin (Wordfence, etc.) Medium High Active CMS access

Step 4 — Close the Vulnerabilities

Once the site is clean, address the root causes before bringing it back online:

  • Update your CMS, plugins, and themes to the latest stable versions. Delete anything you no longer use.
  • Remove nulled or pirated themes and plugins — they frequently contain deliberate backdoors.
  • Fix file permissions: directories at 755, files at 644. Never 777.
  • Disable XML-RPC if you don't need it (in WordPress, it's a common brute-force entry point).
  • Install a Web Application Firewall (WAF): Cloudflare's free plan or Wordfence filter malicious traffic before it ever reaches your code.
  • Enable 2FA on both your hosting panel and your CMS.

If you want an environment with these protections built in from day one, elenlace.com offers hosting with WAF, daily backups, and dedicated security support included.

Step 5 — Request a Google Review and Delist from Blacklists

If Google flagged your site as dangerous, submit a manual review request in Google Search Console (Security & Manual Actions → Security Issues → Request Review). Google typically responds within 24–72 hours.

If your domain or IP landed on email blacklists (Spamhaus, Barracuda, etc.), request removal directly from each list. MXToolbox Blacklist Check shows you which ones you're on.

For more guides on keeping your site secure, visit our security SSL & web category.

Key Takeaways

  • Act within hours, not days — every minute of compromise damages SEO, reputation, and users.
  • Change all passwords before touching any files.
  • Identify the attack vector before cleaning, so you don't leave the door open.
  • Restoring a clean backup is safer and faster than manual cleanup.
  • Close all vulnerabilities (updates, permissions, WAF, 2FA) before relaunching the site.
  • Submit a Google Search Console review and delist from blacklists once the site is clean.

Was your site already hacked, or do you want to harden it before that happens? Contact elenlace.com — our team will guide you from initial diagnosis all the way to full recovery.

FAQ

How long does it take to recover a hacked website?

With a clean backup available, recovery can be completed in 2–4 hours. Manual cleanup without a backup can take anywhere from one day to several, depending on the site's size and complexity. Google's review to remove warnings adds another 24–72 hours on top of that.

Should I notify my users that the site was hacked?

Yes, if the hack could have compromised user data (emails, passwords, payment info). Communicate clearly, explain what happened, and describe what steps you've taken. Depending on your jurisdiction and the nature of the data, you may also have a legal notification obligation.

Can hackers come back after I clean the site?

Yes, if you don't close the original vulnerability. That's why Step 4 (closing vulnerabilities) is just as important as the cleanup itself. An active WAF and strong, unique passwords dramatically reduce the probability of reinfection.

Is my hosting provider responsible for the hack?

It depends on the vector. If the attack exploited a vulnerability at the shared server level (not in your code or passwords), the hosting provider bears responsibility. If it was caused by an outdated plugin or a weak password, the responsibility is yours. Either way, a good hosting provider should help you investigate and recover.

Further reading

Other providers and guides worth comparing:

← All