WordPress Woes: Making Malcure Work When WP CLI Fails

Sometimes a WordPress website is so corrupt, one might assume it’s beyond repair and it may be time to wipe off the slate and start from scratch.

Hold that thought for a minute.

Here’s how to test it out. Type a simple command like this and wp-cli hangs with no output.

wp option get siteurl

Nothing… nada… zilch…

It’s time to start cleaning.

First thing is to clean up WordPress core.

You’ll need access to SSH/bash to follow this guide. If that’s not possible, your next best option is to use FTP or a file manager to delete the wp-admin and wp-includes folders and then re-upload them.

If you’re still with us, let’s prepare a workspace. Assuming you’re in the root of your WordPress installation, execute the following commands to create and enter a directory named cleanup:

mkdir cleanup
cd cleanup

Now, adapt the following command to match your installation needs:

wp core download --force --skip-content --locale=nl_NL --version=6.4.3

Next, we’ll execute what we like to call the “nuke” command. This will remove the existing WordPress core directories and replace them with clean versions. This deletes WordPress core and your site will be dead for a few microseconds. Beware, you’ve been warned!

rm -rvf ../wp-admin && rm -rvf ../wp-includes && cp -rv wp-admin ../ && wp -rv wp-includes ../ && cp -rv wp-content ../ && cp ./* ../

This nuke command will remove WordPress core and reinstate the clean WordPress core files.

Voilà! You’re almost done. This process reinstates clean WordPress core files, setting a strong foundation for further troubleshooting and malware scanning.

Let’s remove the temporary folder that we created.

cd ..
rm -rv cleanup

This article is written by Evelyn Allison. Evelyn has over two decades of experience with the big-tech corporate giants. Starting in 2002 with consumer IT remote support, he transitioned into IT enterprise support and systems provisioning for Windows and Linux servers. Her prowess spans her expertise in network security, security audit and scripting-based-automation. Actively involved in web security since 2017, Evelyn has worked with various technologies to secure the web, leveraging tech like Nginx, modsecurity, reverse-proxies, developing web-application-firewalls, on-the-fly asset optimization using Google’s PageSpeed Module and more. Her expertise is reflected in the top-tier plugins and comprehensive consulting-services she offers in the domain of web-security.