Using network monitoring tools, an attacker can find vulnerabilities that can potentially allow delivery of a web shell. These vulnerabilities are often present in applications that are run on a web server.[2]
To relay commands inside the network which is inaccessible over the Internet[2]
To use as command and control base, for example as a bot in a botnet system or in way to compromise the security of additional external networks.[2]
Web shells give hackers the ability to steal information, corrupt data, and upload malwares that are more damaging to a system. The issue increasingly escalates when hackers employ compromised servers to infiltrate a system and jeopardize additional machines. Web shells are also a way that malicious individuals target a variety of industries, including government, financial, and defense through cyber espionage. One of the very well known web shells used in this manner is known as “China Chopper.”[6]
Delivery of web shells
Web shells are installed through vulnerabilities in web application or weak server security configuration including the following:[2][4]
An attacker may also modify (spoof) the Content-Type header to be sent by the attacker in a file upload to bypass improper file validation (validation using MIME type sent by the client), which will result in a successful upload of the attacker's shell.
Example
The following is a simple example of a web shell written in PHP that executes and outputs the result of a shell command:
<?=`$_GET[x]`?>
Assuming the filename is example.php, an example that would output the contents of the /etc/passwd file is shown below:
The above request will take the value of the x parameter of the query string, sending the following shell command:
cat/etc/passwd
This could have been prevented if the shell functions of PHP were disabled so that arbitrary shell commands cannot be executed from PHP.
Prevention and mitigation
A web shell is usually installed by taking advantage of vulnerabilities present in the web server's software. That is why removal of these vulnerabilities is important to avoid the potential risk of a compromised web server.
The following are security measures for preventing the installation of a web shell:[2][3]
Regularly update the applications and the host server's operating system to ensure immunity from known bugs
Deploying a demilitarized zone (DMZ) between the web facing servers and the internal networks
Web shells can be easily modified, so it's not easy to detect web shells and antivirus software are often not able to detect web shells.[2][9]
The following are common indicators that a web shell is present on a web server:[2][3]
Abnormal high web server usage (due to heavy downloading and uploading by the attacker);[2][9]
Files with an abnormal timestamp (e.g. newer than the last modification date);[9]
Unknown files in a web server;
Files having dubious references, for example, cmd.exe or eval;
Unknown connections in the logs of web server
For example, a file generating suspicious traffic (e.g. a PNG file requesting with POST parameters).[2][10][11][12] Dubious logins from DMZ servers to internal sub-nets and vice versa.[2]
Using web shells, adversaries can modify the .htaccess file (on servers running the Apache HTTP Server software) on web servers to redirect search engine requests to the web page with malware or spam. Often web shells detect the user-agent and the content presented to the search engine spider is different from that presented to the user's browser. To find a web shell a user-agent change of the crawler bot is usually required. Once the web shell is identified, it can be deleted easily.[2]
Analyzing the web server's log could specify the exact location of the web shell. Legitimate users/visitor usually have different user-agents and referers, on the other hand, a web shell is usually only visited by the attacker, therefore have very few variants of user-agent strings.[2]
^co-organizer, Makis MourelatosWordPress Security Engineer at FixMyWPWC Athens 2016; Support, W. P.; Aficionado, Security; Kitesurfer, Wannabe (16 October 2017). "The Definitive Guide about Backdoor Attacks - What are WebShell BackDoors". fixmywp.com. Archived from the original on 13 January 2019. Retrieved 20 December 2018.{{cite web}}: CS1 maint: numeric names: authors list (link)