·

How to Find a Backdoor in WordPress: 8 File Checks

How to find a backdoor in WordPress: verify checksums, find PHP in uploads, check mu-plugins and drop-ins, grep for webshell code, and read access logs.

Banner reading How to Find a Backdoor in WordPress, a security guide to detecting webshells in WordPress files

Last updated: November 6, 2026 · Skill level: intermediate

To find a backdoor in WordPress, compare every file against a known-good copy, then hunt for what checksums can’t cover: PHP files in wp-content/uploads, unexpected must-use plugins and drop-ins, recently changed files, obfuscated code, and POST requests to odd PHP files in your access logs. Work on a copy, and delete nothing until you have confirmed it.

This guide is for the site that “was cleaned” and got hacked again, or the one where the spam is gone but something still feels wrong. Reinfection almost always means a backdoor survived the cleanup. Below are the eight checks I run, in order, with the exact commands, what normal output looks like, and where each check goes blind.

  • TL;DR: back up first, verify core and plugin checksums, list PHP in uploads, review mu-plugins and drop-ins, sort files by change time, grep for execution patterns, diff themes and premium plugins against fresh copies, and read your access logs for POSTs to strange PHP files.

What is a WordPress backdoor?

A WordPress backdoor is code an attacker leaves behind so they can get back in after the original hole is closed. A webshell is one kind of backdoor: a PHP file that runs commands, uploads files, or edits the database on request, usually through a POST parameter or cookie only the attacker knows.

Backdoors rarely live in one place. In a case Sucuri published on July 22, 2025, a loader at wp-content/mu-plugins/wp-index.php fetched a ROT13-obfuscated remote payload, stored it in the options table under _hdra_core, executed it from a temporary .sess-[hash].php file in uploads, and kept a hidden admin user named officialwp. Delete only one of those pieces and the rest rebuild it.

That is why this guide focuses on files but tells you where the database and user accounts fit in. If the visible symptom is spam or redirects, removing it treats the symptom. Finding the backdoor treats the cause.

Where do WordPress backdoors usually hide?

Backdoors hide where WordPress loads code automatically or where nobody looks: wp-content/uploads, wp-content/mu-plugins, drop-in files like db.php and object-cache.php, cache folders, plugin folders with convincing names, theme files such as functions.php, look-alike files in wp-includes, and PHP configuration files that set auto_prepend_file.

LocationWhat’s normalRed flags
wp-content/uploads/Images, PDFs, video, plugin-generated CSS, an occasional .htaccess or empty index fileAny .php, .phtml, .phar or .php5 file; hidden dot-files such as .sess-*.php; PHP code inside a file named .jpg or .ico
wp-content/mu-plugins/Empty, or loaders your host or agency installed and can nameFiles nobody on the team installed; generic names like index.php or wp-index.php that download remote code (Sucuri, March 28, 2025)
Drop-ins in wp-content/: db.php, object-cache.php, advanced-cache.php, maintenance.php, php-error.php, fatal-error-handler.phpPresent only because a cache, database, or error-handling plugin you use created themA drop-in no installed plugin claims; obfuscated code; advanced-cache.php on a site with no page-cache plugin
wp-content/cache/ and plugin cache foldersStatic HTML, minified CSS and JS, files your cache plugin generatesPHP that reads $_POST, $_REQUEST or cookies, or decodes long strings
wp-content/plugins/One folder per plugin shown in Plugins or wp plugin listA folder or single-file plugin missing from the admin list; a security- or performance-sounding name with no readme, vendor, or update history
Theme files (functions.php, header.php, footer.php)Code that matches the vendor’s release plus your documented editsLong encoded strings, eval, code stuck before the theme header or after the last function
wp-admin/ and wp-includes/Core files onlyAny extra file, especially names that imitate core; WP-CLI reports these as “File should not exist”
Site root: .htaccess, .user.ini, wp-config.phpRewrite rules, PHP limits, your configurationExtra PHP files in root; include lines in wp-config.php; auto_prepend_file pointing at a file you can’t explain

