Signs your website has a PHP web shell, and how to clean it up

By TurnUpHosting Web Services LLC · · #malware #wordpress #incident-response

A web shell is a script an attacker uploads to a website so they can run commands, browse files or send spam through your server from a browser. Most arrive through an outdated plugin, a vulnerable upload form or stolen FTP/admin credentials.

Signs something is wrong

  • Your host or Google warns about malware or spam.
  • New administrator accounts you didn't create.
  • Pages redirect visitors (often only mobile or search-engine visitors) to other sites.
  • Outbound spam or unusual CPU from PHP processes.
  • PHP files in places that should only hold images, such as wp-content/uploads.

What the code usually looks like

Attackers hide intent with obfuscation, so look for patterns rather than names:

  • eval(base64_decode(...)), eval(gzinflate(...)) or chained decoders.
  • eval, assert, system or shell_exec fed directly from $_GET, $_POST or $_COOKIE.
  • Very long single-line strings of base64 or \x escapes.
  • auto_prepend_file in .htaccess or .user.ini pointing at an innocent-looking file.
  • .htaccess rules that redirect only visitors coming from search engines.

Where they hide

Upload folders, cache directories, theme and plugin folders, files named like core files (wp-tmp.php, class-wp-cache.php), and files with image extensions that are executed through an .htaccess handler.

Cleaning up properly

  1. Contain: take a full backup for evidence, then put the site in maintenance mode or block public access while you work.
  2. Find everything: scan the whole account, not only the file you noticed. Check recently modified files (find . -mtime -14 -name '*.php').
  3. Replace, don't edit: reinstall the CMS core, themes and plugins from official sources rather than trying to clean infected copies.
  4. Remove persistence: unknown admin users, cron jobs, SSH keys, database options with injected scripts, and modified .htaccess files.
  5. Rotate every credential: CMS admins, database, FTP/SFTP, hosting panel and API keys.
  6. Fix the way in: update the vulnerable component, remove unused plugins, and stop PHP from running in upload folders.
  7. Watch for return visits for a few weeks.

How automated scanning helps

A scanner that knows these patterns can check every site on a server continuously, quarantine a malicious file the moment it appears (keeping a copy so a false alarm can be restored), and alert you while the attacker is still getting started.

TurnUpSecurity Shield scans every site's files with built-in web shell and injection signatures (plus ClamAV and YARA when installed), quarantines what it finds, and flags web-server processes that suddenly start shells, downloaders or crypto miners.