Website security and administration

WordPress hacked – what now? Step-by-step procedure for rescuing your site

Text
Table of contents

You're reading this in emergency mode — your site is showing someone else's content, Google warns "This site contains malware", and your client is furious. Stay calm. Most WordPress hacks can be fixed in 4–8 hours if you follow the steps below exactly. Here's the order of actions that limits the damage and gets you to a clean site faster.

In short

  • The first 30 minutes: don't panic, turn on maintenance mode.
  • First 2 hours: diagnosis and identifying the source of the attack.
  • First 4 hours: malware cleanup or backup restore.
  • First 24 hours: hardening + reporting to Google + monitoring.
  • Weekly afterwards: verifying that the attacker has no backdoor.

Signs that your WordPress site has been hacked

🚨 Some signs:

  • Posts / pages you didn't publish
  • Links to "viagra", "casino", "pożyczki" in the content
  • Your website redirects to a foreign domain
  • Google Chrome shows “This site may harm your computer”
  • A "Manual action: Hacked content" notification in Search Console
  • Your hosting provider sent an email: “We detected malware on your account”
  • Your site loads strangely slowly
  • New users with the Administrator role in the WP dashboard
  • Antivirus software (on your computer) blocks the site when you try to open it

⚠️ Possible symptoms:

  • Unexplained traffic drop in GA
  • Customers report receiving a batch of spam content in an email
  • You see different files in /wp-content/uploads than the ones you uploaded

STEP 1: The first 30 minutes — getting the situation under control

1.1 Enable maintenance mode

You can't leave an infected site online — Google will penalize it faster, and customers will lose trust.

Option A: The WP Maintenance Mode plugin (if you still have access to the dashboard).

Option B: Hosting → cPanel → Put a index.html file in the root with a simple message:

<h1>Strona w przerwie technicznej</h1>
<p>We'll get back to you within a few hours.</p>

Option C: W .htaccess:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^TWOJ_IP$
RewriteRule .* /maintenance.html [R=503,L]

1.2 Change ALL passwords

Immediately:
– WP admin password
– Hosting panel password (cPanel)
– FTP password
– MySQL database password
– Admin email password (important, because password resets go to this email!)
– API keys (Stripe, PayU, GoogleMaps, Google Analytics)

Every password different, at least 16 characters, from a password manager.

1.3 Make a copy of the hacked site (for analysis)

It sounds strange, but keep a copy of the hacked state before cleaning. You may need it for:
– Identifying the attack vector
– Evidence if you report identity theft
– A post-mortem audit

A full copy: files + database. Keep it on an external drive.

1.4 Disable auto-deploy / cron

If you have CI/CD or any auto-deploys from Git — turn them off. The attack may be in the repository.

STEP 2: 2 hours — diagnostics

2.1 Logging in on the hosting side

If the WP admin doesn't work, use phpMyAdmin (cPanel → databases).

SELECT * FROM wp_users WHERE user_login = 'twoj_admin';

Check that the email and password have not been changed.

If they remain:

UPDATE wp_users 
SET user_pass = MD5('NoweHaslo123!@#') 
WHERE user_login = 'twoj_admin';

(On the next login, WordPress will hash the password securely — MD5 is used only for this emergency action.)

2.2 Check users with the Administrator role

SELECT u.user_login, u.user_email, m.meta_value 
FROM wp_users u 
JOIN wp_usermeta m ON u.ID = m.user_id 
WHERE m.meta_key = 'wp_capabilities' 
  AND m.meta_value LIKE '%administrator%';

Any admin you don't recognize = a hacker. Delete them, but keep the records for the report.

2.3 Scan files for malware

Online (external scan):

Internal scan:

  • Wordfence Free — Tools → Scan
  • MalCare — plugin, does a scan + auto-clean
  • WPScan — command-line tool for advanced users

2.4 Check the most suspicious places

Attackers most often leave malware in:

  • /wp-content/uploads/ — PHP files that shouldn't be there
  • /wp-content/plugins/ — fake plugins (e.g., "wp-vcd", "wpfm-bg")
  • /wp-content/themes/[motyw]/functions.php — injected code
  • /wp-config.php — check whether there is any extra <?php eval(...)?>
  • wp-cron.php — modified
  • .htaccess — redirects to external domains

2.5 Check the server logs

