Tools
Log in
English

Learn to codeSecurity check

Suspected PHP web shells

CriticalP01PHP servers (Linux and Windows)

Find PHP backdoor files hidden in your web folder, keep a copy as evidence…

What is the risk

A web shell is a PHP file that lets someone run commands on your server through a URL. Attackers drop it through an upload, PHP or plugin vulnerability and keep coming back.

Common signs: eval wrapped around base64_decode, request values ($_GET, $_POST) passed straight to system or shell_exec, or very long unreadable strings. Normal code sometimes looks like this too, so a person has to open the file and decide.

How to check

Linux

sudo grep -rlE --include='*.php' 'eval\((base64_decode|gzinflate|gzuncompress|str_rot13)' /var/www
sudo grep -rlE --include='*.php' '(system|passthru|shell_exec|exec|assert)\(\$_(GET|POST|REQUEST|COOKIE)' /var/www
sudo find /var/www -name '*.php' -mtime -7 -ls

Change /var/www if your web folder is elsewhere. The last line lists PHP files changed in the last 7 days.

Windows PowerShell (admin)

Get-ChildItem C:\inetpub\wwwroot -Recurse -Include *.php | Select-String -Pattern 'eval\((base64_decode|gzinflate|str_rot13)' -List | Select-Object Path
Get-ChildItem C:\inetpub\wwwroot -Recurse -Include *.php | Where-Object LastWriteTime -gt (Get-Date).AddDays(-7)

Change the path if your web folder is elsewhere.

How to fix

Linux

sudo mkdir -p /root/evidence
sudo cp -p /var/www/html/suspect.php /root/evidence/
sudo grep -F 'suspect.php' /var/log/nginx/access.log /var/log/apache2/access.log /var/log/httpd/access_log
sudo rm /var/www/html/suspect.php

Replace suspect.php with the file you found. Copy it before deleting and check the access logs for who called it and when. Errors for log files you do not have are fine.

Windows PowerShell (admin)

New-Item -ItemType Directory -Force C:\evidence
Copy-Item C:\inetpub\wwwroot\suspect.php C:\evidence
Select-String -Path C:\inetpub\logs\LogFiles\W3SVC1\*.log -Pattern 'suspect.php'
Remove-Item C:\inetpub\wwwroot\suspect.php

Paths are the IIS defaults.

Close the way in: update PHP (P02), block PHP in upload folders (P07), update your CMS and plugins, then change DB, admin and API key passwords. If you found one, other files may be changed too, so reinstalling from a clean copy is safest.

How to prevent it

  • Let a deploy account own the code and give the web server account read access only. Allow writes only in upload and cache folders.
  • Stop PHP from running in upload folders (P07).
  • Keep PHP, your CMS and plugins up to date and remove plugins you do not use.
  • Run this check regularly so new PHP files are found early.

Check again after fixing

Linux

sudo grep -rlE --include='*.php' 'eval\((base64_decode|gzinflate|gzuncompress|str_rot13)' /var/www

No output means clean.

Run the downloaded check again and make sure this item passes.

Related CVEs

CriticalCVE-2026-1096189.8HighCVE-2026-1096198.1

Security check home