What is YARA and how can it be leveraged by Tanium (Updated)
YARA is an open source, multi-platform tool commonly used to assist malware researchers and threat hunters in the identification of malware families or compromised systems. Traditional IOCs search for the presence of file hashes, or IP / Domain information, which is static and can often change. YARA on the other hand has the ability to search through many types of data sources including files, portable executables (PE) files, and even volatile memory. YARA can be leveraged to search for strings, hex values, and even regular expression matches against system data. This functionality provides a lot of power for threat hunters.
Tanium Threat Response includes YARA support, making it is possible to find signs of malware or other threats within the network.
As an example, a YARA rule can be created to look for the presence of web shells on an internet facing server. Malicious web shells often utilize Base64 encoding/decoding for obfuscation, and on windows systems, a command shell is typically spawned. Knowing these types of behaviors, it’s possible to create YARA rules to identify this activity. YARA rules can get complicated quickly, so I will focus on some basic string searches. Below is a very generic YARA rule:
rule web_shell_example { strings: $string1 = "eval(base64_decode(" $string2 = "cmd.exe /c" Conditions: $string1 or $string2 }
This rule will scan files identifying any string that is evaluating base64 decoding, or any string that references a Windows command shell. Based on the condition set in the rule, if either of these two strings are present, the rule will trigger. There are several more conditions that are available, including file size, offset location or combinations of strings. There are plenty of available resources to assist in learning to write YARA rules, as well as intelligence providers that publish open source rules.
More complex rules evaluated across very large computer groups, or the entirety of your enterprise, can negatively impact system resources. Tanium provides several options to reduce the scope and impact of these searches. Similar to IOC searching in Tanium, it’s possible to throttle YARA searches by CPU and IO utilization. Best practice is to create a test computer group to gauge resource impact and to target only specific files or folders that would be commonly be used.
For this example, by going to the “Search Scope” within Detect-Management-Intel, it’s possible to specify if this rule should search against Memory, Live files (executable and library files within running processes), or a set of Paths. In this case, since a web shell would only be effective within web directories, we can limit our search to locations such as c:\inetpub\wwwroot, or other locations hosting web services. Remember to test these rules on systems before deploying to the enterprise.
Additional documentation on YARA can be found at Welcome to YARA’s documentation! (yara.readthedocs.io).