Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Backdoor files (web shells) on your server: find and remove

OPS-149High impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

A web shell (also called a backdoor) is a small script, often PHP, that an attacker places on your web server. Once it is there, they can open it in a browser or send requests to it and get a control panel: browse files, edit code, read your database login, send email or create new admin users.

Web shells are usually uploaded through a weakness: an outdated plugin or theme, a weak or stolen password, an upload form that accepts any file type, or a leaked FTP or SSH key. They are made to hide. Names look normal (wp-cache.php, class-db.php), they sit in folders like uploads or wp-includes, and the code is often scrambled with functions such as eval, base64_decode or gzinflate.

Why it costs you leads or sales

A web shell gives someone else full control of the place your forms, checkout and tracking live. What they do with it varies, and it often changes over time:

What attackers commonly do with a web shell
  • Inject redirects that send ad or search visitors to other sites
  • Add spam pages or hidden links that get you flagged by search engines
  • Skim or rewrite form and checkout submissions
  • Add scripts such as fake popups or miners
  • Create rogue admin users to keep access
  • Send spam from your server, which can land your domain on email blocklists
  • Delete or lock files, or take the site down

The result for you: browser or search warnings, lost rankings, paid traffic wasted on a hijacked page, leads going to the wrong place, and a clean-up bill. Because the shell stays hidden, the damage can run for weeks before you notice.

How one hidden file turns into lost leads
  1. Vulnerable plugin or weak loginAttacker finds a way in
  2. Web shell uploadedHidden script gives remote control
  3. Redirects, spam or form tamperingSite changed without you knowing
  4. Visitors and leadsWarnings, lost rankings, lost enquiries

The web shell is the break: everything after it is under someone else's control.

How to check if your site has it

You will not see a web shell by browsing your site. You need to look at the files. If you have shell (SSH) access, the commands below are a fast first pass. If you only have a host file manager, sort by modified date and look for anything you did not change.

Look for a web shell
  1. Take a full backup first

    Copy the files and database somewhere offline. You want evidence and a way back if cleaning goes wrong. Do not overwrite your last known clean backup.

  2. List recently changed files

    Look for code files changed on dates you did not update anything. Pay attention to the uploads, cache and temp folders, where PHP files should rarely exist.

  3. Search for suspicious functions

    Search for functions often used to hide or run code. Legitimate plugins use some of these too, so check each hit rather than deleting blindly.

  4. Find PHP files where they do not belongWordPress

    On WordPress, PHP files inside wp-content/uploads are a strong warning sign.

  5. Run a server-side malware scan

    Use the scanner from your host or a reputable security plugin or tool. Compare core files against the official versions.

  6. Check logs

    Look in access logs for POST requests to odd files, especially ones in uploads or with random names. Also check for unknown admin users and unfamiliar scheduled tasks (cron jobs).

First-pass searches over SSH (run from your site root)bash
# Code files changed in the last 14 days
find . -type f \( -name '*.php' -o -name '*.phtml' -o -name '*.js' \) -mtime -14 -ls

# PHP files inside WordPress uploads (should normally be none)
find wp-content/uploads -type f -name '*.php'

# Common obfuscation and command-execution functions
grep -rIl --include='*.php' -E 'eval\(|base64_decode\(|gzinflate\(|str_rot13\(|shell_exec\(|passthru\(|assert\(' .

# Verify WordPress core files against official checksums (needs WP-CLI)
wp core verify-checksums

How to fix it

The safest approach is to assume the attacker has more than one way in. Removing one file is not enough. Work through the steps in order.

Remove the web shell and close the hole
  1. Contain the site

    Put the site in maintenance mode or restrict access while you work, so visitors are not exposed to redirects or malware. Ask your host for help; many will isolate the account.

  2. Restore from a known clean backup if you have one

    Pick a backup from before the first sign of the hack. Restore files and database, then update everything before putting the site back online.

  3. Or replace code with fresh copies

    Delete core, plugin and theme folders and reinstall fresh copies from official sources. Keep only your own content (uploads, database) after checking it for stray code files.

  4. Delete the shell and anything planted beside it

    Remove the files you found. Also check for modified .htaccess files, injected code in wp-config.php, functions.php or index.php, and unknown scheduled tasks.

  5. Rotate every credential

    Change passwords for the CMS admin users, hosting panel, FTP/SFTP, SSH, database and email accounts tied to the site. Replace API keys and the WordPress security keys (salts). Delete unknown users.

  6. Patch the entry point

    Update the CMS, plugins and themes, and remove anything abandoned or unused. Work out how the attacker got in from logs; if you do not close that hole, the shell will return.

  7. Harden uploads

    Block script execution in upload folders so an uploaded file cannot run.

  8. Ask for review if you were flagged

    If browsers or Google showed a warning, request a review once the site is clean, using Search Console.

Platform-specific notes
  1. Reinstall core

    With WP-CLI run wp core download --force --skip-content, or reinstall from Dashboard > Updates > Re-install version.

  2. Reinstall plugins and themes

    Delete and reinstall each from the official source. Remove inactive and nulled (pirated) plugins entirely, as they are a common source of backdoors.

  3. Review users

    Go to Users > All Users and delete any administrator you do not recognise. Reset passwords for the rest.

  4. Block PHP in uploads

    Add the rules in the snippet below to wp-content/uploads/.htaccess (Apache) or the equivalent in your server config (Nginx).

