Over time people have had an on-again, off-again interest in Event Tracing for Windows (ETW). ETW, first introduced in Windows 2000, is a lightweight Kernel level tracing facility that was originally intended for debugging, diagnostics and performance. Gradually, however, defenders realized that ETW provided metrics and data content that was not otherwise available without custom development efforts. Even so, aside from a number of big players in the industry, people have been slow to adopt ETW as a data source for detection and research. The two primary problems with ETW are: the complexities involved in event collection, and the volume of data that is generated. The task of looking through a haystack to find the proverbial needle is not necessarily appealing from an engineering perspective (How do you store the data? How do you process the data? Is the data really valuable? What were we looking for again?).

Our latest tool, SilkETW, aims to put actionable ETW data in the hands of researchers, both on the defensive and offensive side of the industry. It attempts to mitigate the aforementioned issues by providing a straightforward interface for data collection, various filtering mechanics, and an output format that can be easily processed. This project was originally implemented by the FireEye Advanced Practices (AP) team to aid in the rapid analysis of novel attacker tradecraft, and to feed that analysis back into the detection engineering process.

As mentioned, SilkETW is not solely a defensive tool. ETW data can be used for diagnostics, it can help in reverse engineering, vulnerability research, detection and evasion. A number of ETW use cases are outlined in the following section.

Background Reading

There are many public posts and projects that can be highlighted for background reading on ETW. I have chosen a few that provide different perspectives on the data and how it can be used.

As a starting point, Bing's Production Profiler system (BPerf) is a good case study. People sometimes wonder if you can implement instrumentation for performance and diagnostics in highly sensitive production services. Microsoft’s use of ETW on Bing’s front end provides an answer to this question. For more details please consult the Microsoft’s USENIX presentation on BPerf.

As we already mentioned, ETW can be used to collect telemetry that augments defensive capabilities. To highlight this, please refer to Countercept’s post on Detecting Malicious Use of .NET – Part 2.

Not all ETW research is related to performance optics or defense research. ETW also has offensive capabilities, and one such example is in CyberPoint’s post on Logging Keystrokes with ETW.

ETW offers a rich environment for performing novel research, allowing users to dig through the internals of the Windows operating system. This is illustrated in a post by Matt Graeber of SpecterOps: Data Source Analysis and Dynamic Windows RE using WPP and TraceLogging.

Finally, from a defense perspective, it should be understood that the .NET threat landscape is continuously evolving. It would be prudent to understand the mechanics of ETW and to evaluate if it can be leveraged to keep up with attacker tradecraft. To illustrate this I want to highlight a most excellent post by Adam Chester on Building, Modifying, and Packing with Azure DevOps. This type of tradecraft should give defenders real pause.

SilkETW

SilkETW provides a simple interface to record trace data. The command line options are shown in Figure 1.



Figure 1: SilkETW command line options

Note that the output format for SilkETW is JSON. JSON is ubiquitous and can easily be analyzed locally using PowerShell, but it also integrates well with third-party infrastructure such as Elasticsearch. All events conform to the same C# structure before being serialized to JSON.