🐚
Security

What is a webshell and how to find one on your server

25.11.2026
← All articles

A webshell is a script an attacker places on your server and uses through a browser. It is usually written in PHP and called like any page, but its job is different: browsing and editing files, running server commands, connecting to the database, sending email or downloading more malware. In effect it gives the attacker a permanent door into your hosting account that works without any password.

How a webshell gets onto a site

A webshell is not the way in but the tool used afterwards. The attacker first exploits a weakness, such as a plugin or form with poor upload validation, a remote code execution flaw in outdated software, a stolen FTP or panel password, or code bundled in a nulled theme, and then leaves a shell to return easily. Removing the shell is therefore not enough; you also need to find the entry point.

What webshells look like and where they hide

Some have a full interface with a file manager and command line; others are a single line that executes data from a POST request, often encoded with base64 or gzinflate. Common hiding places are the uploads folder with image-like names, files named like WordPress core such as wp-tmp.php, image-extension files pulled in with include, and a few lines appended to an existing theme file. Attackers usually leave several shells so one can restore another, which is why a cleanup has to find all of them in a single pass rather than deleting the first one and calling it done.

Example: a children's clothing shop in Fergana

An online shop in Fergana noticed slow product pages and higher CPU use. The logs showed constant POST requests from many IPs to an image-like .php file in wp-content/uploads. Two more shells turned up: a line in the theme's footer.php and a core-looking file in the root. The attack had started through a gallery plugin left unpatched for a year.

Searching files and logs

find wp-content/uploads -type f \( -name "*.php" -o -name "*.phtml" -o -name "*.phar" \)
grep -rl "<?php" wp-content/uploads --include=*.jpg --include=*.png --include=*.gif --include=*.ico
grep -rnE '(eval|assert|system|shell_exec|passthru)[[:space:]]*\([[:space:]]*\$_(POST|GET|REQUEST|COOKIE)' --include=*.php .
find . -name "*.php" -mtime -14 -ls
grep "POST" access.log | awk '{print $7}' | sort | uniq -c | sort -rn | head -20

The first two commands look for PHP files in uploads, where a normal WordPress site has none, and for image files that contain PHP code. The third finds code that passes request data straight into dangerous functions, and the fourth lists recently changed files. No search catches every obfuscation, but these give quick results. Use wp core verify-checksums and wp plugin verify-checksums --all for core and directory plugins. In the log output, expect the login page, admin-ajax.php and forms; an unknown PHP file or an uploads path deserves immediate inspection. On sayt.uz hosting, logs are available in the ISPmanager panel.

Removing it and preventing a return

Keep copies and paths of the shells for analysis, delete all of them at once, check cron jobs, change hosting, FTP, database and admin passwords, and update the vulnerable plugin or theme. Then block PHP execution in uploads. On Apache, put this in wp-content/uploads/.htaccess:

<FilesMatch "\.(php|phtml|php[0-9]|phar)$">
    Require all denied
</FilesMatch>

On Nginx, add a similar rule to the server configuration:

location ~* ^/wp-content/uploads/.*\.(php|phtml|phar)$ {
    deny all;
}

Finally, add define('DISALLOW_FILE_EDIT', true); to wp-config.php to disable the dashboard theme and plugin editor, so a hijacked admin account cannot write PHP through it. If shells keep reappearing, open a ticket from the sayt.uz cabinet.

Related articles

⚛️ RCE vulnerability in Next.js and React: how to check your project 🗝️ Passkeys: How Passwordless Sign-In Actually Works 🛡️ Disabling PHP in the Upload Folder: Apache and Nginx Rules 🗂️ 644 and 755: Correct File Permissions for Websites
🌐 Language
🇺🇿 O⁠'zbek 🇺🇿 Özbek (yangi) 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