Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared Managed Cloud India
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Best lists Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Security · Guide

How to Fix the Pharma Hack in WordPress

Short answer

To fix the pharma hack in WordPress, take a copy of the infected site, change every password, remove backdoor files and spam entries from the database, replace core, plugin and theme files with clean copies, update everything, and then ask Google to review the site in Search Console. Do not request a review until every spam link is gone.

Key takeaways

  • The pharma hack hides drug links for Viagra and Cialis in pages, search results and redirects that only search engines may see.
  • Sucuri names wp_options entries such as class_generic_support and wp_check_hash as places where pharma spam can load from.
  • A deleted wp-page.php file can return in seconds if the theme file that recreates it is still present.
  • Google says a fix must cover the whole site, because fixing only some pages will not earn a partial return to search results.
  • Google says most review requests take several days or weeks, and you should not send a second request while one is pending.
  • Changing the eight secret keys in wp-config.php logs every user out, including an attacker with a stolen session.

What is the pharma hack in WordPress?

The pharma hack is a form of SEO spam that adds hidden drug links and drug pages to a WordPress site without the owner knowing.

A pharma hack uses your site to promote illegal drug sellers. Sucuri describes pharma hacks as common SEO spam, where an attacker uses a weak site to send drug content to search engines and visitors.

Google defines hacked content as any content placed on a site without permission because of a weakness in the site. Its spam policies list code injection, page injection, content injection and redirects as the main forms.

The injected content usually names drugs such as Viagra and Cialis. Sucuri says the most common signs are embedded links and anchor text on pages, or changed listings in search results. The links may point to drug shops that have no link to your business.

How do you know your site has the pharma hack?

You can spot the pharma hack by searching Google for your domain plus a drug name and by running a remote scan.

Search Google for site:yourdomain.com viagra, then repeat it with cialis and pharmacy. Sucuri gives this check in its pharma hack guide. If drug titles or pages appear under your domain, you likely have this hack.

Use your own domain name in place of yourdomain.com. Do not click the drug results. Note the titles, URLs and date you saw them.

Run a free remote scan at Sucuri SiteCheck. It checks public pages for known malware, spam links and blocklist status. A remote scan only sees public pages, so a clean result does not prove the server files are clean.

Look for other signs too. Search Console may show a Security issues warning, visitors may report redirects from search results, and search traffic may fall.

What do you need before you start cleaning?

You need hosting or file access, database access, a list of your admin users, and a safe copy of the infected site.

Start by writing down what you see, when you first saw it and what changed just before it. Note new plugins, theme changes, new users and any host warnings. This record is the base of your incident report and it saves time if you ask your host for help.

Take a full copy of files and the database exactly as they are now, even though they are infected. Keep it apart from any clean backup.

Check whether you have a clean backup from before the hack started. Our guide to how to back up WordPress explains what a full backup should hold. A clean backup is often the fastest route back, but only if you also close the hole the attacker used.

Make sure you can reach your host panel, SFTP or SSH, and phpMyAdmin or a similar database tool. If you cannot log in to WordPress, ask your host to confirm the account status.

How do you contain the hack and lock out the attacker?

You contain the hack by limiting public access, changing every password and ending every login session.

Ask your host to put the site in maintenance mode or block public traffic while you work. That stops visitors seeing drug spam and stops search engines indexing more spam pages.

Change every password that touches the site, for every user with access. Sucuri lists WordPress admin and editor accounts plus FTP or SSH passwords in its first fix steps. Change the hosting panel and database passwords too, and update the database password in wp-config.php.

Replace the eight secret keys and salts in wp-config.php with a fresh set from the WordPress salt generator. WordPress documents these keys in its wp-config guide. Changing them ends all login cookies, so every user must log in again.

Check Users, then All Users, in WordPress and filter by Administrator. Remove any admin or editor account you did not create.

How do you remove pharma backdoors from your files?

You remove pharma backdoors by searching for known bad files and code, then deleting the backdoor files and fixing the files that load them.

A backdoor is a hidden file or code block that lets an attacker return after you clean the visible spam. Sucuri warns that if you do not remove backdoors, the attacker can reinfect the site with ease.

