New 24/7 monitoring and daily cloud backups now included in every Shield Pro plan.

Malware

How to remove WordPress malware manually

A hacked WordPress site may redirect visitors, send spam, or show pharma links in Google. Manual cleanup starts with backups, file scans, and database searches. This tutorial covers practical removal before you reintroduce the infection.

Time: 60-120 minutes Level: Advanced

What this problem looks like

Malware hides in uploads as fake images, in mu-plugins, in theme functions.php, and in wp_options as rogue admin users or redirect URLs. Automated scanners help but manual review catches custom backdoors.

Cleanup without closing the entry point leads to reinfection. Update everything, remove unused plugins, and harden wp-config after files are clean.

If you are not comfortable comparing PHP files or reading obfuscated code, stop and hire a professional. Partial cleanup leaves backdoors that reinfect within hours.

Step 1: Backup and enable maintenance mode

Download the full site and database export. Use a maintenance plugin or simple index.html holding page so visitors are not exposed to malicious redirects during cleanup.

Step 2: Find suspicious files in wp-content

Search for PHP inside uploads, unknown files in mu-plugins, and recently modified theme files. Common malware patterns use eval, gzinflate, str_rot13, or long base64 strings.

bash
find wp-content/uploads -name "*.php"
grep -r "eval(" wp-content --include="*.php"
grep -r "base64_decode" wp-content --include="*.php"
Do not delete random core WordPress files. Compare checksums against a fresh download from wordpress.org for wp-admin and wp-includes.

Step 3: Inspect .htaccess for injected redirects

Open root .htaccess and look for unfamiliar RewriteRule lines sending traffic to external domains. Compare with a clean WordPress .htaccess and remove unknown blocks.

Step 4: Clean the database

In phpMyAdmin, search wp_options for spam domains in option_value. Check wp_users for unknown administrator accounts. Search wp_posts for iframe and script injections in post_content.

bash
wp user list --role=administrator
wp option list --search="*spam-domain*"

Step 5: Harden after cleanup

Update WordPress core, themes, and plugins. Remove unused extensions. Rotate salts, passwords, and SFTP keys. Install two-factor authentication and disable XML-RPC if not needed.

When to stop DIY and hire help

Manual malware removal is slow and easy to get wrong on shops with customer data. BugShield cleans hacked WordPress sites from £99.99 with confirmed pricing and reinfection checks.

FAQs

Will reinstalling WordPress remove malware?

Reinstalling core helps wp-admin and wp-includes but ignores infected plugins, themes, uploads, and database rows.

How did attackers get in?

Weak passwords, outdated plugins, nulled themes, and stolen FTP credentials are common. Fix the entry point after cleanup.

Should I use a malware scanner plugin?

Scanners help find known signatures but miss custom backdoors. Combine scans with manual file review.

When is manual cleanup not enough?

When reinfection happens within 24 hours, rootkits exist outside WordPress, or you need Google blacklist removal. Hire professional cleanup.

Rather someone else fixed it?

Request a fix at a confirmed price. Named UK developer, secure Vault, direct chat.

Request a Fix