Support on Telegram VPS login Video login

Your Website Has Been Hacked: What to Do in the First Hour and How to Prevent It from Happening Again

VPS and servers Published: · 5 min read

A redirect to a casino, emails to customers “from you,” a miner eating up the CPU, or simply “the site won’t load” — the signs are always the same. The key in the first hour: don’t erase the traces and don’t restore things “as they were.”

The first hour

  1. Take a server snapshot before doing anything else — it’s both evidence and insurance.
  2. Isolate: put up a maintenance page (nginx return 503), disable outgoing mail, change SSH/panel/database passwords.
  3. Find the entry point. Check the web server logs for the past few days: POST requests to odd files (wp-content/uploads/*.php, .well-known/*.php), requests to xmlrpc.php, admin logins from unfamiliar IPs. find . -mtime -7 -name "*.php" will show recently modified files.
  4. Don’t clean it in place. Deleted “virus files” will come back through a backdoor you didn’t find.

Recovery

  • Deploy a clean server and restore the site from a backup made before the hack. If you don’t know when it happened, use a backup older than the oldest suspicious file.
  • Check the database for injections: in WordPress, the wp_options table (siteurl, scripts), wp_users (extra administrators), posts containing <script>.
  • Change all passwords: admin panel, database, FTP, payment system API keys, SMTP.
  • If spam was sent from the server, check the IP against blacklists (mxtoolbox) and request delisting.

How sites are most often hacked

CauseShareProtection
Outdated plugin/theme/CMS~50%automatic updates, removing unused components
Weak administrator password~20%2FA, login attempt limits
Pirated themes and plugins with backdoors~10%official sources only
Open ports, old PHP~10%firewall, supported versions
Neighbors on shared hosting~10%VPS with isolation

Seven measures to prevent a repeat

  1. Automatic security updates for the OS and CMS.
  2. Two-factor authentication for the admin panel and key-based SSH.
  3. Firewall: only 80, 443 and SSH from your IPs are open.
  4. Block PHP execution in upload folders.
  5. Backups to separate storage with 30-day retention — and restore testing.
  6. Monitoring: file changes, load, external checks of page content.
  7. Minimal plugins, and not a single “nulled” one.

If you need help

As part of MyCloud server administration, we investigate the breach, restore the site on a clean server and close the entry point — usually within a few hours. Clients with backups at MyCloud can restore in one click from the panel.

Need help with the task from this article?

We’ll pick a configuration, calculate the cost and help with the move.

Not sure what to choose? We’ll help you pick a configuration

Tell us what you need — a server for 1C, cameras for a pickup point or a move from another host. We’ll find a solution, give you an exact price and help with the move: we’ll advise and walk you through the steps.