Stop PHP running in wp-content/uploads (Apache, put in uploads/.htaccess)htaccess
<FilesMatch "\.(php|phtml|php[0-9]|phar)$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order allow,deny
    Deny from all
  </IfModule>
</FilesMatch>
Stop PHP running in uploads (Nginx, place before your general PHP location)nginx
location ~* ^/wp-content/uploads/.*\.(php|phtml|phar)$ {
    deny all;
}
Cleaning one file vs a proper clean-up

Delete the visible shell only

  • Other backdoors stay in place
  • Stolen passwords still work
  • Vulnerable plugin still installed
  • Site is hacked again within days or weeks

Full clean-up

  • Code replaced from clean sources
  • All passwords and keys rotated
  • Entry point found and patched
  • PHP blocked in upload folders

How to confirm it's fixed

Confirm the clean-up worked
  • A fresh malware scan and the file searches above return nothing unexpected
  • wp-content/uploads (or your upload folder) holds no script files
  • Core file checksums match the official versions
  • No unknown admin, FTP or database users remain
  • Server access logs show no new requests to the removed file names
  • Open the site in a private window, once from a phone and once arriving from a search result, and check there are no redirects or popups
  • Search Console shows no security issues, or your review request was approved
  • Re-scan again after 24 hours and after a week, in case a hidden copy re-creates the shell

How to prevent it happening again

Habits that block most web shell infections
  • Update the CMS, plugins and themes promptly, and delete the ones you do not use
  • Never install nulled or pirated plugins and themes
  • Use unique, long passwords and two-step sign-in for admin, hosting and SFTP
  • Give each person their own account with only the access they need
  • Use SFTP or SSH, not plain FTP
  • Block script execution in upload folders
  • Restrict file editing in the dashboard (on WordPress, set define('DISALLOW_FILE_EDIT', true); in wp-config.php)
  • Keep automatic offsite backups and test restoring one
  • Run a file integrity monitor or server malware scanner that alerts you when files change
  • Put a web application firewall (WAF) in front of the site

How FunnelGuard handles this

This issue is outside what FunnelGuard checks. FunnelGuard is a synthetic monitoring service: a robot visitor runs your real customer journeys from the outside, such as lead forms, checkouts and booking buttons, and checks each step, the tracking hits and whether test leads arrive. It does not read the files on your server, so it cannot find a web shell.

The kind of tool that fits is a server-side malware scanner with file integrity monitoring, often combined with a web application firewall. Your host's security scanner, a reputable security plugin for your CMS, or a dedicated website security service can all play this role. They compare files to known-good versions and alert you when new or changed code appears.

A hack can still break the journeys FunnelGuard does run, for example a form that stops working after tampering. In that case a failed journey check may be one more sign that something is wrong, but it is not a test for backdoors. Use a security tool for that, and use FunnelGuard to watch your funnels once the site is clean. The Free plan covers 1 site and 2 journeys with daily checks and no card, and paid plans have a 3-day free trial.

Questions people ask

What is a web shell?

A web shell is a small script, often PHP, that an attacker uploads to your web server to control it remotely. It lets them browse and edit files, read database logins, add users and run commands. It is usually disguised with a normal-looking name and scrambled code.

How do I find a backdoor on my website?

Back up first, then look for code files changed recently, PHP files in upload folders, and functions like eval, base64_decode and gzinflate. Run a server-side malware scan and compare core files to official checksums. Also check logs for odd POST requests and review your admin users.

Why does my website keep getting hacked after I clean it?

Usually a backdoor was missed, passwords or keys were not changed, or the original vulnerable plugin or theme is still installed. Attackers often leave several backdoors. Replace code from clean sources, rotate every credential and patch the entry point.

How do I remove a web shell from WordPress?

Take a backup, restore a clean version or reinstall WordPress core, plugins and themes from official sources, and delete any PHP files in wp-content/uploads. Then remove unknown admin users, change all passwords and salts, update everything and block PHP execution in uploads.

Can a malware scanner plugin find every web shell?

No. Scanners catch known patterns but can miss custom or heavily hidden shells. Use them as one layer, combine with file integrity checks and checksum verification, and rebuild from clean files if you have strong signs of compromise.

Do I need to reset passwords after finding a web shell?

Yes. Assume the attacker read your config files, so change CMS, hosting, SFTP, SSH, database and related email passwords, and replace API keys and WordPress salts. Delete unknown users too.

Can FunnelGuard detect a web shell on my server?

No. FunnelGuard runs your customer journeys from the outside and does not scan server files. For web shells use a server-side malware scanner or file integrity monitor.

Does Shopify or Wix get web shells?

Not in the classic sense, because the platform controls the server and you cannot upload server scripts. The risks are malicious theme or custom code, unknown apps or staff accounts, and stolen logins, so review those and enable two-step sign-in.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.