The instinct on finding a hacked website is to clean it straight away. Resist it. Every file an attacker leaves behind, and every log line they create, tells you how they got in and what else they touched. Delete it first and those answers are gone, and without them you can’t be sure the attacker is gone too.
Fifteen minutes spent saving evidence before cleaning protects those answers. This guide shows how, using only cPanel and, where available, the Terminal.
The golden rule: save it outside the website
Never put evidence inside public_html. Anything in there can be downloaded by anyone on the internet, including the attacker. I create a private folder in my home folder instead:
mkdir -p ~/evidence
chmod 700 ~/evidence
Without the Terminal, use File Manager: go to your home folder (one level above public_html), click + Folder, and name it evidence.
Step 1: Screenshot what you can see
Before touching the server, take screenshots of:
- the hacked page, with the address bar visible
- any warning from Google, your browser or your host
- the dashboard, if something looks wrong there
Note the date and time. If the hack shows only to Google visitors, also search for your site on Google and screenshot the spam results.
Step 2: Save a list of files with their dates
This list is the most useful evidence you will have. It records every file and when it was last changed, before cleaning changes those dates.
find ~/public_html -type f -printf '%TY-%Tm-%Td %TH:%TM:%TS %10s %p\n' | sort > ~/evidence/file-list-$(date +%F).txt
Without the Terminal, sort each important folder by Last Modified in File Manager and take screenshots. My guide on finding recently changed files in File Manager shows exactly how.
Step 3: Copy the website files
Make one compressed copy of the whole website, infected files included:
tar -czf ~/evidence/site-files-$(date +%F).tar.gz -C ~ public_html
This keeps the attacker’s files exactly as they were, with their original dates inside the archive. It may take a few minutes on a big site.
Step 4: Export the database
Spam posts, fake administrators and injected scripts often live in the database, not in files.
With WP-CLI:
cd ~/public_html
wp db export ~/evidence/database-$(date +%F).sql --skip-plugins --skip-themes
Without the Terminal: cPanel → phpMyAdmin, click your site’s database on the left, click Export, keep the Quick method and SQL format, and click Export.
Step 5: Download the access logs
Access logs show every visit to your site, including the attacker’s. Hosts only keep them for a limited time, so save them early.
In cPanel, go to Metrics → Raw Access, then download the log for your domain. On the same page, turn on the option to archive logs in your home folder, and turn off the option that removes the previous month’s archive, so future logs are kept too.
Also look at, and screenshot, the Last Login information shown in cPanel. In the Terminal:
cat ~/.lastlogin
This shows the dates and IP addresses of recent cPanel logins. My series explains why, on some servers, every address here shows as 127.0.0.1, and how I found the real ones.

Step 6: Record what you saved
Write a short note in the evidence folder: what you saw, when you noticed it, and which files you saved. Then record a fingerprint of each file, so you can later prove nothing in your evidence was changed:
sha256sum ~/evidence/* > ~/evidence/CHECKSUMS.txt
Step 7: Take a copy off the server
Evidence that stays only on a hacked account is at risk. Download the evidence folder to your own computer: in File Manager, select it, click Compress, then download the archive.
A full cPanel backup is another option (Files → Backup → Download a Full Account Backup), but it is large and it contains the infection too.
Two warnings
- Never restore this copy over a cleaned site. It contains the malware. It is evidence, not a backup to use.
- Keep the copy private. It contains your database, which may include customer details and password hashes.
Once this is done, you can start cleaning knowing that nothing important will be lost. In Part 2 of my security series, I show how I cleaned a hacked WordPress site step by step while keeping this evidence intact.
