You open your website, but instead of your page you see an ad for viagra, a casino redirect, or a black page with a "Hacked by ..." message. Or Google has told you the website is flagged as malware and is removing you from search. Or clients send you screenshots of a phishing email that looks like it comes from your domain. Panic mode. This post is a 24-hour playbook: what to do in the first 30 minutes, the first hour, the first 12 hours, and how to prevent it from happening again.
The first 30 minutes: damage control #
Goal: stop the spread, preserve evidence, notify the right people.
1. Assess what has been hacked #
- The whole website: the homepage is defaced or redirects
- Specific pages: the admin now has hidden links to unwanted websites
- Database: content has been changed, new admin users exist
- Email server: phishing is being sent from your accounts
- File system: suspicious PHP files (backdoor scripts) have been planted
- cPanel: someone has admin access
2. Put the website in maintenance mode #
Stop visitors from seeing the compromised content or being exposed to malware:
- WordPress: activate a maintenance mode plugin, or create an empty
.maintenancefile in the root with the WP timer code - Cloudflare: activate "Under Attack Mode" in the Security tab
- cPanel: you can redirect all requests to a "Maintenance" page through .htaccess
3. Capture the evidence (forensics) #
This is critical because you may need it for insurance, a report, or later identification of the vector:
- A screenshot of the defaced page
- Back up error_log and access_log from cPanel → Metrics → Raw Access
- Back up the current state of the database (mysqldump)
- Back up the current state of the files (a tar archive of the public_html folder)
- List file modification dates (via the SSH find command with the -mtime parameter: you see what has been edited in the last 30 days)
4. Change ALL passwords immediately #
In order of priority:
- cPanel password
- FTP/SFTP password
- SSH key (if you use SSH, regenerate it)
- MySQL root + all DB users
- WordPress admin password
- All email account passwords
- API keys (Stripe, Mailchimp, Google, etc.)
Important: use random passwords of 20+ characters. Not "MojaJaka123!". That gets cracked in 5 minutes.
The first hour: identifying the entry point #
Goal: understand HOW they got in, not just FIX what they did.
5. Check file modification dates #
Via SSH, use the find command with the -mtime parameter:
- Files modified in the last 7 days (except cache)
- PHP files modified in the last 7 days: this is usually the attack vector
- Files with suspicious names (shell, .bak.php, wp-config-backup, etc.)
You will see a list: often it contains one file that is the entry point and 10-20 others that are the payload.
6. Search for known backdoor signatures #
The most common patterns to look for in PHP files with the grep command (recursively through public_html):
- Base64-encoded PHP eval expressions (a combination of an evaluation function and a base64 decoder)
- PHP functions that execute POST parameters directly
- Gzinflate + base64 combinations (compressed obfuscated code)
- preg_replace with the /e modifier (a legacy code execution vector)
- Functions for executing system commands (passthru, system, shell-exec variants)
Any of these functions in your PHP code that is NOT part of the standard WP/plugin core = a backdoor.
7. Check access_log #
A typical attack vector has 3 phases in the log:
- Scan: lots of requests to
wp-login.php,xmlrpc.php, or known vulnerable plugin URLs - Exploitation: a POST request with a large body (the payload)
- Backdoor establishment: a request to a newly created PHP file
In cPanel → Metrics → Raw Access → download the log → grep for IP addresses that made suspicious POST requests.
8. The most common attack vectors in 2026 #
- Outdated plugin (e.g. old WP File Manager, Elementor Pro, Slider Revolution): 60% of all attacks
- Outdated WordPress core
- Brute force on wp-login.php without 2FA
- Compromised admin credentials (phishing, password reuse)
- Vulnerable theme (often nulled/pirated themes)
- SQL injection in custom code
- File upload without validation (a form upload field that accepts .php)
The first 12 hours: cleaning #
Goal: remove all malicious content, restore a clean state.
9. Strategy: clean restore + manual cleanup #
Do not try to "manually clean" a hacked website line by line. An approach that works:
- Identify the last clean backup (from before the infection): JetBackup keeps a history
- Restore to a staging environment (not directly over production)
- Update everything: WordPress core, all plugins, all themes, the PHP version
- Scan the restored website with Wordfence, Sucuri Sitecheck, or Imunify360
- If it is clean → switch DNS to staging, shut down production
- If it is not clean → the backup is older than the infection. Go deeper into the backups.
10. Deleting corrupted files #
If you cannot do a full restore (e.g. too much new content since the infection):
- Delete ALL PHP files in
wp-content/uploads/(the uploads folder must NEVER contain PHP) - Delete all PHP files that are not part of the standard WP/plugin/theme structure
- Re-install the WordPress core from a fresh ZIP
- Re-install all plugins (delete the whole plugin folders, reinstall)
- Re-install the theme, but keep
wp-content/themes/your-child-theme/if you used one
11. Database cleanup #
- Log in to phpMyAdmin
- Review the
wp_userstable: check whether there are new admin users - Review the
wp_optionstable for suspicious transient entries - Check the
wp_poststable for injected content (hidden links) - Search for base64 strings in
wp_options,wp_posts
12. Reset everything that is credential-based #
- All API keys (Stripe, Mailchimp, social media)
- All OAuth tokens (revoke + re-issue)
- All session tokens (via WP-CLI:
wp user session destroy --all) - All "Remember me" cookies (force all users to log in again)
After 24 hours: stabilisation #
13. Hardening #
- Enable 2FA on wp-admin (WP 2FA plugin)
- Enable 2FA on cPanel
- Enable Imunify360 or Wordfence
- Set up a Cloudflare or Sucuri WAF
- Disable file editing in
wp-config.php:define('DISALLOW_FILE_EDIT', true); - Disable XMLRPC if you do not use it
- Limit login attempts (Limit Login Attempts Reloaded plugin)
- Block direct access to wp-admin from all IPs except yours
14. Notifications #
- Google Search Console → if the website has been blacklisted, submit a review request
- Clients if data may have been compromised (GDPR: 72h mandatory)
- AZOP (the Croatian Personal Data Protection Agency) if it is a personal data breach (GDPR Article 33)
- Bank / payment provider if credit card data is at stake
15. Monitoring #
- Weekly scan with Wordfence / Sucuri
- Daily Google Search Console - "Security Issues"
- Daily cPanel - new login locations
- Weekly File Manager check - suspicious new files
- Monthly review of wp_users - new admin users
What NOT to do #
- DO NOT delete everything at once: you lose evidence and possibly important content
- DO NOT pay the ransom if it is ransomware: you will not get access back, you will only fund the next attack
- DO NOT leave production live while forensics is under way: the website keeps spreading malware
- DO NOT restore a backup directly over production: staging first
- DO NOT re-use old passwords: all new, all random
- DO NOT ignore the root cause: if you do not understand how they got in, they will get in again
A hacked website on WMD hosting #
On our hosting, Imunify360 looks for malicious code on the website, and we keep about 20 copies on another server. You restore files and databases yourself through JetBackup in cPanel, following the guide restoring a file or folder from a backup.
A realistic estimate: how long recovery takes #
- A small website, a clean backup exists, only defacement: 2-4 hours
- A medium website, the backup is infiltrated but an older clean state exists: 4-12 hours
- An online store with 5000 products, compromised transactions: 12-48 hours
- An enterprise website, custom code, multi-server: several days, probably an external forensics firm
Has your website been hacked and you do not know where to start? Get in touch through the emergency repair page. The review is free, and we tell you the cause, the deadline and the price before the repair, even when the hosting is not with us.