Drop-ins deserve special attention because WordPress loads several of them with no admin toggle. The WordPress developer reference for _get_dropins() lists them: db.php and object-cache.php load automatically, and advanced-cache.php loads when WP_CACHE is true. Must-use plugins are similar: Sucuri notes they activate automatically and don’t appear in the normal Plugins screen.

The .user.ini trick is older but still works. PHP reads per-directory .user.ini files under CGI/FastCGI, and auto_prepend_file is an INI_PERDIR setting, so one line there runs an attacker’s file before every request (PHP manual). Sucuri documented this exact .user.ini SEO spam technique on February 17, 2017. One caveat: the Wordfence firewall legitimately sets auto_prepend_file to wordfence-waf.php (Wordfence help), so check what the directive points to before you remove it.

How do I prepare before hunting for a backdoor?

Take a full backup of files and database, keep original file timestamps, and do the analysis on a staging copy or a downloaded archive where you can. Read-only commands like find and grep are safe on production, but anything that deletes, replaces, or reinstalls should wait until you know exactly what you’re removing.

Every command in this guide runs over SSH on the web server, from the WordPress root (the folder that holds wp-config.php) unless stated otherwise. Replace /var/www/example.com/public_html with your path. Store evidence outside the web root.

  1. Create an evidence folder outside the web root: mkdir -p ~/evidence.
  2. Export the database and archive the files with timestamps and permissions intact (commands below). This touches nothing on the site.
  3. Record hashes of the archives so you can prove later they weren’t altered.
  4. Add --skip-plugins --skip-themes to WP-CLI commands on a compromised site. WP-CLI loads WordPress, and these global flags stop it from running plugin or theme code, which may include the backdoor.
