WordPress Security ServicesMalware Removal
Defacement

"Hacked By…" Message on Your WordPress Site: How to Fix a Defacement

You open your website and instead of your homepage there's a black page with "Hacked by" and a name, a flag, a slogan or music. That's a defacement. It looks dramatic, and it is embarrassing, but it's usually one of the more straightforward hacks to recover from. Here's what to do, and what not to skip.

Sergey By Sergey, WordPress security specialist Updated 2 min read
In this guide
  1. What a defacement is
  2. Step 1: Take a copy before you fix anything
  3. Step 2: Restore the content
  4. Step 3: Assume there’s more than you can see
  5. Step 4: Close the way in
  6. Step 5: Check search results

What a defacement is

A defacement replaces your visible content, usually the homepage, with the attacker’s message. Common versions:

  • the theme’s index.php, or WordPress’s own index.php, replaced with a “Hacked by…” page;
  • a new index.html in the site root, which many servers show before WordPress;
  • every post title or the site title changed through the database;
  • the attacker’s page set as the static front page.

Step 1: Take a copy before you fix anything

Back up the site as it is. The defaced files and their timestamps help find how the attacker got in.

Step 2: Restore the content

  • Remove the attacker’s index.html or restore index.php from a clean copy.
  • If the theme was changed, reinstall it from the original source.
  • If posts or the site title were changed, restore them, either from a backup of the database taken before the attack, or by hand.

Step 3: Assume there’s more than you can see

A defacement is the visible part. Attackers very often also leave backdoors, extra admin users, or quietly add spam or redirects elsewhere. Check users, look for PHP files in uploads, verify core files with wp core verify-checksums, and scan the site. My step-by-step guide to fixing a hacked WordPress site covers everything.

Step 4: Close the way in

Defacements usually come through an outdated plugin with a known vulnerability, or a weak password. Update everything, delete what you don’t use, change all passwords, end all sessions, and turn on two-factor login. See how to secure WordPress after a hack.

Step 5: Check search results

Search site:yourdomain.com to see if Google indexed the defaced page. Once the site is fixed, use URL Inspection → Request indexing on your homepage so Google picks up the real content quickly.

From my cleanup work: a typical defacement case is fixed in an hour: the homepage is restored, and that’s when the real work starts. In most of them I find at least one backdoor and an extra admin account that the defacer, or someone else using the same hole, left behind. Restoring the homepage without that check is how sites get defaced twice in the same month.

Want it handled for you? A defacement is a hacked site, and my hacked website cleanup covers restoring it, removing the backdoors and closing the hole, for $95.

Sergey, WordPress Security Specialist
About the author
Sergey, WordPress Security Specialist

10 years in WordPress security and incident investigation, and more than 200 websites cleaned of malware. Top Rated on Upwork with a 100% Job Success score. More about me

Frequently Asked Questions

Why would someone deface my small website?

Usually for bragging rights. Some groups deface as many sites as possible and post them on defacement archives to build a reputation. Your site was almost certainly picked by an automated scan for a known vulnerability, not because of who you are.

Is restoring a backup enough?

It removes the visible defacement, but not the way in, and often not the backdoor the attacker left. Without fixing those, defacements commonly happen again.

Can a defacement hurt my Google rankings?

If it stays up, yes: Google may index the defaced page instead of your content, and visitors leave. Fixed quickly, the effect is usually temporary.

Need a hand?

Let me clean your WordPress site for you

Send me your site URL and what you're seeing. I'll reply with what I think is going on and the next step.

$95 per infected site · 1-month guarantee · direct contact with the specialist

Get My Site Cleaned →