cPanel → Statistics → Latest Visitors. Look for:
– Unusual POST requests to wp-login.php
– A large number of requests from a single IP
– Requests to wp-content/uploads/[plik].php

Write down the attacker's IP address — you'll need it for the report.

STEP 3: 4 hours — cleanup

Option A: Restore a backup (recommended)

If you have a backup from before the break-in:

  1. Download a backup from UpdraftPlus / your hosting
  2. Delete everything from the hosting account (wp-content, wp-includes, wp-admin, database)
  3. Upload a fresh WordPress core
  4. Upload the wp-content backup
  5. Import database backup
  6. Check whether post dates / admin activity match "before the break-in"

If you don't know when the breach happened:

Check the files — which ones have a modification date that doesn't match the rest? (Linux: find . -mtime -7 — files modified in the last 7 days.)

Option B: Manual cleanup (without a backup)

This one is harder. Consider getting professional help first.

Steps:
1. Download a fresh WordPress from wordpress.org/download
2. Replace the wp-admin and wp-includes folders with fresh ones
3. DO NOT overwrite wp-content (that's where your content is)
4. Download every installed plugin from the official repository again
5. Download the theme from the official source again
6. Check wp-config.php — remove injected code
7. Update the secret keys (api.wordpress.org/secret-key/1.1/salt/)
8. In the database, check the wp_options tables (key = siteurl, home — make sure they haven't been changed to a foreign domain)

Option C: Professional services

  • Sucuri — one-time malware cleanup for 199 USD + monitoring
  • MalCare — automatic, from 99 USD/year
  • WordFence Care — premium, premium support kicks in within an hour

For medium and large businesses — this is the fastest route.

STEP 4: 24 hours — post-hack hardening

After cleanup:

4.1 Update everything

WordPress core, all plugins, theme: the latest stable versions.

4.2 Strengthen your security

Complete all 12 steps from the security guide.

4.3 Report it to Google

Search Console → Security issues → “Request a review.” Google will rescan your site and, if it’s clean, remove the warning. Time: 24–72 hours.

4.4 Notify your customers

If customer data has leaked (contact form, WooCommerce database) — under GDPR (RODO) you have 72 hours to report it to UODO (the Polish data protection authority) and notify those affected.

4.5 Documentation

Record:
– Date of the breach (approximate)
– Attack vector
– What was changed
– How it was fixed
– Security plan

For an auditor, an insurer, a lawyer.

STEP 5: One week later — monitoring

5.1 Daily Wordfence scan

First week: scan daily. Hackers often leave a second backdoor — they want to come back.

5.2 Login monitor

Check Wordfence → Live Traffic. Every unauthorized login = a signal to act.

5.3 External re-scan

Sucuri SiteCheck every week for 4 weeks.

5.4 Google verification

GSC → Coverage → Indexing. Check that all pages are being re-indexed.

What Hacked Websites Teach Us

  1. The most common way in is neglected updates — a plugin fix has often been available for months
  2. An off-site backup is the only thing that always works — a key investment
  3. Hacked site owners try to argue “it's theft” — unfortunately, if the passwords were weak, it's your fault too
  4. Response time is decisive — an attack detected within 1 hour gets fixed in 4 hours. Detected after a week — in 4 days
  5. Professional help pays off — 1 000 zł for professional cleanup vs the risk of losing your brand

What's next

If you're not in emergency mode and just read this "in advance" — congratulations, that's a smart approach. Enter now:

  1. Off-site backup (UpdraftPlus → Google Drive)
  2. 2FA for all administrators
  3. Wordfence Free
  4. Response plan (who to call if it happens)

We have a “Red Line” for hacked sites — we respond within 1 hour, clean up within 24, and guarantee stability. Get in touch (phone recommended in an emergency).

Your feedback

Was this article helpful?

One click — it helps me choose future topics.

Share this article

Websky Newsletter

New posts straight to your inbox.

Once a month — practical insights on WordPress, WooCommerce, SEO and AI. No spam, unsubscribe with one click.

  • Case studies from Polish projects
  • Checklists and templates to download
  • Google and WordPress changes in a nutshell

Your data goes to Websky Studio only. You can unsubscribe with one click in every message.

Website administration

Backups, monitoring and peace of mind.

Ongoing WordPress care: updates, backups, uptime monitoring, and a fast response when something goes wrong.

See website care plans