Check WordPress for Hacked Files with WP-CLI Checksums
The fastest honest check on a suspect WordPress site is to ask WordPress which files differ from the official release. WP-CLI does it in one command.
When you suspect a WordPress site has been tampered with, the quickest honest check does not need a scanner. WP-CLI can compare every core file against the checksums WordPress.org publishes for that exact version, and tell you which ones differ. It will not tell you what is malware, but it narrows a site with thousands of files down to a short list you can read.
Run the core check
Run WP-CLI as the site's own user rather than as root, and point it at the WordPress directory with --path. That keeps file ownership correct and avoids running code from a possibly compromised site with full privileges.
sudo -u USERNAME wp core verify-checksums --path=/home/USERNAME/public_html
A clean site ends with Success: WordPress installation verifies against checksums. A modified file produces a warning naming it, followed by an error that the installation does not verify, for example File doesn't verify against checksum: wp-includes/version.php. Each warning is a file to look at.
Two options solve most surprising results. If the site uses a language other than the default, or your version differs from what you assumed, the WP-CLI documentation says to pass the locale and version shown under Dashboard, then Updates, so the comparison uses the right reference.
sudo -u USERNAME wp core version --path=/home/USERNAME/public_html
sudo -u USERNAME wp core verify-checksums --path=/home/USERNAME/public_html --version=6.8 --locale=en_US
Add --include-root to also be warned about files in the site's root directory that are not part of WordPress. Backdoors are often dropped there, next to wp-config.php, with names chosen to look like they belong.
Run the plugin check
sudo -u USERNAME wp plugin verify-checksums --all --path=/home/USERNAME/public_html
WP-CLI verifies plugin files against the checksums published by WordPress.org. A paid or self-hosted plugin is not distributed there, so check each of those separately against a fresh copy from its vendor. By default small changes such as an edited readme.txt are tolerated. Add --strict if you want those reported as errors too.
Decide what each mismatch means
| What you find | Likely explanation | Next step |
|---|---|---|
| One core file differs, and it has extra code at the start or end | Injected code | Read the file. Treat the site as compromised and look for the backdoor that placed it |
| Many core files differ | A wrong version or locale, or a partial update | Re-run with the right --version and --locale before assuming an attack |
| A plugin file differs from WordPress.org | A local edit, or injected code | Diff it against a clean download of the same version |
| Plugin cannot be verified | It is not distributed through WordPress.org | Compare with a fresh copy from the vendor |
For a mismatch you cannot explain, compare the file with a clean copy of the same version, the way the diff method in cPanel Malware Scan False Positive? How to Confirm It does, and look at its modification time against its neighbours.
Check what checksums do not cover
Core and WordPress.org plugin checks leave out the places attackers like best. These short commands fill the gap.
find /home/USERNAME/public_html/wp-content/uploads -type f -name '*.php'
ls -la /home/USERNAME/public_html/wp-content/mu-plugins
sudo -u USERNAME wp user list --role=administrator --fields=ID,user_login,user_email,user_registered --path=/home/USERNAME/public_html
sudo -u USERNAME wp cron event list --path=/home/USERNAME/public_html
PHP files inside uploads are rarely legitimate, because that folder should only hold media, so treat any you cannot explain as suspicious. The mu-plugins folder loads automatically without appearing in the normal plugin list, so anything unfamiliar there deserves attention. An administrator account you did not create, or a scheduled event with an odd name, are both common ways a compromise keeps its foothold. The full hunt for the entry point is in WordPress Hacked on cPanel? How to Find the Backdoor.
Restore the core files
If core files were altered, replace them from the official release. This leaves wp-content, where your themes, plugins and uploads live, untouched. Be careful with the version: without it the command downloads the latest release, which turns a repair into an unplanned upgrade.
cd /home/USERNAME/public_html
sudo -u USERNAME wp core download --force --skip-content --version=$(sudo -u USERNAME wp core version) --locale=en_US
Doing this per site is fine for one suspect. Across a server with dozens of WordPress installs it is slow and easy to skip. BashSecure does the same kind of core comparison for WordPress, Joomla and Drupal against the official release, reports modified files separately from malware findings, and identifies installed plugins with known published vulnerabilities. It also scans file contents rather than trusting names, so a payload saved with an image extension is still examined, and confirmed threats move into reversible quarantine instead of being deleted.
Confirm the result
wp core verify-checksumsnow ends with the Success line.wp plugin verify-checksums --allshows no unexplained differences, and any plugin it cannot verify has been compared with the vendor's copy.- The
findinuploadsreturns nothing, the administrator list contains only people you know, and the scheduled events list has no surprises. - Passwords for WordPress administrators, the database and the hosting account have been changed, since an attacker who read
wp-config.phphas those.