The pharma hack is one of the sneakiest WordPress infections because the site looks completely normal to its owner. The damage only shows up in Google, where your pages start advertising pharmaceuticals you’ve never heard of. Here’s how it works, how to confirm it, and what a proper clean-up involves.
What is the WordPress pharma hack?
The pharma hack is a type of SEO spam infection that injects pharmaceutical keywords, links or entire pages into a WordPress site, usually shown only to search engines. Attackers use your site’s reputation in Google to promote online pharmacies, while visitors and the site owner see nothing unusual.
It’s one form of what Google calls “hacked content”. Similar infections push replica goods, gambling or casino terms, or Japanese-language spam pages. The mechanics and the clean-up are much the same.
How do I know if my site has the pharma hack?
Search Google for your domain and look at the titles and descriptions it shows. If your listings mention medication names, “cheap pills”, online pharmacies or similar terms you never wrote, you’re very likely infected.
Run a site: search
Type site:yourdomain.com.au into Google, then try site:yourdomain.com.au viagra or site:yourdomain.com.au pharmacy. Spam pages or altered titles usually show up quickly.
Check Google Search Console
The Security issues report may show “Hacked: content injection”. In the Performance report, look for queries completely unrelated to your business suddenly bringing impressions.
Compare what Google sees with what you see
Because the spam is often “cloaked”, shown only to Google’s crawler, your own browser won’t show it. Search Console’s URL Inspection tool lets you view a page as Google fetched it, which can reveal content that’s hidden from you.
How does the pharma hack hide from site owners?
The malicious code checks who is asking for the page. If it’s a search engine crawler, it serves spam titles, links or pages. If it’s a normal visitor, or a logged-in administrator, it serves your real content.
Some variants also create whole spam pages at URLs you’ve never seen, or edit the titles and descriptions that appear only in search results. That’s why owners often only find out when a customer, an SEO agency or a Google warning points it out.
Where does the pharma hack live in WordPress?
Anywhere the attacker could write code or data: core, theme and plugin files, the uploads folder, the database, or the server’s .htaccess file. It’s frequently spread across several places so that removing one piece doesn’t stop it.
- Theme and plugin files with obfuscated PHP added to legitimate code.
- Fake plugins that don’t appear in the dashboard’s plugin list.
- The database, often in the options table, storing spam content or encoded instructions.
- .htaccess rules that route crawlers or search visitors to spam.
- Backdoors that let the attacker reinstall it later.
How do I remove the pharma hack?
Remove the injecting code from files and the database, close the vulnerability that let it in, and then help Google recrawl the clean site. Deleting the spam pages alone doesn’t work, because the code generates them again.
- Back up the infected site as evidence before changing anything.
- Replace core, plugin and theme files with clean copies from official sources, keeping only genuinely custom code after reviewing it.
- Search the database for spam terms and encoded content in options, posts and widgets.
- Check .htaccess and server config for crawler-specific rules.
- Remove backdoors, especially PHP files in uploads and unfamiliar files in the root.
- Close the entry point by updating or removing vulnerable software and resetting every password.
- Verify with Google by inspecting URLs in Search Console, then request a review if a security issue was reported.
Our guide to removing the “This site may be hacked” warning covers the Google side in more detail.
Will my Google rankings recover after a pharma hack?
Usually, once the spam is gone and Google has recrawled the site. The spam URLs drop out of the index over time as they return “not found”, and your normal pages recover as trust returns. The sooner the clean-up happens, the less there is to recover.
Frequently asked questions
Because the infection is designed to show spam only to search engines, not to visitors or logged-in administrators. Check what Google sees with a site: search or Search Console’s URL Inspection tool.
It can find and remove parts of it, particularly well-known file signatures. Database injections and custom backdoors are often missed, so a manual review is usually needed as well.
It mainly harms your search visibility and reputation, but it shows that an attacker has control of your site. The same access could be used to add more harmful code later.
Most often through an outdated plugin or theme with a known vulnerability, or through stolen login details. Finding the specific entry point is part of a proper clean-up.
Seeing pharmacy spam in your search results? Get your site checked by Dr Web. We remove the injection, close the entry point and help get your listings clean again.
