Something tells you there is a page about prescription drugs on a site that has nothing to do with medicine: a Search Console message, a customer who searched for the company name and got a very different headline, or a line in somebody else's report. You open the URL and the page loads. It carries the right logo, the right menu, the right footer. Nobody at the company wrote it.
That page is a doorway: a page published on a site that already has search reputation, aimed at a query the real site would never rank for, usually pushing the visitor to an off-site shop. The subject is pharmaceutical far more often than anything else, because that market pays well for traffic. What follows is the practical part — how to tell whether you are even looking at a victim, and then the three places these pages hide, only one of which is visible from the admin panel.
This article is kept open. The campaign behind these pages is still running and still changing shape, so new hiding places, new checks and corrections to checks that turned out to be too broad get added here as we find them. Last update: November 25, 2026.
🚪 Step 0: is this a hacked site at all?
If you are working through a list of suspicious results rather than a single site you own, start here. A large share of the "pharmacy" results in any search engine are not hacked businesses. They are domains the operator registered and dressed up as a clone of a real company — real trading name, real street address, sometimes a tax number lifted from the business being impersonated. There is no victim on those. The handling is the opposite of a cleanup: they get reported to the registrar and the host, not fixed.
Three signals separate them, and they are only reliable together:
- The homepage. On a compromised business site the homepage is almost always untouched — the attacker wants the site to keep looking normal. Count the drug terms on
/. A victim scores zero or close to it; a storefront scores in the dozens, because the homepage is the shop. - Is there a victim layer? A real business has sections that have nothing to do with the drugs: a catalogue, news, a contact page with a landline, a services menu. A cloned storefront has one subject, and a block of internal links with five or more drug names sitting next to each other.
- History. Ask the Internet Archive whether
/was ever captured before the pharmaceutical content appeared. Years of captures of an ordinary business site mean there was a business there to compromise.
UA='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0 Safari/537.36'
SITE=your-site.tld
# 1. how pharmaceutical is the homepage?
curl -sL -A "$UA" "https://$SITE/" |
grep -oiE '\b(kamagra|viagra|cialis|sildenafil|tadalafil|semaglutide)\b' |
sort | uniq -c | sort -rn
# 3. does the homepage have a past?
curl -s "http://web.archive.org/cdx/search/cdx?url=$SITE&fl=timestamp,statuscode&limit=5"
One warning, because it is the shortcut everybody reaches for: the registration date on its own is not a test. In one batch every single lookalike had been registered in the same year, which makes a date filter look brilliant — until a grey-market shop turns up on a domain registered years earlier, and a genuinely hacked charity turns up on a domain registered last spring. A young domain with a clean homepage and three years of unrelated archive captures is a victim. Use the three signals together.
🔤 Count with word boundaries, or don't count at all
Before any counting, one trap that quietly ruins the whole exercise. A plain substring search for a drug name is catastrophic in languages other than English. In Italian, cialis sits inside specialista, polispecialistico, socialisti and socialismo. On one perfectly ordinary book magazine, the site's own search for that string returned 20 results — 19 of them articles about socialism, and exactly one real doorway. A 95% false positive rate, from a missing pair of word boundaries.
So: grep -oiE '\b(...)\b' on the command line, and in the database:
-- MySQL 8.0.4+ and MariaDB 10.0.5+ (ICU / PCRE): \\b
SELECT ID, post_date, post_status, post_type, post_name
FROM wp_posts
WHERE post_status = 'publish'
AND post_type IN ('post','page')
AND (post_title REGEXP '\\b(kamagra|viagra|cialis|sildenafil|tadalafil)\\b'
OR post_name REGEXP '\\b(kamagra|viagra|cialis|sildenafil|tadalafil)\\b')
ORDER BY post_date DESC;
-- Older MySQL (before 8.0.4) uses the POSIX forms instead:
-- [[:<:]]kamagra[[:>:]]
1️⃣ Injected pages in the database
The common case. New rows appear in the posts table, published, often backdated so they do not surface at the top of a "recent posts" view. They are ordinary content as far as the CMS is concerned, which is good news: they answer to the site's own APIs, and you need no login to ask.
for term in kamagra viagra cialis sildenafil tadalafil; do
echo "== $term"
curl -s "https://$SITE/wp-json/wp/v2/search?search=$term&per_page=20&_fields=url,title"
done
On a non-WordPress site, the site's own search form does the same job. Either way, read the results with the word-boundary caveat above in mind — the endpoint does substring matching and will happily hand you every article about socialism.
Then look at the dates on what you find. If the oldest injected page is eighteen months older than the newest, you are not looking at a single break-in that happened once. Something on that server was still writing new pages last month, and removing the pages without finding the writer buys you a few days. That pattern — pages that come back after a cleanup — is what our reinfection investigation is for.
2️⃣ A real page overwritten in place
This is the one that gets missed. The attacker does not add a page; they take an existing one and replace its content. The URL is old, the slug is a genuine old article, the post count is unchanged, the sitemap is unchanged, and because the URL has been indexed for years it ranks better than anything freshly injected would. Nothing in the structure looks wrong, so no structural check finds it.
What does find it is a title comparison against the archive:
title() { curl -sL -A "$UA" "$1" | tr -d '\n' | grep -oiE '<title[^>]*>[^<]*' | head -1 | cut -d'>' -f2-; }
PAGE=/a-page-that-looks-wrong/
title "https://$SITE$PAGE"
curl -s "http://web.archive.org/cdx/search/cdx?url=$SITE$PAGE&fl=timestamp&limit=3"
title "https://web.archive.org/web/20201127000000/https://$SITE$PAGE"
If the archived title is about a book festival and the live title is about buying a drug online, that URL belongs to the site owner and the content does not. The fix is also different from the other two: this page should be restored, not deleted, or a real piece of the site disappears along with the spam.
3️⃣ Static files outside the CMS
The third hiding place is not in the CMS at all. Plain .html files, dropped into a directory with a short meaningless name directly in the document root. They are not in the REST API, they are in no sitemap, and the directory itself usually returns 403, so you cannot browse it. From outside the server there is exactly one thread to pull: these pages link to each other. Follow one hop and a single find becomes the whole set.
PAGE="https://$SITE/xx/known-doorway.html"
curl -sL -A "$UA" "$PAGE" |
grep -oE 'href="[^"]+"' | cut -d'"' -f2 |
sed "s#^/#https://$SITE/#" |
grep -E "^https?://$SITE/" | sort -u | head -20
Then run each of those URLs through the same term counter from Step 0. On the server itself, with shell access, it is faster to go straight at the filesystem — as the site's own user, from the document root:
grep -rliE '\b(kamagra|cialis|sildenafil|tadalafil|semaglutide)\b' . \
--include='*.html' --include='*.htm' --include='*.php'
find . -maxdepth 2 -name '*.html' -newermt '2 years ago' -printf '%T+ %s %p\n' | sort
Read what you find; do not request it. Opening an unknown PHP file over HTTP to "see what it does" is how you run it — some of these files act on the request rather than merely answering it. Open the file in a pager instead.
🤖 Fetch it twice: once as a browser, once as a crawler
Some kits serve the real site to people and the doorway to search engines, which is the whole point of the exercise — the owner sees a normal site, the index sees drug pages. Others do it the other way round. Either way, a verdict based on one user agent is half a verdict.
GB='Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
for pair in "desktop:$UA" "googlebot:$GB"; do
name=${pair%%:*}; agent=${pair#*:}
curl -sL -A "$agent" "https://$SITE/" -o "home-$name.html"
printf '%-10s %7s bytes %s\n' "$name" "$(wc -c < "home-$name.html")" \
"$(grep -oiE '<title[^>]*>[^<]*' "home-$name.html" | head -1 | cut -d'>' -f2-)"
done
Different sizes and different titles from the same URL mean the content is chosen by who is asking. Note it, and from that point judge the crawler view, because that is the one in the index.
🧹 Once you have the list
- Keep a copy before you remove anything. A targeted dump of the rows you are about to delete and a copy of the files you are about to remove. After the
DELETEruns there is nothing left to look at, and the first question anybody asks afterwards is what exactly was there. - Clean all three places in one pass. Removing the injected posts while a directory of static files keeps serving is not a cleanup, it is a partial one that reads as a cleanup in your notes.
- Work from the indexed set, not only from what you found. Search the index for the site plus drug terms and re-check every URL it returns, including the ones that already answer 404 — a page that is gone from disk can still be a live listing with your name on it.
- Answer 410 rather than 404 for removed doorways where the platform lets you, then request removal of the URLs.
- Run every check again the next day. If the writer is still on the server, that is when it shows.
If the checks above turn up any of these signs on a site you are responsible for and you would rather hand the removal to someone who does it every day, that is exactly what our malware removal service covers — the pages, whatever is writing them, and a written report of what was found. If you need the timeline and the indicators rather than a cleanup, the incident investigation is the one to look at.
📌 Shapes worth searching for
- Published posts or pages whose slug contains a drug name — in the site's own language, not just English
- A directory in the document root with a short, meaningless name holding nothing but
.htmlfiles - URLs that return 200 but appear in no sitemap the site publishes
- Pages whose archived title has nothing in common with the live one
- A page whose title ends with the site's own brand name while its subject has nothing to do with it
- Any page the search index knows about and the CMS does not
💡 Takeaways
- A clean homepage is a victim's signature. A homepage that is itself the shop is somebody's business model.
- Registration dates are a hint, never a verdict. Homepage, victim layer and history, together.
- Count with word boundaries. Without them, a search for drug names on non-English content is mostly noise.
- The CMS only knows about one of the three hiding places. The sitemap is not an inventory of what the server serves.
- When a doorway is found, follow its own internal links one hop before concluding there is only one.
❓ FAQ
The page returns 404 now. Is it over?
Not necessarily. A 404 says that one URL no longer resolves; it says nothing about whether the mechanism that created it is still on the server, and nothing about the other two hiding places. The URL also stays in the search index for a while after the page is gone. Re-run the checks a day later, and check all three places rather than the one you were told about.
Why don't these pages show up in my sitemap?
A sitemap is generated from what the CMS knows. Static files dropped next to the CMS were never in the database, so no plugin will ever list them, and injected posts are sometimes explicitly excluded from the sitemap by the same code that created them. Treat the sitemap as a list of pages the site means to publish, not as a list of pages the server will serve.
Can I just delete the posts from the admin panel?
For the injected ones, yes — after you have kept a copy. An overwritten page should be restored rather than deleted, or you lose a real page along with the spam. Static files outside the CMS do not appear in the admin panel at all. And in every case, deleting the output does not stop whatever produced it.
Is a domain registered this year automatically fake?
No. New businesses exist, and get hacked. The registration date is useful only next to the other two signals: whether the homepage is clean, and whether there is a site underneath the drug pages that belongs to somebody. A recent domain with a clean homepage and an ordinary business behind it is a victim like any other.