Web shells remain one of the most potent weapons in an adversary’s arsenal, particularly when targeting Linux servers and containers. These malicious scripts serve as powerful remote access tools with capabilities such as process execution, filesystem access, and tunneling of network connections.
Web shells are frequently used in the exploitation of Linux servers and containers and often are undetected for months or even years, giving adversaries persistent access. Adversaries are using obfuscation techniques and in-memory variants, and modifying legitimate scripts to evade traditional security controls. The stakes are particularly high for organizations running business-critical web applications, where a single successful web shell deployment can lead to data exfiltration or lateral movement, or serve as a launching pad for ransomware attacks.
CrowdStrike has recently released enhancements for the CrowdStrike Falcon® sensor on Linux platforms to provide better visibility of PHP web shells, particularly with features to detect pre-existing and obfuscated web shells. This complements the Falcon sensor’s powerful “On write script file visibility” feature, which has directly led to the detection of 492 web shells in a three-month period by the CrowdStrike Falcon® Adversary OverWatch™ threat hunting team.
On Write Script File Visibility
The “On write script file visibility” feature provides visibility of script files as they are written to the file system. This approach is superior to traditional scanning methods because the Falcon Linux sensor is aware of the context and content of the script that is written, as well as its behavior (activity performed by the script). This is useful for the identification and analysis of malicious scripts in general, but it is particularly useful for web shells. The Falcon platform is aware when web script content is written by frequently exploited processes such as web servers and SQL service processes. This approach leads to greater detection efficacy and identification of even previously unknown web shells.
While investigating an incident, “On write script file visibility” gives security teams a more complete picture of an adversary’s actions. For example, knowing an adversary only used the openly available tunneling web shell Suo5 indicates they gained tunneling capabilities but not process execution to a server.
Enhance PHP Visibility
“Enhance PHP visibility,” the Falcon platform’s visibility enhancement, provides enhanced script control for existing files and events for dynamically executed code. PHP web shells such as Chopper dynamically evaluate code using the eval function, with the web shell client supplying the code to execute. Obfuscated PHP web shells frequently make use of the eval function or variations such as assert and create_function.
<?php
if (isset($_POST['cmd'])) {
eval(base64_decode($_POST['cmd']));
}
?>
Figure 1. A basic web shell using eval and base64_decode
With this feature enabled, use of the PHP eval function now results in the event PhpEvalString, including the script content to be executed. This gives security teams additional hunting opportunities and provides superior visibility when investigating intrusions that use PHP web shells.
{
"#event_simpleName": "PhpEvalString",
"PhpEvalContent": "echo shell_exec(\"whoami\");"
}
Figure 2. Key fields from PhpEvalString event showing the eval content