Skip to content

How to find the backdoor in a hacked WordPress site

By William · · updated · 3 min read

A magnifying glass held over a stack of folded paper documents on a wooden desk
AI-generated image.

Find and remove all four, then change every credential, and the site stays clean.

Key takeaways

  • Scanners match known signatures; a fresh backdoor file has no signature yet.
  • Legitimate uploads are images, PDFs, and media, so flag any PHP file created around the hack window.
  • Check the siteurl and home options; a hijacked value redirects every page.
  • Disable PHP execution in the uploads folder with a .htaccess rule or server config.
  • An unpatched plugin is the most common entry point.

Why a free scanner misses the backdoor

Scanners match known signatures; a fresh backdoor file has no signature yet. If a scanner reports "clean" after a re-infection, treat the original entry point as still present until you have checked the four locations above. The backdoor is the persistence mechanism; the spam redirect is the symptom. If the site was hacked more than once, a backdoor was left behind each time.

Check the uploads folder for hidden PHP files

Open wp-content/uploads and look for .php files; legitimate uploads are images, PDFs, and media. Sort by modification date and flag any PHP file created around the hack window. Open each suspicious file and look for base64_decode, eval, or gzinflate calls. Delete the file and note its path for the hardening step.

Search theme and plugin core files for injected code

Compare each theme and plugin file against a fresh copy from the official source. Look for a single line of obfuscated code at the top or bottom of a .php file. Check functions.php, header.php, footer.php, and index.php in the active theme first. If a plugin was the entry point, its files may still contain the loader even after deactivation.

Inspect .htaccess and web server config for redirect rules

Open the .htaccess file in the site root and in wp-content/uploads. Look for RewriteRule or Redirect lines pointing to domains you do not recognise. Check for a second .htaccess file inside the uploads folder. If the host uses nginx, ask for the server block config; the same redirect can live there.

Illustration: Inspect .htaccess and web server config for redirect rules

Clean the database options and users tables

In wp_options, search for rows whose value contains 'http' to a domain you do not own. Check the siteurl and home options; a hijacked value redirects every page. In wp_users and wp_usermeta, look for an admin account you did not create. Delete the rogue rows and reset the passwords for every remaining account.

Change every credential and close the entry point

Reset the WordPress admin password, the database password, and the FTP/SFTP password. If a plugin or theme was the entry point, delete it and reinstall from the official source. Review the user list and remove any account you do not recognise. Rotate any API keys or service accounts that had file or database access.

Harden the site so the same backdoor cannot return

Disable PHP execution in the uploads folder with a .htaccess rule or server config. Keep the core, themes, and plugins updated; an unpatched plugin is the most common entry point. Use a strong, unique password and enable two-factor authentication on every admin account. Take a clean backup now and schedule automatic backups before the next incident.

Frequently asked questions

Why does a free scanner miss the backdoor?

Scanners match known signatures; a fresh backdoor file has no signature yet.

What should I look for in the uploads folder?

Look for .php files; legitimate uploads are images, PDFs, and media.

How do I check the database for a backdoor?

In wp_options, search for rows whose value contains 'http' to a domain you do not own.

How do I prevent the same backdoor from returning?

Disable PHP execution in the uploads folder with a .htaccess rule or server config.

Related on this site

This article was drafted with AI assistance and checked before publication.

Free calculator: Website hack downtime cost calculator

The full guide: WordPress Hack Recovery Checklist

Free sample: WordPress Hack Recovery Checklist
Get the free sample now, and new guides by e-mail.