Web shell

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

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

[edit | edit source]

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

[edit | edit source]

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

[edit | edit source]

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

<?=`$_GET[x]`?>

With a filename of example.php, the command to display the /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

[edit | edit source]

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

Detection

[edit | edit source]

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

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

  • Unusually high web server activity from downloading/uploading[2][9]
  • Files with abnormal timestamps (e.g., newer than last modification)[9]
  • Unknown files on the server
  • Suspicious references (e.g., cmd.exe or eval)
  • Unusual connections in server logs

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

[edit | edit source]

References

[edit | edit source]
  1. ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  2. ^ a b c d e f g h i j k l m n o p q r s t u v w x Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).Public Domain This article incorporates text from this source, which is in the public domain.
  3. ^ a b c d Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  4. ^ a b c Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  5. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  6. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  7. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  8. ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  9. ^ a b c Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  10. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  11. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  12. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  13. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  14. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  15. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).

Lua error in Module:Authority_control at line 153: attempt to index field 'wikibase' (a nil value).