cd /var/www/example.com/public_html
wp db export ~/evidence/db-2026-11-05.sql --skip-plugins --skip-themes
tar -czpf ~/evidence/files-2026-11-05.tar.gz .
sha256sum ~/evidence/*

How do I check WordPress core and plugin files with WP-CLI?

Run wp core verify-checksums to compare core files against WordPress.org’s published hashes, then wp plugin verify-checksums –all for every plugin hosted on WordPress.org. Any file reported as changed, added, or “should not exist” is a lead. Neither command checks uploads, themes, mu-plugins, or premium plugins, so they are step one, not the whole job.

wp core verify-checksums --include-root --skip-plugins --skip-themes
wp plugin verify-checksums --all --skip-plugins --skip-themes

Per the WP-CLI core verify-checksums docs, --include-root (added in WP-CLI 2.8.0) also warns about non-WordPress items in the root directory. The checksum command source skips everything under wp-content and reports extra files in wp-admin or wp-includes as “File should not exist”. I walk through output and fixes in the full guide to verifying WordPress core files with WP-CLI.

For plugins, the plugin verify-checksums docs list --all, --strict (flags even readme edits), and --exclude. Errors read “Checksum does not match” or “File was added”. Premium and custom plugins produce a warning ending in “skipping”, because WordPress.org has no checksums for them. Write those plugin names down: you’ll diff them by hand later.

How do I find malicious PHP files in wp-content/uploads?

List every executable script inside wp-content/uploads with find. WordPress stores media there, not code, so a PHP, PHTML, or PHAR file in uploads deserves a close look. Then search for hidden dot-files and for PHP opening tags inside files with image or text extensions, which attackers use to slip past filename filters.

# Scripts of any PHP flavor in uploads (.php, .php5, .php.suspected, .phtml, .phar)
find wp-content/uploads -type f \( -iname '*.php*' -o -iname '*.phtml' -o -iname '*.pht' -o -iname '*.phar' \) -ls

# Hidden PHP files anywhere in the install
find . -type f -name '.*.php' -ls

# PHP code hiding in non-PHP files in uploads
grep -rl --exclude='*.php' '<?php' wp-content/uploads

Open each hit with less rather than running it. An empty placeholder file you can trace to a plugin is benign. A file that reads request input, decodes strings, or includes another file is not. Next, list must-use plugins and drop-ins, since neither shows up in the usual Plugins screen:

ls -la wp-content/mu-plugins/ wp-content/*.php
wp plugin list --status=must-use --skip-plugins --skip-themes
wp plugin list --status=dropin --skip-plugins --skip-themes

How do I find recently modified files in WordPress?

Use find with -mtime or -ctime to list PHP files changed in the last few days, or -newer against a reference file dated just before the suspected break-in. Attackers often fake modification times with touch, so check ctime as well: it records the last inode change, and an ordinary user can’t set it back.

# PHP files modified (mtime) or changed (ctime) in the last 7 days
find . -type f -name '*.php' -mtime -7 -ls
find . -type f -name '*.php' -ctime -7 -ls

# Everything changed since a date just before the suspected hack (GNU touch)
touch -d '2026-10-20 00:00' /tmp/ref-before-hack
find . -type f -newer /tmp/ref-before-hack -ls

# 50 most recently changed PHP files, newest first (GNU find)
find . -type f -name '*.php' -printf '%C+ %p\n' | sort -r | head -50

Plugin and core updates show up here too, so match each cluster against your update history. What stands out is a single file changed at 3 a.m. inside a plugin you haven’t updated in months, or a handful of unrelated files sharing the same timestamp. Once you find one bad file, every file with a matching ctime is a suspect.

Which code patterns should I grep for?

Grep PHP files for code that executes strings or shell commands fed by request data: eval over base64_decode, gzinflate, or str_rot13; assert or system-family calls taking $_POST, $_GET, $_REQUEST, or $_COOKIE; and preg_replace with the /e modifier. Treat every hit as a lead to read, not a verdict, because legitimate code trips some of these.

# Decode-and-execute chains
grep -rnE --include='*.php' 'eval\s*\(\s*(base64_decode|gzinflate|gzuncompress|str_rot13)' .

# Request data passed straight into execution functions
grep -rnE --include='*.php' '(system|exec|shell_exec|passthru|popen|proc_open|assert)\s*\(\s*\$_(GET|POST|REQUEST|COOKIE)' .

# preg_replace with the /e modifier
grep -rnP --include='*.php' "preg_replace\s*\(\s*['\"]/[^/]*/[a-zA-Z]*e[a-zA-Z]*['\"]" .

# Files with extremely long lines (packed payloads)
grep -rlE --include='*.php' '.{3000,}' wp-content
PatternWhy attackers use itCommon false positives
eval(base64_decode(...))Hides the real payload from casual reading and simple scannersSecurity plugins’ signature files, some commercial license checkers and encoded premium code
gzinflate / str_rot13 chainsLayered obfuscation; Sucuri’s 2025 mu-plugins loader used ROT13 for its URLRare in legitimate plugin code
system, exec, passthru taking $_POSTThe core of a command webshellAlmost none in WordPress plugins
assert($_...)Before PHP 8.0, assert() evaluated string arguments as codeTest suites bundled in vendor folders
preg_replace with /eExecuted the replacement as PHP; removed in PHP 7.0, so on a modern site its presence alone is oddVery old, unmaintained plugins
Lines over 3,000 charactersPacked or encoded payloadsMinified libraries and WordPress’s .l10n.php translation files

The most productive grep comes after your first find. Take a unique string from the confirmed backdoor (a variable name, a domain, a function name) and search the whole install and the database export for it. Backdoors are rarely planted alone.

How do I compare themes and plugins against fresh copies?

Download the exact same version of each theme and plugin from its official source, unpack it outside the web root, and run diff -r against the installed folder. Anything added or changed that isn’t your own documented customization is suspect. This is the only reliable check for themes and for premium plugins that WP-CLI skips.

  1. List installed versions: wp theme list --fields=name,version,status --skip-plugins --skip-themes.
  2. Download the matching release into ~/clean. For WordPress.org themes and plugins the URL pattern is https://downloads.wordpress.org/theme/<slug>.<version>.zip or /plugin/<slug>.<version>.zip. Premium code comes from the vendor’s account area, never from a “free download” site.
  3. Unzip and diff. -q lists only the files that differ or exist on one side.
  4. Compare the plugin folders on disk with what WordPress reports, to catch folders hidden from the admin list.
mkdir -p ~/clean && cd ~/clean
curl -LO https://downloads.wordpress.org/theme/twentytwentyfive.1.3.zip
unzip -q twentytwentyfive.1.3.zip
diff -rq ~/clean/twentytwentyfive /var/www/example.com/public_html/wp-content/themes/twentytwentyfive

# Back in the WordPress root: folders on disk vs. plugins WordPress knows about
cd /var/www/example.com/public_html
ls wp-content/plugins
wp plugin list --field=name --skip-plugins --skip-themes

Do file ownership and permissions reveal a backdoor?

Often, yes. On a well-configured server, code is owned by a deploy or account user and the web server can’t write to it. A PHP file owned by the web server user (www-data, apache, or nginx) inside plugins or themes, or any world-writable file, shows where something wrote code at runtime instead of through a normal deployment.

# PHP owned by the web server user in code folders (adjust www-data for your server)
find wp-content/plugins wp-content/themes wp-content/mu-plugins -name '*.php' -user www-data -ls

# World-writable files anywhere in the install
find . -type f -perm -o+w -ls

This check loses its value on shared hosting where PHP runs as your account user, because every file has the same owner. In that case rely on timestamps and diffs. If the results show loose permissions across the board, fix them after cleanup using the values in our WordPress file permissions guide.

How do I find backdoor activity in access logs?

Search your web server access logs for POST requests to PHP files that aren’t normal WordPress endpoints. Webshells are usually driven by POST, so once you filter out wp-login.php, admin-ajax.php, wp-cron.php, xmlrpc.php, wp-comments-post.php, wp-admin, and the REST API, a request to a PHP file in uploads or an unknown root file stands out quickly.

Common log paths are /var/log/nginx/access.log and /var/log/apache2/access.log; on managed hosts, download raw access logs from the control panel. The awk field assumes the standard combined log format.

# Rank PHP files receiving POSTs, minus normal WordPress endpoints
grep '"POST ' /var/log/nginx/access.log \
  | grep -vE 'wp-login\.php|admin-ajax\.php|wp-cron\.php|xmlrpc\.php|wp-comments-post\.php|/wp-admin/|/wp-json/' \
  | awk '{print $7}' | sort | uniq -c | sort -rn | head -40

# Any request at all for PHP inside uploads or cache folders
grep -E 'wp-content/(uploads|cache)/[^" ]*\.php' /var/log/nginx/access.log

# Full history for a suspicious file, including rotated logs
zgrep 'wp-index.php' /var/log/nginx/access.log*

The earliest request to a backdoor file is the most valuable line you’ll find. Its timestamp and IP lead you to the requests just before it, which usually show the real entry point: a vulnerable plugin endpoint, a brute-forced login, or a stolen account.

What should I do when I find a backdoor?

Don’t delete it on sight. Copy it to your evidence folder, record its path, hash, and timestamps, and search for siblings with the same timestamp or strings. Then replace infected files from clean sources, rotate every credential, and trace the entry point. Skip any of those steps and the attacker can simply walk back in.

  1. Preserve evidence. cp -p path/to/file.php ~/evidence/, then stat and sha256sum the original. -p keeps timestamps.
  2. Find siblings. List files changed in the same window, for example find . -type f -newermt '2026-10-21 03:10' ! -newermt '2026-10-21 03:20' -ls, and grep for strings unique to the backdoor.
  3. Check users and the database. Run wp user list --role=administrator --fields=ID,user_login,user_registered --skip-plugins --skip-themes, and grep your database export for the same strings, since payloads can live in options rows like _hdra_core.
  4. Remove and replace, on staging first. Delete files you’ve confirmed don’t belong. Replace core with wp core download --skip-content --force --version=<your version>, reinstall WordPress.org plugins with wp plugin install <slug> --force --version=<version>, and reupload themes and premium plugins from vendor zips. Back up first: --force overwrites files.
  5. Rotate credentials. Run wp config shuffle-salts to invalidate every login cookie, reset all administrator passwords, change the database password in both the host panel and wp-config.php, and change SFTP, SSH, hosting panel, and API keys.
  6. Close the entry point. Match the earliest log hits against vulnerable plugin and theme versions in the WPScan or Patchstack vulnerability databases, then update or remove the vulnerable component.
  7. Rescan. Repeat the checksum, find, and grep checks after 24 hours and again after a week. A file that reappears means a persistence mechanism is still running somewhere.

Free scanners help at this stage, within their limits. The Wordfence plugin page says its free scanner compares core files, themes, and plugins with the WordPress.org repository and checks for known malware signatures, with free signature updates delayed 30 days. Sucuri SiteCheck is a remote scanner that sees only what the browser sees, so it can’t detect a webshell sitting quietly on the server. For a comparison of tools, see our roundup of WordPress malware removal and scanner plugins.

How do I stop backdoors from coming back?

Close the paths attackers use to plant and run files: block PHP execution in uploads, disable the built-in file editor with DISALLOW_FILE_EDIT, delete unused and nulled plugins, keep everything patched, and monitor file integrity so a new PHP file triggers an alert within hours instead of being found months later.

  • Block PHP in uploads. Even if an attacker drops a webshell into uploads, the server refuses to run it. Server-specific rules are in our guide to blocking PHP execution in WordPress uploads.
  • Disable file editing. Add define( 'DISALLOW_FILE_EDIT', true ); to wp-config.php, as Sucuri recommends in its July 2025 write-up, so a stolen admin login can’t edit theme or plugin PHP from the dashboard.
  • Keep a clean baseline. Save the output of find . -type f -name '*.php' -exec sha256sum {} + after cleanup and compare it weekly, or use your security plugin’s file-change alerts.
  • Trim the attack surface. Remove inactive plugins and themes, and never install nulled premium code.

Frequently asked questions about WordPress backdoors

Can a backdoor survive reinstalling WordPress?

Yes. Reinstalling core replaces wp-admin, wp-includes, and the root core files, but it doesn’t touch wp-content (uploads, plugins, themes, mu-plugins, drop-ins), wp-config.php, .htaccess, .user.ini, or the database. Those are exactly where most backdoors live.

Does wp core verify-checksums detect backdoors in plugins?

No. The core command skips everything under wp-content. Use wp plugin verify-checksums –all for WordPress.org plugins, and diff themes and premium plugins against fresh vendor copies.

Is every PHP file in wp-content/uploads malicious?

Not every one, but WordPress core doesn’t keep code in uploads, so each PHP file there needs an explanation. An empty placeholder you can trace to a plugin is fine. A file that reads request data, decodes strings, or includes other files is not.

What does a webshell look like?

Usually a small PHP file with a forgettable name that takes input from $_POST, $_REQUEST, or a cookie and passes it to eval, assert, or a shell function, often behind base64 or gzinflate encoding. Many print nothing at all when you load them in a browser.

Can a WordPress backdoor scanner find every backdoor?

No. Scanners match known signatures and compare files against repository copies, so a new or custom-obfuscated backdoor, or one inside a premium plugin with no reference copy, can slip through. Use a scanner alongside the manual checks in this guide.

← Previous Post
Next Post →