Search your files for eval(base64_decode and for the string wp_class_support. Sucuri names both as markers in its pharma hack guide. It also names PHP files hidden in the uploads folder, such as any file ending in .php under wp-content/uploads/.

Check these places first:

  • Any PHP file in wp-content/uploads/, where PHP files should not normally sit
  • Extra files in wp-includes/, such as wp-db-class.php or wp-img.php named by Sucuri
  • Plugin folders for extra files with names such as db-akismet.php or wp-akismet.php
  • Your active theme folder, in header.php and in any file you do not know, such as nav.php
  • Must-use plugin files in wp-content/mu-plugins/, which do not show in the normal plugin list

Sucuri describes a case where wp-page.php kept coming back after deletion. The cause was nav.php in the theme folder, loaded by an added line in header.php that ran on every page load and rebuilt wp-page.php in seconds.

Delete the backdoor file and also remove the line that loads it. In the Sucuri case, the spam left only after both nav.php and the added include in header.php were removed. If a file returns after you delete it, look for the file or cron task that rebuilds it.

How do you clean the pharma hack from the database?

You clean the database by deleting the spam rows in wp_options and by searching posts, pages and user tables for drug links.

Sucuri says the pharma hack loads its spam from entries in the wp_options table. Its guide names class_generic_support, widget_generic_support, fwp and wp_check_hash as rows to delete. It also names rows starting with rss_ followed by a long random string.

Use phpMyAdmin and back up the database before you run any delete query. Delete only the named rows after you have checked them. A wrong delete in wp_options can break the site.

Search the database for drug words and for links to sites you do not know. Check wp_posts for hidden posts and pages, wp_postmeta for injected links, and wp_users for accounts you did not create. Search for viagra, cialis, pharmacy and levitra as a first pass.

Check wp_options for changed values too, such as siteurl and home. If a value holds drug text or a strange URL, note it before you change it.

Database placeWhat to look forAction
wp_optionsclass_generic_support, widget_generic_support, fwp, wp_check_hashDelete the row after a backup
wp_optionsRows starting with rss_ plus a long random stringDelete the row after a backup
wp_postsHidden posts, pages or drug text you did not writeDelete the spam post or page
wp_postmetaDrug links or strange URLs in post dataRemove the injected value
wp_usersAdmin accounts you did not createDelete the unknown account

How do you replace core, plugin and theme files safely?

You replace core, plugin and theme files by using fresh copies of the same WordPress version and by reinstalling each plugin and theme from its source.

Download a fresh copy of the same WordPress version your site runs. Replace the wp-admin and wp-includes folders and the root files with the clean copies. Do not overwrite wp-content or wp-config.php in that step, because they hold your content and settings.

Reinstall every plugin and theme from WordPress.org or from the vendor. Delete any plugin or theme you do not use, files included, because a deactivated plugin can still hold a backdoor. Our guide to how to find abandoned WordPress plugins helps you spot plugins with no recent update.

Check custom theme files by hand. Compare functions.php, header.php and footer.php with your clean copy. Remove only the injected code, and note what you removed.

Update WordPress, every plugin and every theme to the latest version after the files are clean. Sucuri puts updating WordPress and all plugins near the top of its fix list, before cleanup starts in some cases. An old plugin is a common way back in.

What if a plugin came from outside WordPress.org?

Remove any plugin or theme from an unknown source, including nulled copies. Our guide are nulled WordPress plugins safe explains why those files carry a high risk. Replace them with a copy from the vendor or with a different plugin that does the same job.

How do you check that the pharma hack is really gone?

You check the fix with a server scan, a remote scan, a search check and a file check, and you repeat them until all four are clean.

Run a full scan with a security plugin such as Wordfence. Its WordPress.org listing says the scanner compares core, theme and plugin files with the WordPress.org versions and reports changes. Wordfence also says new firewall rules and malware signatures reach the free version 30 days after Premium, as of November 2026.

Run a second scan from outside the site with Sucuri SiteCheck and check the blocklist status. A remote scan sees what a visitor sees, so it can catch spam a server scan missed.

Repeat the Google checks from the start. Search site:yourdomain.com viagra and site:yourdomain.com cialis again.

Open Search Console and use URL Inspection on your home page to see the page as Google sees it. Look in the page source for drug words and for links to unknown sites.

Check file dates and the user list once more for files you did not change and for new admin users. Sucuri says to re-run the WordPress update tool, clear cache files and re-scan after cleanup.

CheckTool or placeClean result
Server scanWordfence scan in WordPressNo flagged files or malware
Remote scanSucuri SiteCheckNo malware, spam or blocklist hit
Search checksite:yourdomain.com viagraNo drug pages under your domain
Google viewSearch Console URL InspectionNo drug text in the crawled page
File checkFile dates and user listNo unknown files or admin users

How do you ask Google to remove the warning?

You ask Google by fixing every listed issue, then choosing Request Review in the Security issues report in Search Console.

Open Search Console and open the Security issues report. Google says the report shows a count of issues at the top if any exist, and a green check mark if none exist. Expand each issue to see sample URLs and the date it was first seen.

Fix the issue on every page, not only on the sample URLs. Google says fixing the issue on just some pages will not earn a partial return to search results. If the report lists more than one issue, fix all of them before you ask for a review.

When all issues are fixed on all pages, select Request Review. Google says a good request explains the exact issue, describes the steps you took to fix it, and documents the outcome. Name the plugin or file you updated and the spam you removed.

Most reviews take several days or weeks, and link cases can take longer, according to Google. You get an email when the request is received and another when the review is done.

Do not send a second request while one is pending, because Google says that can slow the next review or mark the site as a repeat offender.

Our guide to how to check if a WordPress site is penalized explains the difference between a security warning and a manual action. A pharma hack can bring both, so check the Manual Actions report too.

How do you stop the pharma hack from coming back?

You stop a return by closing the entry point, updating on a set routine, and adding a firewall and two-factor login.

Find how the attacker got in. Check access logs, plugin update dates and the user list for the change just before the hack. A clean site with the same hole will be hit again.

Update WordPress, plugins and themes as soon as an update is out. Remove plugins and themes you do not use. Turn on automatic updates for plugins you trust, and check the update screen each week.

Turn on two-factor login for every administrator. Use long, unique passwords from a password manager, and change them again after the site is confirmed clean.

Add a firewall and file monitoring. Our guide to how to set up Wordfence firewall walks through the Wordfence firewall screens. A firewall blocks many attacks before they reach WordPress, and file monitoring alerts you when a core or theme file changes.

WordPress hardening guidance in the hardening guide covers file permissions, the file editor and login limits. Turn off the built-in file editor with DISALLOW_FILE_EDIT in wp-config.php if you do not use it.

What mistakes should you avoid?

You should avoid cleaning only the visible spam, restoring an infected backup, and asking Google for a review too soon.

Do not delete drug links and stop there. A backdoor, a database row or a theme include can rebuild the spam in seconds, as the Sucuri wp-page.php case shows. Check files, the database and the theme together.

Do not restore a backup taken after the hack started. That backup holds the same backdoor and spam rows. Use a backup from before the first drug page appeared, and update everything right after the restore.

Do not ask Google for a review before every page is clean. Google says a request sent before the fix is done can slow the next review. Wait until the scans, the search checks and the file check are all clean.

Do not keep the same passwords after cleanup. Change every password again once the site is clean. A password changed during the hack may already be known.

Do not install a new security plugin and assume the site is safe. A scanner finds known bad files, but it cannot close a hole in an old plugin or fix a weak admin password. Update the software, remove unused plugins and turn on two-factor login as well.

Frequently asked questions

How long does it take to fix the pharma hack in WordPress?

A small site can take 2 to 4 hours to scan, clean and check, while a large site with many plugins can take a day or more. Google review time is separate, and Google says most reviews take several days or weeks. Do not count the job as done until the scans and the Google check are both clean.

Can I fix the pharma hack by deleting the drug links only?

No. The visible links are only the output. The hack usually lives in a backdoor file, a theme include or a database row in wp_options. If you leave that part in place, the links can return within seconds or days. Clean the files, the database and the theme, then scan again.

Will Google remove the drug pages from search results on its own?

No. Google will only drop the spam pages after the site is clean and the pages return a 404 or 410 status, or after a successful review. You need to remove the spam, let Google recrawl the site, and request a review in the Security issues report. The spam pages can stay in the index for weeks while that happens.

Should I restore a backup instead of cleaning the files by hand?

A clean backup from before the hack is often faster, but only if you know when the hack started and you close the hole after the restore. A backup taken after the hack started will bring the backdoor back with it. Check the backup date, restore it, update everything, change all passwords and scan again.

Why does the pharma hack keep coming back after I clean it?

It usually comes back because the entry point is still open or a backdoor is still present. Common causes are an old plugin that was never updated, a theme file that rebuilds a spam file, a cron task, an unknown admin user, or passwords that were never changed. Find the entry point, remove every backdoor and update the software.

Do I need a paid security plugin to fix the pharma hack?

No. Free scanners such as Wordfence and Sucuri SiteCheck can find many infections, and you can replace files and clean the database by hand. A paid plan can help with faster signatures or one-click cleanup, but it does not replace updating plugins, removing unknown users and changing passwords.

Sources

  1. How to Clean a WordPress Pharma Hack Sucuri Blog
  2. Cleaning the Wp-Page Pharma Hack in WordPress Sucuri Blog
  3. Spam Policies for Google Web Search Google Search Central
  4. Security issues report Google Search Console Help
  5. Hardening WordPress WordPress Developer Resources
  6. Editing wp-config.php WordPress Developer Resources
  7. WordPress Malware Scanner MalCare

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

WPLegible editors

Researched from the primary sources listed above and checked against our editorial rules. About the site · How we test