WHAT TO DO WHEN YOUR WORDPRESS SITE IS HACKED
A hacked website can be stressful, but with the right steps and tools, you can recover your site and strengthen its security to prevent future attacks. This guide provides a step-by-step recovery process and explains how Yogi’s VPS can assist you during this critical time.
Step 1: Identify the Hack
Symptoms of a Hacked Website
- Your site is defaced or displays unwanted content.
- Visitors see warnings about malware or phishing.
- You notice unauthorized logins or changes.
- Your site is redirecting to unknown URLs.
- Google flags your site as compromised in search results.
Step 2: Take Your Website Offline
Prevent further damage by temporarily taking your site offline:
- Deactivate the Site: Use cPanel’s File Manager to rename your
public_html
directory (e.g.,public_html_backup
). - Display a Maintenance Page: Create a simple
index.html
file with a maintenance message to reassure visitors.
Step 3: Scan Your Website for Malware
Use tools to identify malicious files or code:
- Yogi’s VPS Malware Scanner:
- Log in to your Yogi’s VPS cPanel and access the Virus Scanner tool.
- Scan your website files for malware.
- WordPress Security Plugins:
- Install plugins like Wordfence or Sucuri Security to scan for infected files and malicious code.
Step 4: Remove Malicious Files and Code
Manual Cleanup
- Identify Infected Files:
- Review malware scan results for flagged files.
- Restore Clean Backups:
- If you have a recent backup, restore it via cPanel’s Backup Wizard.
- Remove Suspicious Files:
- Use cPanel’s File Manager or FTP to delete unfamiliar or suspicious files, especially in directories like
/wp-content/uploads
,/wp-includes
, and/wp-content/themes
.
- Use cPanel’s File Manager or FTP to delete unfamiliar or suspicious files, especially in directories like
Reinstall Core Files
- Download a fresh copy of WordPress from wordpress.org.
- Replace the following directories on your server:
/wp-admin
/wp-includes
- Replace all WordPress core files except
wp-config.php
and the/wp-content
directory.
Step 5: Reset Passwords and Permissions
- Change All Passwords:
- Update passwords for cPanel, FTP, WordPress admin, and database users.
- Use strong, unique passwords.
- Check User Accounts:
- Log in to your WordPress admin dashboard and review Users. Delete any unauthorized accounts.
- Fix File Permissions:
- Set file permissions to secure values:
- Folders:
755
- Files:
644
- Folders:
- Set file permissions to secure values:
Step 6: Secure Your Database
- Check for Unauthorized Changes:
- Log in to phpMyAdmin via cPanel and review tables like
wp_users
andwp_options
.
- Log in to phpMyAdmin via cPanel and review tables like
- Change Database Credentials:
- Update your database password in MySQL Databases in cPanel.
- Update the
DB_PASSWORD
in yourwp-config.php
file.
Step 7: Update and Harden Your Website
- Update WordPress Core, Themes, and Plugins:
- Install the latest versions of WordPress, all themes, and plugins.
- Remove unused themes and plugins.
- Harden WordPress:
- Disable XML-RPC:
- Add the following to
.htaccess
:
- Add the following to
- Disable XML-RPC:
Copy to Clipboard