Skip to content

Finding Malware and Unknown Files on a Website

Reviewed on 4 December 2026

Bad code on a website often isn't one big file. It can be a few lines slipped into places that already run. That makes it easy to overlook and slow to track down.

Look safely first

Don't open suspect pages in your normal browser. Malware often spreads through browser weaknesses, so Google says to avoid viewing pages on your site that way.1

Use a download tool such as cURL or Wget, which fetch a page's raw text without running it. Google suggests fetching a page both with and without a Google referrer, because some malware only switches on when visitors arrive from Google Search.1

Keep a written list. Note each damaged file's name and location, and how it was changed. You'll need it for the clean-up.1

Start with the examples Google gives you

Search Console, Google's free site tool, shows a sample of affected pages in its Security Issues report. Google warns the list isn't exhaustive, so more may be hiding.1

Also run a site: search to see every page Google has listed for your domain, including ones you didn't add.2

Where code hides

Server settings files. These tell the server how to treat requests, including where to redirect them. On Apache servers they're the .htaccess file and httpd.conf. Hackers can add redirects there that send visitors to an attack site. Check for directives pointing at sites you don't know. There may be more than one hacked file.1

Page files and templates. Injected code might be an iframe, which is a small hidden window that loads another site. It might be a script that pulls in a file from an attack site, or a script that redirects visitors who came from Google.1

Google says helpful words to search for include iframe, script, eval and unescape.1 On Unix-based servers, a search tool called grep can look through every file for them. A hit isn't proof, since many honest scripts use these words. Treat each one as something to read.

Disguised code. Some code is scrambled so it can't be read at a glance. Google lists obfuscated code, written to avoid detection, as a common pattern.1

Error pages. The page shown when something isn't found can be set to load from an attacker's site. Ask for a page that doesn't exist and check what comes back.1

Database records. Attackers may insert code into entries in a database table, so it appears on any page that reads them. Google suggests searching for words like iframe in your database and comparing what you find with the page source. You can update each bad record or restore your last known database backup.1

Comparing against a clean copy

If you have a clean older backup, Google suggests a site diff. That's a comparison, done by hand or by a tool, between the clean copy and the infected one. Files that are new or different deserve a close look.3

Make that comparison on copies. Google tells you to back up the infected site first, and to label the backups as infected.3

When you can't tell

If a file looks odd and you can't say whether it belongs, leave it in your notes and ask your host or a qualified professional. Deleting the wrong file can break the site, and missing the right one lets the hack return.

Once you have your list, the next step is restoring a clean copy of a hacked website.

Where hidden code tends to sitSearch Console example pagesServer settings filesPage files and templatesDatabase records
Places where hidden code can sit.

Where the facts come from

  1. Hacked with malware, web.dev (Google)
  2. How do I know if my site was hacked?, web.dev (Google)
  3. Clean and maintain your site, web.dev (Google)