How I Cleaned a Hacked WordPress Database in 5 Minutes
dev.to·10h·
Discuss: DEV
Flag this post

Security incidents happen. What matters is how quickly you can respond. Here’s how I cleaned a compromised WordPress database when I discovered malicious JavaScript injected into hundreds of posts.

The Discovery

During a routine site check, I noticed suspicious external script loading on multiple pages. The pattern was consistent:

<script src='https://malicious-cdn[.]example/m.js?n=ns1' type='text/javascript'></script>

This script was appearing in post content across the entire site. Classic injection attack—probably from a compromised admin account or vulnerable plugin.

Note: Domain defanged ([.] instead of .) for security reasons. This was a real attack using a suspicious .ga domain.

The Damage Assessment

First, I needed to know the scope:

Similar Posts

Loading similar posts...