In Part 1 I described finding a fake casino page sitting on top of a website’s real About page, and proving that WordPress itself had not been hacked. In this part I walk through the cleanup itself: what I removed, what I checked, and the mistakes I tried hard not to make.
Many developers will recognise the approach I used to take. For years, my idea of “cleaning a hacked site” was: delete the bad file, change the password, install a security plugin, done. That approach feels productive, but it often leaves the attacker’s way back in wide open. A quick cleanup and a proper cleanup are different jobs.
The principle I now work by
Find everything the attacker added before you remove anything. A cleanup is only finished when you can say, with evidence, “this is everything they changed, and I have reversed all of it.”
So my cleanup had three stages: inventory, remove, verify.
Stage 1: Inventory everything the attacker added
From the file dates in Part 1, I already knew the attack happened within a short window on one morning. That gave me my first tool: search for anything created or modified around that time.
In cPanel’s File Manager you can sort by “Last Modified”. Over SSH, find can do the same:
# Files changed between two dates inside the account
find /home/USER -newermt "2026-10-18 00:00" ! -newermt "2026-10-19 00:00" -type f
Replace USER with the cPanel username. This showed me the fake about/index.html and the Google verification file. Then I went looking in the places attackers use to come back, which I cover further down in this post. There I found two more items: an API token and an FTP account, both created a few minutes after the spam page.
My final inventory was four items, all created within six minutes:
| What the attacker added | Why it was dangerous |
|---|---|
| A cPanel API token with full access and no expiry | Full control of cPanel, even after a password change |
| An extra FTP account with access to the whole home folder | Could upload or change any file |
A fake casino page in a physical about/ folder | Replaced the real About page with spam and phishing links |
| A Google Search Console verification file | Let the attacker claim the site in Google |
Stage 2: Remove, in the right order
The order matters. Remove the attacker’s access first and their content second. If you delete the spam page while their token still works, they can simply put it back.
- Revoke the API token. In cPanel, go to Security → Manage API Tokens and revoke anything you didn’t create.
- Delete the extra FTP account. In Files → FTP Accounts, delete the account but not its files. The account pointed at the home folder, and deleting its files would delete the whole website.
- Move the spam page and the Google file to the cPanel Trash rather than deleting them permanently. I kept them for a few days in case I needed them as evidence.
- Change the cPanel password and turn on two-factor authentication (Security → Two-Factor Authentication).
Warning: When cPanel asks whether to delete an FTP account’s files as well, think carefully. If the account’s directory is the home folder, “delete files” means “delete everything”.
Stage 3: Verify, then verify again
Once everything was removed, I checked the whole site again from scratch, as if I’d never seen it:
- WordPress core:
wp core verify-checksumsmatched all core files. - Plugins:
wp plugin verify-checksums --allmatched the official files for every WordPress.org plugin. - Theme and other plugins: I read the theme and the non-WordPress.org plugins for suspicious code, such as
eval(,base64_decode(, long scrambled strings, or code that runs shell commands. - Uploads: no PHP files, only images.
wp-config.phpand.htaccess: no injected lines.- Database: one administrator (the real owner), no spam posts, no unknown scripts in settings.
- DNS, email and cron jobs: nothing changed by the attacker.
The About page showed the real “About Me” content again.
Why the security scanner said nothing
The server ran a commercial malware scanner, and it had reported nothing at all. That surprised me at first, until I thought about what it actually looks for.
Malware scanners are very good at spotting malicious code: PHP backdoors, scrambled scripts, known web shells. But the spam page here was plain HTML. It contained no code to detect. It was just a web page with bad links on it. And the API token and FTP account aren’t files; they’re settings in cPanel. A file scanner can’t see them.
That was a lesson in itself: a clean scan does not mean a clean account. Scanners are one tool, not the whole investigation.
The part people skip: Google Search Console
Because the attacker had verified the site in Google, removing the verification file isn’t quite enough. Google may still have the spam pages in its index. So the site owner needs to:
- Open Google Search Console for the site.
- Go to Settings → Users and permissions and remove any owner or user they don’t recognise.
- Use the Removals tool to ask Google to drop the spam URLs quickly.
The hidden back doors attackers leave in cPanel
When people clean a hacked site, they usually look for bad files. That makes sense, because files are what you can see. But in this investigation, the most dangerous things the attacker left behind were not files at all. They were two quiet settings inside cPanel, and either one would have let the attacker walk back in even after the password was changed.
In this section, I show you what those back doors were, how I found them, and how to check every account on a server for the same pattern.
Back door 1: A cPanel API token
cPanel lets you create API tokens. These are long secret keys that let a script or app control your cPanel account without a password. They’re genuinely useful: backup tools, deployment scripts and some site-management apps use them.
But look at it from an attacker’s side. A token:
- keeps working after the password is changed
- can be set to never expire
- can have full access to everything in the account
- doesn’t appear in the places most people check
In the site’s account, I found a token called admin-koi, created six minutes after the spam page, with full access and no expiry date.

How to check (cPanel): Security → Manage API Tokens. If you see a token you didn’t create, or one with full access that never expires and that you can’t explain, revoke it.
How to check over SSH, for one account:
uapi --user=USER Tokens list
Back door 2: An FTP account pointed at the whole home folder
The second back door was an extra FTP account, also named admin-koi, whose directory was the whole home folder (/home/USER), not just one subfolder.
Normal FTP sub-accounts are usually limited: a developer might get access only to public_html/wp-content/themes. An account with access to the whole home folder can upload, change or delete anything: the website, email files, configuration, everything.
How to check (cPanel): Files → FTP Accounts. Look at the “Path” column. Any account pointing at the home folder deserves a hard question: who created it, and why?
Over SSH:
uapi --user=USER Ftp list_ftp_with_disk
The attacker’s signature
Here is what made me suspicious that this wasn’t a one-off. The two back doors came as a pair:
- a full-access, never-expiring API token, and
- an FTP account covering the whole home folder,
both created within minutes of each other, often with a generic name like admin.
An attacker who does something methodically on one account usually does it on others. So the next question became: are there other accounts with the same pattern?
Checking a whole server for the same pattern
If you have root access to a server, you can check every account at once. These files are read-only checks. They don’t change anything.
All cPanel API tokens on the server, with their names and creation dates:
python3 - <<'EOF'
import json, glob, os, datetime
for f in sorted(glob.glob('/var/cpanel/authn/api_tokens_v2/cpanel/*.json')):
user = os.path.basename(f)[:-5]
data = json.load(open(f))
for name, t in data.get('tokens', data).items():
created = datetime.datetime.utcfromtimestamp(t.get('create_time') or 0).date()
full = 'FULL' if t.get('has_full_access') else 'limited'
exp = 'expires' if t.get('expires_at') else 'NEVER expires'
print(user, t.get('name', name), created, full, exp)
EOF
FTP sub-accounts whose directory is a whole home folder:
awk -F: 'FILENAME !~ /passwd.vhosts/ && $1 ~ /@/ {
split(FILENAME, p, "/"); u = p[4];
if ($6 == "/home/" u || $6 == "/home/" u "/") print u, $1
}' /etc/proftpd/*
WHM-level tokens (reseller or root) deserve a look too. In WHM: Development → Manage API Tokens, or whmapi1 api_token_list.
What I found on the wider server
When I ran these checks across a whole server, the exact pairing from the site’s account turned up on two more accounts: a full-access token simply named admin, created on the same day on both accounts, plus an admin@ FTP account covering the whole home folder on each.
I also found several other whole-home FTP accounts with names like admin@, support@, developer@ and randomly generated names. Not all of them are malicious. Developers create these too. But every one should be confirmed by the account owner, because an attacker’s account and a forgotten developer account look exactly the same on the list.
Not every token is evil
I want to be fair here, because a security article that cries wolf isn’t helpful. Some tokens are perfectly legitimate:
- DNS cluster tokens: cPanel creates tokens with names like
reverse_trust_…when servers sync DNS with each other. - Billing and backup systems: tools like WHMCS or backup services use tokens to manage accounts.
- Deployment scripts written by developers.
The test isn’t “does a token exist?”. It’s: can someone explain this token, and does it have only the access it needs? A legitimate token should ideally:
- have an expiry date
- be restricted to a known IP address (WHM tokens support this)
- have only the permissions it needs, not full access
Removing them safely
- Confirm with the owner first when it’s not your own account.
- Revoke the token (cPanel → Manage API Tokens → Revoke, or
uapi --user=USER Tokens revoke name=TOKEN_NAME). - Delete the FTP account without deleting its files, especially when it points at the home folder.
- Then change the cPanel password and turn on 2FA.
Lessons from the back doors
- Back doors are often settings, not files. File scanners won’t see them.
- A password change alone doesn’t lock out someone who holds an API token.
- Look for the pair: a full-access, non-expiring token plus a whole-home FTP account, created close together.
- Check the whole server, not just the hacked site. Attackers repeat themselves.
- Give legitimate tokens expiry dates and IP restrictions, so they’re easy to tell apart from an attacker’s.
The question that remained
When I wrote my cleanup report, the site was clean. But one question stayed with me: how did the attacker get the cPanel password in the first place?
There was no sign of guessing. The attacker logged in and went straight to work. I also knew that another site at the same host was showing similar problems. That’s when I decided this needed more than a single-site cleanup. The rest of this series follows that thread.
Cleanup checklist you can reuse
- Write down every suspicious file with its date before deleting anything.
- Search for all files changed around the attack time.
- Check cPanel API tokens, FTP accounts, cron jobs, email forwarders and DNS.
- Remove access first (tokens, FTP, passwords), then content.
- Never delete an FTP account’s files if its directory is the home folder.
- Turn on two-factor authentication.
- Re-verify WordPress core, plugins, uploads, config and database.
- Clean up Google Search Console owners and spam URLs.
- Keep evidence in the Trash for a few days before emptying it.
Next: Part 3, “Reading cPanel login history to find intruders”.
