As a WordPress Developer, I often preach about security. However, I recently encountered a real-world scenario with a client’s website that serves as a powerful reminder for everyone in the digital space. It was a classic, insidious attack, and a testament to why proactive security is non-negotiable.
The Attack: Sneaky & Sophisticated My client, based in India, noticed something alarming: when searching for their legitimate English-language website on Google, the search results showed a title and description in Indonesian, promoting lottery content. 😱 Even more frustrating, the live site appeared perfectly normal to them on desktop – a clever tactic by the attackers.
Here’s how they pulled it off:
- Cloaking: The malicious code was designed to show spammy Indonesian content only to Google’s crawlers and mobile users, while displaying the normal site to desktop visitors. This is why it went unnoticed for a while.
- Google Search Console Hijack: The attackers even added themselves as a verified owner in Search Console to push their spammy content and monitor their illicit gains.
- Malicious index.php and wp-config.php Injections: They injected code that was pulling content from a readme.html file (or a ‘ghost file’ disguised as one) and even compromised sensitive files like wp-config.php, exposing critical database credentials.
- Fake Rich Snippets: They injected schema markup, making Google believe their spam was legitimate “product” content, trying to generate rich snippets in search results.
- AMP Cache Abuse: They leveraged Google’s AMP cache to make their mobile redirects seem more authentic.
The Resolution: A Methodical Cleanup This wasn’t a quick fix. It required a deep dive:
- Immediate Containment: Site offline, passwords changed (hosting, FTP, WP admin, database – ALL of them!), and notifying the hosting provider.
- Unmasking the Attacker’s Tracks: Tracing IPs (which led to an Azure cloud server, not a personal computer!), analyzing server logs, and identifying the cloaking code in index.php.
- Reclaiming Google Search Console: Crucially, identifying and removing the attacker’s verification token (an HTML file or DNS record) and then revoking their ownership.
- Deep Code Cleanup: Manually removing malicious code from index.php, regenerating all WordPress security keys and salts in wp-config.php (after changing the database password!), and running comprehensive security scans.
- Google Re-indexing: Submitting new sitemaps, using the “URL Inspection” tool in Search Console for live tests and requesting re-indexing, and validating fixes for the “Product snippets” report.
The Lesson for All: This experience was a powerful reminder:
- Update Everything, Always: The vast majority of hacks stem from outdated plugins or themes.
- Strong, Unique Passwords & 2FA: For every critical account (hosting, WordPress, email).
- Regular Backups: The ability to revert to a clean state is invaluable.
- Google Search Console is Your Early Warning System: Monitor it diligently for security issues, manual actions, or unexpected changes.
- A Web Application Firewall (WAF) is Your First Line of Defense: Services like Cloudflare can block malicious traffic before it ever reaches your server.
- Install a Reputable Security Plugin: After the full resolution, we installed and configured Wordfence. This adds a crucial layer of active defense through malware scanning, login protection, and a live firewall right within WordPress.
Cybersecurity isn’t just an IT department’s job; it’s a constant vigilance for every website owner and developer. If you suspect anything, don’t delay. The longer a hack persists, the more damage it can do to your reputation and SEO.

