How-Tos

How-To: Find Outdated Plugins and Freshly Dropped PHP Files on a WordPress Site With WP-CLI

Leave a comment

The WP Rocket attacks are a good reason to do a quick health check on any WordPress site you run. These commands are read-only. Run them from the site’s root directory as the user that owns the files, and swap in your own path where you see /path/to/site.

1. Which plugins have updates waiting?

wp plugin list --update=available --fields=name,status,version,update_version

Paid plugins like WP Rocket update through their own license system, so check them by name too:

wp plugin get wp-rocket --field=version

2. PHP files where they don’t belong

find /path/to/site/wp-content/uploads -type f -name "*.php"

The uploads folder should hold images and documents, not PHP. Anything this finds deserves a hard look.

3. PHP changed in the last 10 days

find /path/to/site -type f -name "*.php" -mtime -10 -printf "%TY-%Tm-%Td %TH:%TM  %p\n" | sort

If you didn’t update anything recently, new or changed PHP is a red flag. If you did update, the changed files should match the plugins you updated.

4. Core files still match WordPress.org

wp core verify-checksums

5. Any admins you don’t recognize?

wp user list --role=administrator --fields=ID,user_login,user_registered

If something looks wrong, don’t just update and move on. Updating won’t remove a planted backdoor. Take a backup for evidence, clean up or restore from a known-good backup, and rotate passwords and application passwords.

God Bless, and May the Source Be with You!

References & Further Reading

Subscribe (RSS) Follow How-Tos via RSS

Leave a note

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.