Searching the Windows Registry Using Tanium

Windows stores vast amounts of information inside the Registry. The Windows Registry has configuration settings, version information, and in some cases is a persistence mechanism for malware.

Registry terminology can be confusing, which in turn makes asking Tanium questions confusing. This article explains some Registry terminology and gives ideas on how to query the Registry at speed and scale.

Registry Terminology

Here are some useful terms when dealing with the Windows Registry:

Root Key - a logical grouping of Registry data.

 The most common root keys are:

  • HKEY_LOCAL_MACHINE (HKLM) - local machine settings

  • HKEY_CLASSES_ROOT (HKCR) - file extension information

  • HKEY_USERS (HKU) - all user settings. Tanium can use this key to query across multiple user profiles.

  • HKEY_CURRENT_USER (HKCU) - logged-in/current user-based settings (references HKU. Remember Tanium runs as System, so this key will return values set for the System user).

  • HKEY_CURRENT_CONFIG (HKCC) - current computer settings (references HKLM).

  • Key / Sub Key - contains one or more data values or additional keys. Keys are structured in a tree format. A Key can have one or more subkeys. Keys/subkeys are separated by a backslash (\.

  • Value - the smallest container in the Registry. Values are referenced independently from Keys. Inside the value is the actual data being stored.

  • Value Data - this is the actual data that is contained inside of a value. This often contains the information you are looking for (e.g. version number of software or string of text).

Example Registry entry broken down into its components:

HKLM\SOFTWARE\Microsoft\Command Processor, DefaultColor

  • HKLM - Root key

  • \SOFTWARE\Microsoft\Command Processor - keys and subkeys

  • DefaultColor - Value

  • 0 - Value Data

Note:

 In Tanium you can interchangeably use the full root key name (e.g. HKEY_LOCAL_MACHINE) or the abbreviated name (e.g. HKLM). I generally recommend using the abbreviated name in all capital letters to keep requests consistent. 

Let’s look at an example Registry entry using a native Windows GUI for accessing the Registry: regedit.exe.


SearchingWinReg_caa2e1ba-62d0-491c-859b-698f35a680b2.jpg
 In regedit.exe, you can navigate through keys and subkeys much like traditional folders navigating a hard drive. In this example above, we see the key *“*HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor” listed at the bottom of the window.

Inside this key there are multiple key values (e.g. CompletionChar and EnableExtensions). The highlighted value is “DefaultColor”. DefaultColor is just one of the values in this key. The DefaultColor key value has the data “0x00000000” (or 0 for short). Registry values are often entered as hexadecimal values. 

Important:

The most confusing part of the Registry for most people is the distinction between Key Value (container) and Value Data (actual data inside the key value). One way you can remember this distinction is that data is generally what most customers want to retrieve.

Writing a Tanium Question to get Registry Information

 At the time of writing, there are six (6) Registry Sensors in initial content that you could use to ask Registry questions. Below are example questions for each, along with results.

 I. Registry Key Value Names with Data. A very common and useful Sensor used to show data elements inside the Registry. Returns data and values in a supplied Registry key. If the hive selected is HKEY_USERS, Tanium will attempt to output the username associated with the key.

HKEY_CURRENT_USER will only return data for the SYSTEM account which is the user that the Tanium Client runs as.

Example Tanium question: 

Get Registry Key Value Names with Data[HKLM\SOFTWARE\Microsoft\Command Processor] from all machines

Example result:


SearchingWinReg_2226d863-d1cf-4999-8de7-8d8a9d54b537.png

Some notes about this sensor:

  1. User is shown as N/A above because HKEY_USERS was not used.

  2. The value DefaultColor is shown in the Value field.

  3. 0 is shown in the Data field.

  4. Architecture is a column that shows whether the key was created for 64bit or 32bit processing (or both).

II. Registry Key Subkeys. Another common and very useful Sensor. Returns all subkeys of a supplied key. If the hive is HKEY_USERS, it will attempt to output the username associated with the key. HKEY_CURRENT_USER will only return data for the SYSTEM account which the Tanium Client runs as.Example Tanium question: 

Get Registry Key Subkeys[HKLM\SOFTWARE\Microsoft] from all machines

Example result:


SearchingWinReg_5994d574-99b9-4a27-bbfa-a851f17c929a.png

III. Registry Value Data. Requires two parameters. Returns the actual data of a supplied value in a supplied Registry key. Example Tanium question:

Get Registry Value Data[HKLM\SOFTWARE\Microsoft\Command Processor, DefaultColor] from all machines

Example results:


SearchingWinReg_2d8b76cf-80d9-402a-a232-aa340ab9ee69.png

IV. Registry Key Value Names. Returns all values contained in a supplied key. If the hive is HKEY_USERS, it will attempt to output the username associated with the key.

Example Tanium question:

Get Registry Key Value Names[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor] from all machines

Example result:


SearchingWinReg_c5d76c5e-eef1-494b-bd47-03462e860f01.png

The next two Sensors check to see if a Key or a Key Value exist.

 V. Registry Key Exists. This Sensor simply returns True if a key exists and False if not. Example Tanium question:

 Get Registry Key Exists[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor] from all machines

Example results:


SearchingWinReg_07f69fbb-bd2e-498e-8b1e-65c3f0b50fcc.png

VI. Registry Key Value Exists. Requires two parameters. Returns True if the Registry Value exists, False if not. 

Example Tanium question: 

Get Registry Key Value Exists[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor, DefaultColor] from all machines

Example results:


SearchingWinReg_581bfa9e-0e80-4fe4-aa61-8b3a4ed2852d.png

Reminder - when searching the current user hive (HKCU), Tanium defaults to the System user. To search multiple user values, use the users hive (HKU).

Final Thoughts

  • A good practice using these Sensors is to start with one of the “Exists” Sensors and drill down on some of the “True” responses.

  • The most commonly used Sensor is probably Registry Key Value Names with Data. If you are not sure of which Sensor you would like, start with this one first. The second most commonly used Sensor is probably Registry Key Subkeys.

  • As with all things Tanium, if you have questions about using Registry Sensors please reach out to your TAM.