Web shell explained

A web shell is a shell-like interface that facilitates remote access to a web server, commonly exploited for cyberattacks.[1] Unlike traditional shells, it is accessed via a web browser, making it a versatile tool for malicious activities.[2] [3]

Web shells can be coded in any programming language supported by a server, with PHP being the most prevalent due to its widespread use in web applications. Other languages, such as Active Server Pages, ASP.NET, Python, Perl, Ruby, and Unix shell scripts, are also employed.[1] [2] [3]

Attackers identify vulnerabilities often in web server application using network monitoring tools, which can be exploited to deploy a web shell.[2]

Once installed, a web shell allows attackers to execute shell commands, perform privilege escalation, and manage files by uploading, deleting, downloading, or executing them on the server.[2]

General usage

Web shells are favored in cyberattacks for their versatility and elusiveness.[4] Common applications include:

Web shells enable hackers to extract data, corrupt systems, and deploy more damaging malware. The threat intensifies when compromised servers are used to infiltrate additional systems. They are also employed in cyber espionage targeting sectors like government, finance, and defense. A notable example is the "China Chopper" web shell.[6]

Delivery of web shells

Web shells are deployed by exploiting vulnerabilities in web applications or weak server configurations, including:[2] [4]

Attackers may also spoof the Content-Type header during file uploads to bypass weak file validation, enabling shell deployment.

Example

The following is a basic PHP web shell that executes a shell command and displays the output:

With a filename of example.php, the command to display the [[Passwd#Password file|/etc/passwd]] file could be:

https://example.com/example.php?x=cat%20%2Fetc%2Fpasswd

This executes the command cat /etc/passwd. Such risks can be mitigated by disabling PHP shell functions to prevent arbitrary command execution.

Prevention and mitigation

Preventing web shell installation requires addressing server vulnerabilities. Key measures include:[2] [3]

Detection

Web shells are challenging to detect due to their modifiability, often evading antivirus software.[2] [9]

Indicators of a web shell include:[2] [3]

For instance, a PNG file with POST parameters or dubious logins between DMZ servers and internal subnets may signal a web shell.[2] [10] [11] [12]

Web shells may include disguised login forms, such as fake error pages.[2] [13] [14] [15]

Attackers can modify the .htaccess file (on Apache HTTP Server) to redirect search engine queries to malware or spam pages, often tailoring content based on user-agent detection. Identifying the shell may require altering the crawler's user-agent, after which it can be easily removed.[2]

Analyzing server logs can pinpoint the web shell's location, as legitimate users typically have diverse user-agents and referers, while attacker access is more uniform.[2]

See also

Notes and References

  1. Web site: How can web shells be used to exploit security tools and servers?. SearchSecurity. 2018-12-21. https://web.archive.org/web/20190328065900/https://searchsecurity.techtarget.com/answer/How-can-web-shells-be-used-to-exploit-security-tools-and-servers. 2019-03-28. live.
  2. Web site: Web Shells – Threat Awareness and Guidance. US Department of Homeland Security. www.us-cert.gov. 9 August 2017. 20 December 2018. https://web.archive.org/web/20190113062745/https://www.us-cert.gov/ncas/alerts/TA15-314A. 13 January 2019. live.
  3. Web site: What is a Web shell?. admin. 3 August 2017. malware.expert. 20 December 2018. https://web.archive.org/web/20190113003907/https://malware.expert/general/what-is-a-web-shell/. 13 January 2019. live.
  4. Web site: Russian Government Cyber Activity Targeting Energy and Other Critical Infrastructure Sectors – US-CERT. www.us-cert.gov. 16 March 2018. 20 December 2018. https://web.archive.org/web/20181220172706/https://www.us-cert.gov/ncas/alerts/TA18-074A. 20 December 2018. live.
  5. Web site: The Definitive Guide about Backdoor Attacks - What are WebShell BackDoors. Makis Mourelatos. WordPress Security Engineer at FixMyWPWC Athens 2016. W. P.. Support. Security. Aficionado. Wannabe. Kitesurfer. 16 October 2017. fixmywp.com. 20 December 2018. https://web.archive.org/web/20190113003929/https://fixmywp.com/security/what-are-web-shell-backdoors.php. 13 January 2019. live.
  6. Hannousse. Abdelhakim. Yahiouche. Salima. 2021-09-01. Handling webshell attacks: A systematic mapping and survey. Computers & Security. 108. 102366. 10.1016/j.cose.2021.102366. 0167-4048. subscription.
  7. Web site: Got WordPress? PHP C99 Webshell Attacks Increasing. 14 April 2016. 21 December 2018. https://web.archive.org/web/20181229190535/https://securityintelligence.com/got-wordpress-php-c99-webshell-attacks-increasing/. 29 December 2018. live.
  8. Web site: Equifax breach was 'entirely preventable' had it used basic security measures, says House report. 10 December 2018. 21 December 2018. https://web.archive.org/web/20181220232937/https://techcrunch.com/2018/12/10/equifax-breach-preventable-house-oversight-report/. 20 December 2018. live.
  9. Web site: Breaking Down the China Chopper Web Shell - Part I. FireEye. 20 December 2018. https://web.archive.org/web/20190113182308/https://www.fireeye.com/blog/threat-research/2013/08/breaking-down-the-china-chopper-web-shell-part-i.html. 13 January 2019. live.
  10. Web site: Intrusion Detection and Prevention Systems. 2018-12-22. https://web.archive.org/web/20190113003930/https://ws680.nist.gov/publication/get_pdf.cfm?pub_id=901146. 2019-01-13. live.
  11. Web site: Five signs an attacker is already in your network. Kasey Cross. 16 June 2016. Network World. 22 December 2018. https://web.archive.org/web/20190113003925/https://www.networkworld.com/article/3085141/network-security/five-signs-an-attacker-is-already-in-your-network.html. 13 January 2019. live.
  12. Web site: Traffic Analysis for Network Security: Two Approaches for Going Beyond Network Flow Data. 15 September 2016. 2018-12-22. https://web.archive.org/web/20161114084537/https://insights.sei.cmu.edu/sei_blog/2016/09/traffic-analysis-for-network-security-two-approaches-for-going-beyond-network-flow-data.html. 2016-11-14. live.
  13. Web site: Hackers Hiding Web Shell Logins in Fake HTTP Error Pages. BleepingComputer. 21 December 2018. https://web.archive.org/web/20180726011308/https://www.bleepingcomputer.com/news/security/hackers-hiding-web-shell-logins-in-fake-http-error-pages/. 26 July 2018. live.
  14. Web site: Hackers Hiding Web Shell Logins in Fake HTTP Error Pages. 24 July 2018. ThreatRavens. 17 February 2019. https://web.archive.org/web/20190113062731/https://threatravens.com/hackers-hiding-web-shell-logins-in-fake-http-error-pages/. 13 January 2019. live.
  15. Web site: Hackers Hiding Web Shell Logins in Fake HTTP Error Pages. cyware.com. 22 December 2018. https://web.archive.org/web/20190113003916/https://cyware.com/news/hackers-hiding-web-shell-logins-in-fake-http-error-pages-f9f1b47e. 13 January 2019. live.