Website Defaced? What to Do Right Now
A defacement is the rare intrusion that announces itself, which makes it tempting to treat it as a cosmetic problem. It isn't: whoever replaced your homepage had write access to your server, and the visible message is the least interesting thing they did with it.
Want to see what a professional report looks like? Read the sample report
Take it offline the right way
Your first instinct is to get the message off the internet, and that's correct. How you do it decides whether you also lose your search rankings.
Serve a maintenance page with HTTP 503, not 200
A maintenance page that returns 200 OK tells search engines that this placeholder is your site now, and they will index it in place of your real pages. A 503 Service Unavailable says "temporarily down, come back" - crawlers retry and your existing pages keep their positions. Add a Retry-After header if you can estimate the duration.
In nginx, in the server block for the site:
location / {
return 503;
}
error_page 503 /maintenance.html;
location = /maintenance.html {
root /var/www/maintenance;
add_header Retry-After 3600 always;
internal;
}On Apache, the equivalent lives in .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/maintenance.html
RewriteRule ^ /maintenance.html [R=503,L]
ErrorDocument 503 /maintenance.html
Header always set Retry-After "3600"If you have no server access, the hosting panel's maintenance mode or Cloudflare's "Under Attack"/custom page will do - just confirm what status code it actually returns before you trust it.
Don't delete the defacement
Screenshot the defaced page, save a copy of the modified file, and note the exact time you first saw it. It's evidence, it often identifies the group or the automated campaign behind it, and the file's modification timestamp is the anchor for your whole timeline - it tells you which window of logs to read.
Rotate credentials and cut deploy paths
Whoever did this had write access. Change the CMS admin passwords, the hosting panel password, FTP/SFTP accounts, SSH keys, database credentials and any API or deploy tokens. If a CI/CD pipeline or an agency has push access, suspend it until you know the compromise didn't come through there - a developer's machine is a common route in.
Find out what else they did
The visible message is the part they wanted you to see. These are the parts they didn't.
Look for web shells and modified files
Find everything written in the window around the defacement. From the web root:
find . -type f -mtime -14 -ls | sort -k8
find . -type f -name "*.php" -newermt "2026-10-01"Pay particular attention to PHP files in upload and media directories, which should never contain executable code, to files with innocuous names in odd places (wp-content/uploads/2026/10/img.php is not an image), and to anything containing eval(, base64_decode(, assert(, system( or long obfuscated blobs. Check .htaccess files in every directory, not just the root - attackers use them to make uploads executable or to redirect only search-engine traffic.
Check for injected SEO spam and cloaking
This is the damage that outlives the defacement. Attackers routinely inject pharma or casino spam that is served only to Googlebot, or hidden links in your footer and templates. Because it's invisible in a normal browser, people declare the site clean while it's still poisoning their rankings. Compare what a crawler sees with what you see:
curl -s -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" https://example.com/ | grep -iE "viagra|casino|payday|replica|hidden"Then search Google for site:example.com and look for pages you never created.
Audit accounts and scheduled tasks
Look for new CMS administrators, new database users, new SSH keys in authorized_keys, and new cron jobs or scheduled tasks. These are the mechanisms that bring the defacement back after you've cleaned the files, and they're the reason a file-level cleanup alone so rarely holds.
Read the logs around the timestamp
With the file's modification time as your anchor, read the access logs either side of it. You're looking for POST requests to admin or upload endpoints, successful logins from unfamiliar addresses, requests for files that shouldn't exist, and the long scan that usually precedes the hit. This is where the entry point actually reveals itself.
How defacements usually happen
- Stolen or reused credentials - the CMS, the hosting panel, FTP or SSH. Frequently from an unrelated breach where the same password was reused, or from a password-stealing infection on a developer's laptop.
- A vulnerable plugin, theme or component - especially abandoned ones, and nulled commercial plugins that ship with a backdoor pre-installed.
- An unrestricted upload or injection flaw - a form that accepts a PHP file, or an injection that lets the attacker write one.
- A neighbour on shared hosting - one compromised site in a poorly isolated account can reach the others.
- Exposed services - an admin panel, database port, exposed
.gitdirectory or backup file reachable from the internet. Check your own host with the port scanner or the broader perimeter scan.
Mass defacement campaigns are overwhelmingly automated and opportunistic - the scanner found a known vulnerable version and moved on to the next of a thousand targets. That's reassuring about motive and not at all reassuring about access.
Clean, restore, and verify
The order that works: identify the entry point, then rebuild or restore, then patch, then bring it back online.
Restoring from a backup is the fastest route if - and only if - you can date the compromise and pick a backup from before it. Without that date you may be restoring the backdoor along with the content. Where the compromise is old or undatable, a clean rebuild is genuinely faster than chasing files: fresh CMS core, plugins and themes reinstalled from official sources, and only your content and database migrated across after inspection.
Before lifting the maintenance page, verify: no files modified outside your deploy process, no unknown admin accounts, no unexpected cron jobs, the Googlebot comparison above comes back clean, and a crawler-eye search for site:yourdomain.com shows nothing foreign. Then remove the 503 and watch the logs for the attacker returning to check their work - they often do.
Repair the search-engine damage
Two things need attention after the site is clean. First, Google Search Console's Security Issues report: if the site was flagged for malware or spam, fix the cause and then request a review - the flag does not clear on its own, and an interstitial warning in search results costs more traffic than the outage did. Check Bing Webmaster Tools too. Second, if spam pages were indexed while the site was compromised, remove them and let the 404s be crawled - a robots.txt block at this point is counterproductive, because a blocked URL can't be recrawled and the stale entry lingers.
If the defacement is still in Google's cache, it clears on the next crawl; requesting indexing for the affected URLs speeds that up.
Make the next one not happen
Keep the CMS, plugins and themes updated and delete anything you no longer use - abandoned plugins are the single most common route in. Put MFA on every admin account, including the hosting panel. Remove write permissions from the web server where it doesn't need them, and block PHP execution in upload directories entirely. Take backups that are offline or at least not writable from the web server, and restore one occasionally to prove it works. Add file-integrity monitoring so the next unauthorised change is an alert rather than a customer's phone call.
If the site runs WordPress, the WordPress-specific cleanup guide goes deeper on where infections hide in that stack. For the general containment sequence across any kind of compromise, see what to do when you have been hacked, and if you're unsure whether this was an isolated defacement or the visible part of something larger, the twelve signals of a compromise is the triage list.
And if the real question is what else on that server is reachable, that's what web application penetration testing answers - the same look an attacker takes, written up with the fixes ranked. Get in touch if you'd like me to verify a cleanup or find the hole properly.
Defacement questions
No, and this is the most expensive mistake available here. Replacing the defaced file fixes the symptom while leaving the access that produced it - the web shell, the modified plugin, the stolen key, the rogue admin account. Sites cleaned this way typically get defaced again within days, and the second time the attacker is usually quieter about it. Find the entry point and the persistence before you restore anything.
Briefly, if you handle it correctly. A short outage served as HTTP 503 costs you very little - Google is built to retry. Lasting damage comes from two other things: a defacement or injected spam being crawled and indexed while it's live, and a Safe Browsing malware flag, which replaces your result with an interstitial warning and can halve traffic overnight. That's why the maintenance page must return 503 rather than 200, and why you check Search Console's Security Issues report before you consider the job done.
Updates close the most common route, not the other five. The usual suspects are stolen or reused credentials for the CMS, hosting panel, FTP or SSH; a vulnerable or abandoned plugin or theme (including nulled ones that ship with a backdoor); a compromised developer or agency machine with deploy access; a neighbour on the same shared hosting account; and an exposed service like a database, admin panel or Git directory that was never meant to face the internet. A port scan of your own host answers that last one in a minute.
If the site only served static marketing content and nothing else was reachable from it, usually not - though saying something builds more trust than saying nothing, because visitors and competitors may have screenshots. It becomes a duty rather than a choice when personal data could have been accessed, payment pages were in scope, or user accounts exist on the site. Those are notification questions with statutory deadlines attached, and they go to counsel, not to a blog post.
Yes, and it costs you little. Unauthorised access to a computer system is a crime in essentially every jurisdiction, defacements are frequently mass-automated against hundreds of sites at once, and your report helps connect those cases. It also creates the paper trail an insurer or a client may later ask for. The channel depends on where you are - the country-by-country list is here.
Defaced once and worried it'll happen again?
Find the entry point, verify the cleanup, and close the hole properly.