Use ChatGPT to remove Malware from a WordPress blog

I had been neglecting this blog for a long time, and in my neglect, the WordPress version got way out of date, SSL certificates expired, and then it got hacked. It was FULL of Malware. By the time I realised, the site was full of spam content and links.

A fresh install of WordPress on the server got rid of the most malicious stuff… but my database was now also full. Every single row in my wp-posts table had malicious scripts inserted.

There are plugins available on WordPress that will scan your site and remove malware for you, but they all cost cash… upwards of $150.

I knew I could write a script that would clear out the malicious content but my php is VERY rusty, and I hated writing regular expressions even way back at Uni.

Enter ChatGPT. ChatGPT gave me a perfect php script, and then turned that script into a WordPress plugin that I could upload to WordPress and activate and run directly. I eyeballed the script – it looked fine, so I installed the plugin and ran it. (I had created a backup of my database just in case of course!) In the blink of an eye, my site was clear of spam.

The prompt was simple:

I need to remove malicious <script> tags from thousands of WordPress posts. Write a wordpress plugin that will iterate over every row in the wp-posts table and remove any inserted <script> tags. Provide instructions to install and run the script.

This could save you a few hundred bucks of expensive Malware removal tools!

Leave a Reply