DEV Community

Radosław Fedorczuk
Radosław Fedorczuk

Posted on Fully Autonomous

How to check a WordPress site for malware with free tools, and what each one cannot see

Disclosure first: I make ShieldWave, an outside website scanner, and Ensomedia Security, a free WordPress plugin. Both appear below next to tools from other people. Every tool here has blind spots, and I name them.

Run these steps on a site you own or manage. Replace example.com with your domain and take a backup before you change anything.

1. Ask the outside world first

Four free checks that need no access to the server:

What none of them can see: a backdoor file that prints nothing, code that only runs for logged-in admins, the database, cron jobs. An outside scan reads what the server sends, nothing more.

2. Look at the site the way Google sees it

Spam injections often show only to search engines or to visitors who arrive from Google, so the owner never sees them.

# As Googlebot
curl -s -A "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" https://example.com/ > as-bot.html

# As a visitor coming from Google
curl -s -e "https://www.google.com/" https://example.com/ > as-search.html

# As a direct visitor
curl -s https://example.com/ > as-direct.html

diff as-direct.html as-bot.html | head -50
Enter fullscreen mode Exit fullscreen mode

Then search Google for site:example.com and look for pages in a language you never published, or pharma and casino titles.

3. Compare files with the originals

With WP-CLI on the server:

wp core verify-checksums
wp plugin verify-checksums --all
Enter fullscreen mode Exit fullscreen mode

Both compare your files with the checksums WordPress.org publishes for the installed version. A changed core file is a strong signal, because core files should never change.

Blind spot: premium plugins and custom themes are not on WordPress.org, so there are no public checksums. Compare them with a fresh download from the vendor or with a backup you trust.

4. Find PHP where it does not belong

# Uploads should hold images and documents, not PHP
find wp-content/uploads -type f -name "*.php"

# PHP files changed in the last 7 days
find . -type f -name "*.php" -mtime -7 -printf '%TY-%Tm-%Td %p\n' | sort

# Common obfuscation patterns
grep -rlE "eval\(base64_decode|gzinflate\(base64_decode|str_rot13\(|assert\(\\\$_(POST|GET|REQUEST)" wp-content --include=*.php
Enter fullscreen mode Exit fullscreen mode

Read the results with care. Attackers can reset file dates, so an empty "last 7 days" list proves little. Some legitimate plugins use base64. One hit is a reason to open the file, not proof of infection.

Also check the server config files for a prepended script:

grep -n "auto_prepend_file" .htaccess .user.ini wp-content/.htaccess 2>/dev/null
Enter fullscreen mode Exit fullscreen mode

5. Check accounts, scheduled tasks and the database

wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
wp cron event list
wp db search "<script" --all-tables
wp option get siteurl
wp option get home
Enter fullscreen mode Exit fullscreen mode

An admin you do not recognise, a cron hook no plugin owns, a <script> tag inside options or widgets, or a changed siteurl all need an explanation.

6. Let a plugin repeat this on a schedule

Doing steps 3 to 5 by hand once is useful. Doing them every week is where people stop. Several free plugins automate part of it. Wordfence's free version, for example, also compares files with WordPress.org.

Mine is Ensomedia Security, the WordPress plugin from ShieldWave: https://shieldwave.io/wordpress-plugin?utm_source=devto&utm_medium=community&utm_campaign=launch-2026-11 . It runs the checksum comparison first, keeps a baseline for premium plugins and custom themes, looks for PHP in uploads and for injected scripts in posts and options, and checks what Googlebot and search visitors see. It emails at most once per scan, only for problems that are new or got worse, and it changes nothing until you press a button.

Its limits, in its own documentation: cleanup removes injected code only when the change is unambiguous and you approve it, a cleanup does not prove a hacked site is clean, and no plugin can protect a site from someone who already has admin access.

7. If you find something

  1. Take a copy of the files and the database as evidence before you change anything.
  2. Change every admin password, the database password and the keys and salts in wp-config.php.
  3. Replace core, plugin and theme files with clean copies instead of editing infected ones.
  4. Update everything, remove plugins and themes you do not use, and remove admin accounts you cannot explain.
  5. If Google flagged the site, request a review in Search Console after the cleanup.

If the site holds customer data or takes payments and you are not sure the attacker is gone, pay someone to look. No tool on this list can tell you a site is clean.

If you have seen an infection that none of these steps would catch, I would like to know how it hid.

Top comments (0)