How to Prevent and Recover From a Hosting Account Hack
Your site is hacked, or you want to make sure it never is. This guide covers both: a step-by-step emergency recovery playbook and a comprehensive prevention checklist. From identifying the attack vector to cleaning malware, recovering from Google blacklists, and hardening your security for the future.

Web hosting enthusiast who tests providers and breaks down features, pricing, and real world speed

Signs Your Hosting Account Is Hacked
| Symptom | What It Looks Like | Severity | Likely Attack Type |
|---|---|---|---|
| Site redirects to spam/malware URLs | Visitors land on pharmacy, gambling, or phishing sites instead of yours | 🔴 Critical | Malware injection (.htaccess or JS redirect) |
| Google 'This site may be hacked' warning | Search results show warning label; CTR drops 60–90% | 🔴 Critical | SEO spam injection or malware detected by Google |
| Browser security warning (red page) | Chrome/Firefox blocks visitors with 'Deceptive site ahead' | 🔴 Critical | Phishing content or malware distribution detected |
| Unknown files in web root | New .php files, .htaccess modifications, or hidden directories | 🟠 High | Backdoor/webshell upload |
| Hosting account suspended | Host sends email: 'Account suspended for malicious activity' | 🟠 High | Host-detected malware, spam sending, or resource abuse |
| Outbound spam from your email/server | Bounce-back emails for messages you didn't send; IP blacklisted | 🟠 High | Compromised email account or PHP mail() abuse |
| Unknown admin users in CMS | New WordPress/Joomla admin accounts you didn't create | 🟠 High | Credential theft or privilege escalation exploit |
| Sudden traffic spike to strange URLs | Analytics shows visits to /wp-content/uploads/shell.php or similar | 🟡 Medium | Backdoor being actively used |
| Site loading extremely slowly | Pages take 10+ seconds; server resources maxed | 🟡 Medium | Cryptomining malware or DDoS bot |
| Content changes you didn't make | New pages, modified text, or injected links to external sites | 🟡 Medium | SEO spam or content injection |
Immediate Response (First 30 Minutes)
⚠️ Emergency mode: Follow these steps in order. Don't skip any; each one prevents further damage.
Change ALL passwords immediately
(0–5 min)Hosting panel (cPanel/Plesk), CMS admin (WordPress wp-admin), FTP/SFTP, database (MySQL), email accounts, domain registrar. Use a password manager to generate unique 20+ character passwords. Do NOT reuse any previous passwords.
Enable 2FA on every account
(5–8 min)Hosting panel, CMS admin, domain registrar, email, and any connected services (Cloudflare, CDN, DNS). Use an authenticator app (Google Authenticator, Authy), not SMS.
Take the site offline
(8–12 min)Put site in maintenance mode to stop serving malware to visitors. Quick method: rename your index.php to index.php.hacked and upload a simple maintenance page. Or use .htaccess to block all traffic except your IP.
Contact your hosting provider
(12–15 min)Open a support ticket marked URGENT. Ask for: 1) Malware scan results 2) Available clean backups 3) Access logs for the past 7 days 4) Any automated security actions taken. Most managed hosts have security incident teams.
Revoke all active sessions and API keys
(15–20 min)In WordPress: change security salts in wp-config.php (forces all users to re-login). Revoke any API keys, OAuth tokens, and third-party app connections. Regenerate database credentials.
Document everything
(20–25 min)Screenshot symptoms, note timestamps, save error messages. Check email for any password reset notifications you didn't initiate. This documentation is critical for: identifying the attack vector, filing reports with your host, and potential legal/compliance requirements.
Scan your local machine
(25–30 min)Your local computer may be compromised (keylogger, credential-stealing malware). Run a full antivirus scan before accessing any accounts from it. If possible, use a different trusted device for recovery.
Identify the Attack Vector
| Attack Vector | Frequency | How to Detect | Evidence to Look For |
|---|---|---|---|
| Vulnerable plugin/theme | ~40% | Check plugin versions against known CVEs (WPScan, Patchstack) | Recently updated plugin files; exploit payload in access logs targeting plugin URLs |
| Weak/reused passwords | ~20% | Check access logs for brute-force attempts (thousands of wp-login.php requests) | Successful login from unknown IP; no file upload vulnerability needed |
| Credential stuffing (leaked passwords) | ~15% | Check haveibeenpwned.com for your email; review login locations in CMS | Single successful login (not brute force) from foreign IP/VPN |
| Shared hosting cross-contamination | ~10% | Ask host if other accounts on the server were compromised | Malware in system-level directories; symlink attacks across accounts |
| Outdated CMS core | ~8% | Verify WordPress/Joomla version against latest release | Known exploit signatures in access logs matching old version vulnerabilities |
| File upload vulnerability | ~5% | Check upload directories for PHP files disguised as images | Files like image.php.jpg or .php files in /uploads/ directory |
| SQL injection | ~3% | Check access logs for SQL syntax in URL parameters | Modified database entries; injected admin users; encoded payloads in GET parameters |
| SSH/FTP compromise | <2% | Review FTP/SSH login logs for unknown IPs | File changes via FTP from unfamiliar locations; authorized_keys modification |
Malware Removal & Cleanup
| Step | Action | Tools / Commands |
|---|---|---|
| 1. Full file scan | Run malware scanner across all files | Sucuri SiteCheck (free), Wordfence scan, ImunifyAV (host-level), ClamAV (server-level) |
| 2. Find recently modified files | List files modified in last 7–30 days | find /home/user/public_html -mtime -7 -type f | grep -E '\.(php|js|html)$' |
| 3. Check .htaccess files | Look for redirect rules, base64-encoded content | find . -name '.htaccess' -exec cat {} \;, compare against clean defaults |
| 4. Search for base64/eval patterns | Find obfuscated malicious code | grep -rl 'eval(base64_decode' /home/user/public_html/ or grep -rl 'gzinflate' . |
| 5. Check for webshells/backdoors | Look for standalone PHP files in upload directories | find wp-content/uploads -name '*.php': there should be zero PHP files in uploads |
| 6. Compare with clean source | Diff your files against known-clean originals | Download fresh WordPress core from wordpress.org; diff -r clean-wp/ your-wp/wp-includes/ |
| 7. Remove malicious files | Delete backdoors, webshells, and injected files | Delete unknown files; replace modified core files with clean originals; don't delete wp-config.php |
| 8. Check cron jobs | Attackers often install persistent cron jobs | crontab -l (check all user crontabs); check wp-cron events via WP-CLI: wp cron event list |
| 9. Verify file permissions | Reset to secure defaults | Directories: 755, Files: 644, wp-config.php: 400 or 440. Never use 777. |
| 10. Re-scan after cleanup | Confirm all malware is removed | Run all scanners again. Check from external scanner (Sucuri SiteCheck) to verify visitor-facing is clean. |
WordPress-Specific Recovery
WordPress recovery commands (via SSH or WP-CLI)
# 1. Replace WordPress core files with clean versions
wp core download --force --skip-content
# 2. Check for unknown admin users
wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
# 3. Delete suspicious admin accounts
wp user delete SUSPICIOUS_USER_ID --reassign=YOUR_ADMIN_ID
# 4. Reset all user passwords
wp user reset-password $(wp user list --field=ID)
# 5. Regenerate security salts (forces all sessions to expire)
wp config shuffle-salts
# 6. Reinstall all plugins from clean sources
wp plugin install $(wp plugin list --field=name) --force
# 7. Check for modified theme files
wp theme verify-checksums --all
# 8. Verify core file integrity
wp core verify-checksums
# 9. Search database for injected content
wp db search "eval(" --regex
wp db search "<script" --regex
wp db search "base64_decode" --regex
# 10. Flush all caches
wp cache flush
wp rewrite flush| WordPress File/Area | Common Malware Locations | What to Check |
|---|---|---|
| wp-config.php | Injected require() or include() at top/bottom of file | Compare with default wp-config-sample.php; check for unknown require/include statements |
| .htaccess (root) | Redirect rules sending visitors to malware/spam sites | Should only contain standard WordPress rewrite rules unless you've customized it |
| wp-content/uploads/ | PHP backdoors disguised as images (.php files) | Should contain ZERO .php files, only images, PDFs, etc. |
| wp-includes/ | Modified core files with injected code | Run wp core verify-checksums, any mismatch indicates modification |
| Theme functions.php | Injected eval/base64 code at top or bottom | Check all active AND inactive themes, attackers inject into unused themes too |
| wp-content/plugins/ | Fake plugins (single-file plugins with generic names) | Look for plugins you don't recognize; check plugin headers for suspicious content |
| Database (wp_options) | Injected JavaScript in siteurl, home, or widget options | Check siteurl and home values; search for <script> tags in serialized widget data |
| Database (wp_posts) | Spam links or redirects injected into post content | Search for <iframe>, <script>, eval, and base64 in post_content column |
Database Cleanup
SQL queries to detect and clean database injections
-- ALWAYS backup database before running cleanup queries
-- mysqldump -u user -p database > backup_before_cleanup.sql
-- Find injected scripts in posts
SELECT ID, post_title FROM wp_posts
WHERE post_content LIKE '%<script%'
OR post_content LIKE '%eval(%'
OR post_content LIKE '%base64_decode%'
OR post_content LIKE '%document.write%';
-- Check for modified site URL (common hack indicator)
SELECT option_name, option_value FROM wp_options
WHERE option_name IN ('siteurl', 'home', 'blogname', 'blogdescription');
-- Find suspicious users created recently
SELECT * FROM wp_users
WHERE user_registered > DATE_SUB(NOW(), INTERVAL 30 DAY)
ORDER BY user_registered DESC;
-- Check for injected admin capabilities
SELECT * FROM wp_usermeta
WHERE meta_key = 'wp_capabilities'
AND meta_value LIKE '%administrator%';
-- Find spam links in comments
SELECT comment_ID, comment_content FROM wp_comments
WHERE comment_content LIKE '%<a href%'
AND comment_approved = '1';DNS & Email Verification
| Check | Why | How to Verify |
|---|---|---|
| DNS A/CNAME records | Attacker may have changed DNS to point to their server | dig example.com A, verify IP matches your hosting server |
| DNS MX records | Attacker may redirect email to intercept password resets | dig example.com MX, verify mail servers are correct |
| DNS nameservers | Full DNS takeover allows complete domain control | whois example.com, verify nameservers match your DNS provider |
| Domain registrar account | Attacker may have transferred or locked the domain | Login to registrar; verify contact info, transfer lock status, and 2FA |
| SPF/DKIM/DMARC records | Attacker may have modified email authentication to send spam | Check TXT records: dig example.com TXT, compare with your expected values |
| Email IP blacklist status | Your server IP may be blacklisted from sending spam | Check mxtoolbox.com/blacklists.aspx with your server IP |
| SSL certificate | Attacker may have issued their own cert for phishing | Check certificate issuer and validity in browser; verify via crt.sh for unexpected certs |
Google Blacklist Recovery
| Step | Action | Timeline |
|---|---|---|
| 1 | Verify site is fully clean, run external scanners (Sucuri SiteCheck, VirusTotal, Google Safe Browsing diagnostic) | Before requesting review |
| 2 | Login to Google Search Console → Security Issues section | Check for specific issues listed |
| 3 | Fix ALL security issues listed, Google won't remove warnings for partial fixes | Complete all fixes before proceeding |
| 4 | Click 'Request a Review' in Search Console → Security Issues | Google reviews within 1–3 days for malware, up to 14 days for spam |
| 5 | If you have a Manual Action (Search Console → Manual Actions), file a separate reconsideration request | Response within 1–4 weeks |
| 6 | Check Google Safe Browsing status: transparencyreport.google.com/safe-browsing/search | Updates within 24–72 hours after approval |
| 7 | Monitor Search Console for re-crawling, submit updated sitemap and request indexing for key pages | Rankings typically recover within 1–4 weeks |
| 8 | If warning persists after 2 weeks, re-scan and submit another review with detailed cleanup description | Document every action taken |
Prevention: Hardening Your Account
| Category | Action | Impact | Difficulty |
|---|---|---|---|
| Passwords | Use unique 20+ character passwords on all accounts | Blocks ~20% of attacks (brute force + credential stuffing) | Easy |
| Authentication | Enable 2FA on hosting, CMS, registrar, email | Blocks account takeover even if password is compromised | Easy |
| Updates | Auto-update CMS core, plugins, and themes | Patches ~40% of attack vectors (vulnerable plugins) | Easy |
| Firewall | Install WAF (Cloudflare free, Wordfence, Sucuri) | Blocks exploit attempts, bot traffic, and known attack patterns | Easy |
| Hosting | Use managed hosting with server-level security (Imunify360, ModSecurity) | Blocks attacks before they reach your application | Easy (choose right host) |
| Backups | Automated daily backups stored off-server (S3, Google Drive) | Enables rapid recovery, restore clean version in minutes | Easy |
| Plugin hygiene | Remove unused plugins and themes; audit monthly | Reduces attack surface, fewer plugins = fewer vulnerabilities | Easy |
| Login hardening | Limit login attempts (3–5); change wp-login.php URL; disable XML-RPC | Blocks brute-force attacks; hides login endpoint from bots | Medium |
| File permissions | Set directories to 755, files to 644, wp-config to 400 | Prevents unauthorized file modification even if partial access gained | Medium |
| File integrity monitoring | Use Wordfence, OSSEC, or Tripwire to detect file changes | Alerts you immediately when files are modified, catches hacks early | Medium |
| Security headers | Add HSTS, CSP, X-Frame-Options, X-Content-Type-Options headers | Prevents XSS, clickjacking, and protocol downgrade attacks | Medium |
| Database prefix | Change default wp_ table prefix to a custom prefix | Makes SQL injection harder (attacker must guess table names) | Medium |
| Disable file editing | Add define('DISALLOW_FILE_EDIT', true) to wp-config.php | Prevents attackers from editing theme/plugin files via WP admin | Easy |
| PHP restrictions | Disable dangerous PHP functions (exec, system, passthru) in php.ini | Prevents webshells from executing system commands | Advanced |
Hosting Provider Security Features
| Provider | Malware Scanning | WAF | Free Cleanup | Auto-Backups | 2FA |
|---|---|---|---|---|---|
| Kinsta | ✅ Daily + on-demand | ✅ Cloudflare Enterprise | ✅ Free malware removal | ✅ Daily (30 days) | ✅ |
| WP Engine | ✅ Automated scanning | ✅ Built-in WAF | ✅ Included in plan | ✅ Daily (40 days) | ✅ |
| SiteGround | ✅ AI-powered (Site Scanner) | ✅ Custom WAF rules | ✅ First cleanup free | ✅ Daily (30 days) | ✅ |
| Cloudways | ✅ Imunify360 + Malcare | ✅ OS-level firewall | ⚠️ Self-service or paid addon | ✅ On-demand + scheduled | ✅ |
| Hostinger | ✅ Monarx malware scanner | ✅ Built-in protection | ⚠️ Limited assistance | ✅ Weekly | ✅ |
| A2 Hosting | ✅ Imunify360 | ✅ ModSecurity + custom rules | ⚠️ Paid HackScan monitoring | ✅ Server-level (rewind) | ✅ |
| Bluehost | ⚠️ SiteLock (paid addon) | ⚠️ Basic ModSecurity | ❌ Paid service | ⚠️ CodeGuard (paid addon) | ✅ |
Ongoing Monitoring Setup
| Tool | Type | Free Tier | What It Monitors |
|---|---|---|---|
| Google Search Console | Google integration | ✅ Free | Security issues, manual actions, indexing problems, Core Web Vitals |
| Sucuri SiteCheck | External scanner | ✅ Free | Malware, blacklist status, SSL issues, security headers |
| UptimeRobot | Uptime monitor | ✅ Free (50 monitors) | Site availability, SSL expiry alerts, response time |
| Wordfence (WordPress) | Security plugin | ✅ Free tier | File integrity, login security, firewall, malware scan |
| Patchstack (WordPress) | Vulnerability monitoring | ✅ Free tier | Plugin/theme vulnerabilities, real-time CVE alerts |
| Cloudflare | CDN + security | ✅ Free tier | DDoS protection, bot detection, WAF rules, analytics |
| Certificate Transparency (crt.sh) | SSL monitoring | ✅ Free | Unauthorized SSL certificate issuance for your domain |
| Have I Been Pwned | Credential monitoring | ✅ Free | Check if your email/passwords appeared in data breaches |
Incident Response Plan Template
| Phase | Action | Responsible | Timeframe |
|---|---|---|---|
| Contain | Change all passwords + enable 2FA | Site owner / IT admin | 0–10 min |
| Contain | Take site offline (maintenance mode) | Site owner / developer | 10–15 min |
| Contain | Contact hosting provider security team | Site owner | 15–20 min |
| Assess | Identify attack vector from logs | Developer / security team | 1–4 hours |
| Assess | Determine data exposure scope | Developer / legal | 1–4 hours |
| Remediate | Remove malware and clean all files | Developer / security service | 4–24 hours |
| Remediate | Patch vulnerability that allowed the hack | Developer | 1–4 hours |
| Remediate | Restore from clean backup if needed | Developer / hosting support | 1–2 hours |
| Recover | Request Google review if blacklisted | Site owner / SEO team | Same day |
| Recover | Notify affected users if data was exposed (GDPR/CCPA) | Legal / site owner | Within 72 hours |
| Harden | Implement all prevention measures | Developer | 1–3 days |
| Review | Write post-incident report with root cause + improvements | Site owner / developer | Within 1 week |
Frequently Asked Questions
How do I know if my hosting account has been hacked?
What should I do first when I discover a hack?
Can my hosting provider help me recover from a hack?
How long does it take to recover from a hosting hack?
Should I restore from a backup or clean the existing site?
How do hackers get into hosting accounts?
Will a hack affect my SEO rankings?
How can I prevent future hacks?
Need Secure Hosting with Built-In Protection?
Find hosting providers with free malware scanning, automated backups, WAF protection, and expert security teams, so you're protected before and after any incident.
Find Secure Hosting