Журнал событий windows на английском

If you’re using a Windows server and want to know what happened to your machine, Windows logs are an essential resource. Windows logs record various system activities, errors, and other significant events, providing valuable information for troubleshooting, auditing, and ensuring system integrity. Understanding how to access, interpret, and utilise these logs enables efficient, problem solving, enables security measures and ensures the smooth operation of your system.

In this guide, you will learn about Windows event logs, its different categories, how to filter and create Custom Views.

What is a Windows Event Log?

A Windows event log is a file that keeps track of system events and errors, application issues, and security events. Windows Event log can also provide insights into an application’s behavior by tracking its interactions with other processes and services. With the right knowledge of the information stored in these logs, you can easily diagnose and easily resolve issues within your system and applications.

You can access the windows events logs as follows:

Using the Start Menu:

  • Click on the Start button or press the Windows key.
  • Type Event Viewer in the search box and select it from the search results.

Using the Run Dialog:

  • Press Windows + R to open the Run dialog.
  • Type eventvwr and press Enter.

Using the Control Panel:

  • Open the Command Prompt and run as administrator.
  • Type eventvwr and press Enter.

You can see the detailed steps below. Now let’s discuss and understand windows events logs in detail.

Understanding Windows Event Logs categories & Types

There are different Windows logs, each serving a specific purpose in tracking and recording events related to your system, applications, and security. They include:

  • System Events: System events log information is about the core operations of your Windows operating system. System events are essential for maintaining your system’s health and functionality because it records events related to the system’s hardware and software components. Some system events are as follows:
    • Hardware Failures: Logs any issues related to hardware components, such as disc failures or memory errors.
    • Driver Issues: Records events related to the loading, unloading, or malfunctioning of device drivers. This helps in identifying driver-related problems that could affect system stability.
    • System Startups and Shutdowns: Tracks the times when the system starts up or shuts down. This can be useful for understanding system uptime and diagnosing issues related to improper shutdowns or startup failures.
  • Application Events: Data related to software applications running on the system includes application errors, warnings, and informational messages. If you are using a Windows server to run your production-level application, you can use the application errors, warnings, and messages provided here to solve the issue. There are different types of Application events some are as follows:
    • Application Errors: Application errors are events generated by software applications when they encounter issues that prevent them from functioning correctly.
    • Warnings: Logs warnings from applications about potential issues that might not be critical but could lead to problems if not addressed.
    • Informational Messages: Provides general information about application activities, such as successful operations or status updates, helping to understand the normal functioning of applications.
  • Security Events: Security events are logs that capture all security-related activities on your Windows system. They are essential for monitoring, maintaining, and auditing the security of your system. These events help detect unauthorised access attempts, monitor access to sensitive resources, and track changes to system policies. Some security events are as follows:
    • Successful and Failed Login Attempts: Successful and failed login attempts are critical events that are logged by a system to monitor access and ensure security. These logs provide valuable insights into user activity, helping to detect unauthorised access attempts and identify potential security threats.
    • Resource Access: These events log attempts to access protected resources such as files, folders, or system settings. Monitoring these logs ensures that sensitive data is accessed appropriately and helps identify unauthorised access attempts.
    • System Policy Changes: These logs record any changes to system policies, including modifications to user permissions or security settings. This is important for auditing purposes and ensuring compliance with security policies, helping to maintain the integrity and security of the system.
  • Setup Events: Setup events are logs that contain detailed information about the installation and setup processes on your Windows system. These logs are valuable for diagnosing and resolving issues that occur during the installation or configuration of software and system components. Some Setup events are as follows:
    • Installation Processes: Installation processes refer to the series of steps and operations carried out to install software, updates, or system components on a Windows system. It contains log details about software installation, updates, or system components. This helps in diagnosing issues related to incomplete or failed installations.
    • Setup Configurations: Records information about system configurations during the setup process. This can be useful for understanding your system’s initial setup and configuration.
  • Forwarded Events: Forwarded events are logs sent from other computers to a centralised logging server. This is particularly useful in larger environments where centralised log management is needed. They include:
    • Logs from Remote Systems: Collects event logs from multiple systems, allowing for centralised monitoring and management.
    • Centralised Logging Scenarios: Useful for organisations that need to aggregate logs from various systems to a single location for easier analysis and monitoring.

Accessing the Windows Event Viewer

Windows Event Viewer is a Windows application that lets you see your computer’s logs, warnings, and other events. Each application you open generates entries that are recorded in an activity log, which can be viewed from the Event Viewer.

There are several ways to access the Windows Event Viewer. Here are some of them:

  1. Using the Start Menu:

    • Click on the Start button or press the Windows key.
    • Type Event Viewer in the search box.
    Using start menu to open Event viewer

    Using start menu to open Event viewer

    — Select Event Viewer from the search results which will popup something like this.

    Event Viewer main page

    Event Viewer main page

    2. Using the Run Dialog: — Press Windows + R to open the Run dialog. — Type eventvwr and press Enter.

    Windows Run App to open Event Viewer

    Windows Run App to open Event Viewer

    Windows Event viewer landing page

    Windows Event viewer landing page

    3. Using Control Panel: — Open the Command Prompt and run as administrator

    Open CMD as Administrator from start menu

    Open CMD as Administrator from start menu

    — Once open, type eventvwr and press enter, and you will be redirected to Event Viewer page.

    CMD terminal

    CMD terminal

Windows Log Location

Windows event logs are stored in files located in the C:\\Windows\\System32\\winevt\\Logs directory. Each log file corresponds to a specific log category, such as System, Application, or Security. It may differ depending on which version of Windows you are using.

The main event log files are:

  1. Application.evtx: Logs events from applications and programs.
  2. Security.evtx: Logs security events like successful or failed logins.
  3. System.evtx: Logs events related to Windows system components and drivers
Windows Event Viewer logs

Windows Event Viewer logs

You can find many other log files which could be related to system operations & other processes that are happening inside the Windows System. Windows 11uses the .evtx format rather than using the classic EVT format.

Understanding Event Viewer Entries

Event Viewer entries provide detailed information about each logged event. It is like a log book for your Windows system. They record important happenings within the system, including applications, systems, security, failed events, etc. Understanding these entries is key to effective log management.

The key components of an Event Viewer entry are:

  1. Date and Time: When the event occurred.
  2. Source: The application or system component that generated the event.
  3. Event ID: A unique identifier for the event type.
  4. Level: The severity of the event (Information, Warning, Error, Critical).
  5. User: The user account under which the event occurred.
  6. Computer: The name of the computer where the event was logged.
  7. Description: Detailed information about the event.

Each event in the Event Viewer has a severity level, indicating the importance and type of the event:

  • Information (Green Light): These events resemble a green traffic light, signifying smooth sailing. They indicate successful operations or occurrences within your system.
  • Warning (Yellow Light): Treat these entries with caution, like a yellow traffic light. They signal potential issues that warrant attention but might not cause immediate problems.
  • Error (Orange Light): Think of error entries as an orange traffic light; proceed with care. They denote significant problems that could affect system functionality. Imagine an error message indicating a driver failure.
  • Critical (Red Light): Critical entries are akin to a red traffic light; stop and address the situation immediately. They represent severe errors that have caused a major failure. A critical event might report a complete system shutdown or a critical service crashing.
Severity levels for events

Severity levels for events

System Event logs page

System Event logs page

Filtering and Custom Views

Event Viewer allows you to filter events using a variety of parameters, including date, event level, source, and more. Consider the following scenario: your system exhibits weird behaviour, but the Event Viewer is overflowing with hundreds, if not thousands, of entries. Filtering steps and generating custom views can significantly reduce the workload. You may also construct custom views to focus on specific kinds of events:

  1. In the Event Viewer, you’ll see Administrative Events, to create special logs right-click on «Custom Views» and select «Create Custom View.»
Opening Administrative events

Opening Administrative events

Custom View page from Admin Events

Custom View page from Admin Events

1. In the Custom View page, you can see logged drop down, choose a preferred time or it gives you an option to create a custom time to set. 2. On the Event Level choose an appropriate level for your custom view, You can choose among the 5 levels.

Selecting Event Levels

Selecting Event Levels

1. Once done, choose how you want the events to be filtered, By log or By source.

Filtering using: By log

Filtering using: By log

Filtering using: By Source

Filtering using: By Source

Once everything is set up according to your needs, save all events in Custom View as

from the drop-down menu and choose an appropriate location to save the logs. Click on the Save button. (A log file with the extension .evtx will be saved on your device).

Conclusion

This blog provides an understanding how you can use the Windows Event Viewer which is provided by the Windows in default and using it to monitor Windows logs.

  • Main event log files are stored in C:\\Windows\\System32\\winevt\\Logs.
  • Windows logs are crucial for understanding the activities, errors, and significant events on your machine. They provide valuable information for troubleshooting, auditing, and ensuring system integrity.
  • They record a variety of system activities, errors, and other significant events, providing valuable information for troubleshooting, auditing, and ensuring system integrity.
  • We learnt how to setup Filtering and Custom Views to optimise what we see and solve the problems and where it happened.

By grasping the significance of different event types such as System, Application, Security, Setup, and Forwarded Events, and knowing how to filter and export logs, you can effectively manage your Windows system.

FAQ’s

How to view Windows logs?

To view Windows logs, use the built-in Event Viewer:

  1. Press Win + R, type eventvwr, and press Enter.
  2. Navigate through the console tree to find the log you want to view (e.g., Windows Logs > Application).

Where are Microsoft logs?

Microsoft logs, including Windows logs, can be found in the Event Viewer under sections like Application, Security, and System. Log files are also located in the C:\Windows\System32\winevt\Logs directory.

How do I audit Windows logs?

To audit Windows logs:

  1. Open Event Viewer.
  2. Navigate to Security logs under Windows Logs.
  3. Configure auditing policies via the Local Security Policy or Group Policy Management Console.

How do I check my Windows activity log

Check your Windows activity log by viewing the Security logs in Event Viewer. These logs record user logins, logoffs, and other security-related activities.

Which is Windows log key?

The Windows log key, often referred to as the Windows key, is the key on your keyboard with the Windows logo. It is used in various shortcuts to open system tools, including Event Viewer (Win + X > Event Viewer).

Where is the logs folder?

The logs folder is located at C:\Windows\System32\winevt\Logs. This folder contains all the event log files in .evtx format.

Why are Windows logs important?

Windows logs are important because they provide detailed information about system operations, security events, and application behavior, which is crucial for troubleshooting, auditing, and ensuring system integrity.

How to view log files?

View log files using Event Viewer:

  1. Open Event Viewer (Win + R, type eventvwr, press Enter).
  2. Expand the Windows Logs section and select the log you want to view.

Where are login logs?

Login logs are located in the Security logs section of Event Viewer. They record all login attempts, both successful and failed.

What are system logs?

System logs contain information about the core operations of the Windows operating system, including hardware events, driver issues, and system startups and shutdowns. They are found under the System section in Event Viewer.

How do I find Windows log files?

Find Windows log files in the Event Viewer or directly in the C:\Windows\System32\winevt\Logs directory.

How do I view user logs in Windows 10?

View user logs in Windows 10 through the Event Viewer:

  1. Open Event Viewer.
  2. Go to Windows Logs > Security to see logs related to user activities, including logins and logoffs.

How do I view Windows setup logs?

To view Windows setup logs:

  1. Open Event Viewer.
  2. Navigate to Applications and Services Logs > Microsoft > Windows > Setup.

How do I view Windows app logs?

To view Windows application logs:

  1. Open Event Viewer.
  2. Navigate to Windows Logs > Application to see logs related to software applications running on your system.

Was this page helpful?

This is my write-up on THM’s Windows Event Logs Room.


Task 1: What are event logs?

Event logs essentially contain the records of events or activities that have transpired in a machine or host, that would help system administrators, IT technicians, etc, audit and trouble shoot issues in the system.

But for blue teams, windows event logs serve a different purpose. These logs are analyzed for malicious activities or indicators of compromise. Windows Event Logs can also be forwarded to SIEMs where analyst can aggregate, analyze, and correlate log data from various sources to provide security insights of a network.

For a Linux system, the logging system is knows as Syslog.


Task 2: Event Viewer

The Windows Event Logs are stored with an .evt or .evtx extension and are located in C:\\Windows\\System32\\winevt\\Logs.

Before moving on to Event Viewer, we first need to understand the different elements of a Windows Event Logs system. This would help us understand where to look at if we are trying to solve an issue or analyzing a specific kind of event.

  • System Logs: Records events associated with the Operating System segments. They may include information about hardware changes, device drivers, system changes, and other activities related to the device.
  • Security Logs: Records events connected to logon and logoff activities on a device. The system’s audit policy specifies the events.
  • Application Logs: Records events related to applications installed on a system. The main pieces of information include application errors, events, and warnings.
  • Directory Service Events: Active Directory changes and activities are recorded in these logs, mainly on domain controllers.
  • File Replication Service Events: Records events associated with Windows Servers during the sharing of Group Policies and logon scripts to domain controllers, from where they may be accessed by the users through the client servers.
  • DNS Event Logs: DNS servers use these logs to record domain events and to map out
  • Custom Logs: Events are logged by applications that require custom data storage. This allows applications to control the log size or attach other parameters, such as ACLs, for security purposes.

The following table describes the five event types used in event logging.

Event type Description
Error An event that indicates a significant problem such as loss of data or loss of functionality. For example, if a service fails to load during startup, an Error event is logged.
Warning An event that is not necessarily significant, but may indicate a possible future problem. For example, when disk space is low, a Warning event is logged. If an application can recover from an event without loss of functionality or data, it can generally classify the event as a Warning event.
Information An event that describes the successful operation of an application, driver, or service. For example, when a network driver loads successfully, it may be appropriate to log an Information event. Note that it is generally inappropriate for a desktop application to log an event each time it starts.
Success Audit An event that records an audited security access attempt that is successful. For example, a user’s successful attempt to log on to the system is logged as a Success Audit event.
Failure Audit An event that records an audited security access attempt that fails. For example, if a user tries to access a network drive and fails, the attempt is logged as a Failure Audit event.

Event Viewer

The Windows Event Logs can be accessed with three methods; Event Viewer, Wevtutil.exe (command-line), and Get-WinEvent (PowerShell). The latter two methods will be discussed in the succeeding tasks.

Event Viewer allows interaction with and analyzing the logs in a GUI application.

Event Viewer can be started by right-clicking the Windows icon and selecting Event Viewer.

Or by typing “eventvwr.msc” in the command line.

Answer the questions below

For the questions below, use Event Viewer to analyze Microsoft-Windows-PowerShell/Operational log.

What is the Event ID for the first recorded event?

Answer: 40961

Open Event Viewer and go to Applications and Services Logs then to Microsoft > Powershell > Operational log.

The first event is found at the bottom of the window pane. We can also click on “Date and Time” column to sort the events based on the date and time of the occurrence of events.

Filter on Event ID 4104. What was the 2nd command executed in the PowerShell session?

Answer: whoami

To create a filter, go to the right pane. Under “Operational” click on “Filter current Log”

We will filter the events with the Event ID 4104.

Once the results are in, sort the events based on date and time. Select the second event. Select the “Details” tab and the PowerShell command is displayed with the tag “ScriptBlockText”.

What is the Task Category for Event ID 4104?

Answer: Execute a Remote Command

We can find the answer by looking at the middle pane, similar to the image above. The “Task Category” column shows the category for Event ID 4104.

Analyze the Windows PowerShell log. What is the Task Category for Event ID 800?

Answer: Pipeline Execution Details

Clear the filter first. We would be returned to the same PowerShell event logs.

The middle pane, under the “Task Category” column would show the task category for Event ID 800.


Task 3: wevtutil.exe

Wevtutil.exe (Windows Event Utility) is a command line tool that would help us query event logs. By writing scripts with this tool, we would be more efficient in sifting through thousands of event logs.

To access its help files, we will run wevtutil.exe /?.

The tool would follow this syntax.

  • wevtutil COMMAND [ARGUMENT [ARGUMENT] …] [/OPTION:VALUE [/OPTION:VALUE] …]

The commands are the following:

el  | enum-logs        List log names.
gl  | get-log          Get log configuration information.
sl  | set-log          Modify configuration of a log.
ep  | enum-publishers  List event publishers.
gp  | get-publisher    Get publisher configuration information.
im  | install-manifest Install event publishers and logs from manifest.
um  | uninstall-manifest Uninstall event publishers and logs from manifest.
qe  | query-events     Query events from a log or log file.
gli | get-log-info     Get log status information.
epl | export-log       Export a log.
al  | archive-log      Archive an exported log.
cl  | clear-log        Clear a log.

Note: We can use the short or long versions of the command, example el or enum-logs

Common options are;

Common Options:

/{r | remote}:VALUE
If specified, run the command on a remote computer. VALUE is the remote computer name. Options /im and /um do not support remote operations.

/{u |username}:VALUE
Specify a different user to log on to the remote computer. VALUE is a user name in the form of domain\\user or user. Only applicable when option /r is specified.

/{p | password}:VALUE
Password for the specified user. If not specified, or if VALUE is "*", the user will be prompted to enter a password. Only applicable when the /u option is specified.

/{a | authentication}:[Default|Negotiate|Kerberos|NTLM]
Authentication type for connecting to remote computer. The default is Negotiate.

/uni | unicode}:[true|false]
Display output in Unicode. If true, then output is in Unicode.

To learn more about a specific command, type the following:

wevtutil COMMAND /?

If we want to know how to use a specific command, as provided in the help files, we will use wevtutil COMMAND /?. For example, if we want to get more information on the command qe (query-events), we would use wevtutil qe /?.

More info can be found on docs.microsoft.com.

Answer the questions below

How many log names are in the machine?

Answer: 1071

The command el would list the log names and the results would then be piped to the next command to count the list of log names by line.

wevtutil el | Measure-Object -Line

What event files would be read when using the query-events command?

Answer: event log, log file, structured query

For us to find more info about the command, we would use wevtutil qe /?.

What option would you use to provide a path to a log file?

Answer: /lf:true

After running the command, we see the options we can use with qe. The option we would use to include a log file path is /lf:true.

What is the VALUE for /q?

Answer: query XPATH

Scrolling through the options, we can see the value for /q? is XPATH query.

The questions below are based on this command: wevtutil qe Application /c:3 /rd:true /f:text

What is the log name?

Answer: Application

From the command given to us, wevtutil is querying events from Application logs.

What is the /rd option for?

Answer: event read redirection

When we run wevtutil qe /?, we would see the options for this command. /rd would refer to event read redirection.

What is the /c option for?

Answer: Maximum number of events to read

/c option refers to the number of events that we wold want to query from the logs.


Task 4: Get-WinEvent

Get-WinEventis a Powershell cmdlet. Per Microsoft, the Get-WinEvent cmdlet “gets events from event logs and event tracing log files on local and remote computers.” The tool can provide information on event logs and event log providers. We can also combine events from different sources by using a single command and filtering these events with XPath queries, structured XML queries, and hash table queries.

Note: The Get-WinEvent cmdlet replaced the Get-EventLog cmdlet.

Refer to the Get-Help information online at docs.microsoft.com.

Examples of how to use Get-WinEvent

Example 1: Get all logs from a computer

The first list will be classic logs, then by new Windows Event logs. RecordCount can have zero or null logs.

Example 2: Get event log providers and log names

This will get us the event log providers and their associated logs. The Name is the provider, and LogLinks is the log that is written to.

Get-WinEvent -ListProvider *

Example 3: Log filtering

Log filtering allows us to select events from an event log. We can then filter event logs from a specific Provider using the Where-Object cmdlet:

Get-WinEvent -LogName Application | Where-Object { $_.ProviderName -Match 'WLMS' }

Where-Object is inefficient to use when working with large event logs. Therefore, the suggested Get-WinEvent cmdlet’s FilterHashtable parameter is recommended to filter event logs.

Get-WinEvent -FilterHashtable @{
LogName='Application'
ProviderName='WLMS'
}
Get-WinEvent -FilterHashtable @{ LogName='Application'; ProviderName= 'WLMS'} 

The syntax of a hash table is as follows:

@{ <name> = <value>; [<name> = <value> ] ...}

Guidelines for defining a hash table are:

  • Begin the hash table with an @ sign.
  • Enclose the hash table in braces {}
  • Enter one or more key-value pairs for the content of the hash table.
  • Use an equal sign (=) to separate each key from its value.

Note: Using semicolon is not needed if each key/value are separated with a new line, as in the first set of commands above for the -FilterHashtable for ProviderName='WLMS'.

Below is a table that displays the accepted key/value pairs for the Get-WinEvent FilterHashtable parameter.

Key name Value data type Accepts wildcard characters?
LogName <String[]> Yes
ProviderName <String[]> Yes
Path <String[]> No
Keywords <Long[]> No
ID <Int32[]> No
Level <Int32[]> No
StartTime <DateTime> No
EndTime <DateTime> No
UserID <SID> No
Data <String[]> No
<named-data> <String[]> No

Check the official Microsoft documentation docs.micro-soft.com for more info on querying using Filterhashtable.

Here is a command by @mubix on using Get-WinEvent -FilterHashtable

Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-PowerShell/Operational'; ID=4104} | Select-Object -Property Message | Select-String -Pattern 'SecureString'

Answer the questions below

Answer the following questions using the online help documentation for Get-WinEvent

Execute the command from Example 1 (as is). What are the names of the logs related to OpenSSH?

Answer: OpenSSH/Admin,OpenSSH/Operational

We will use the command from example 1, then pipe the result to find the strings that matches ssh. We see two logs being displayed.

Get-WinEvent -ListLog * | findstr /i ssh

Execute the command from Example 8. Instead of the string Policy search for PowerShell. What is the name of the 3rd log provider?

Answer: Microsoft-Windows-PowerShell-DesiredStateConfiguration-FileDownloadManager

We will simply copy the command and change the string policy to Powershell. This will display all events relatd to the filter.

Get-WinEvent -ListProvider *Powershell*

Alternatively, we can modify the command to display only the third log provider.

Get-WinEvent -ListProvider *Powershell* | Select-Object -Property Name -Skip 2 -First 1

Execute the command from Example 9. Use Microsoft-Windows-PowerShell as the log provider. How many event ids are displayed for this event provider?

Answer: 192

We will be using the provided command and changing the log provider to Microsoft-Windows-PowerShell. We will also be modifying it by adding Measure-Object -Line to count the results by line.

(Get-WinEvent -ListProvider Microsoft-Windows-PowerShell).Events | Format-Table Id, Description | Measure-Object -Line

How do you specify the number of events to display?

Answer: -MaxEvents

Example 13 provided us the options we can use to display only a certain number of events.

If we want to know more about -MaxEvents, we could use the Get-Help cmdlet.

When using the FilterHashtable parameter and filtering by level, what is the value for Informational?

Answer: 4

This resource for FilterHashtable contains the numerical value of each Level.


Task 5: XPath Queries

The third method of filtering events is by using XPath or XML Path Language, which was created by W3C. The Windows Event Log supports a subset of XPath 1.0.

Here is an example of an XPath query along with its explanation:

// The following query selects all events from the channel or log file where the severity level is less than or equal to 3 and the event occurred in the last 24 hour period.
XPath Query: *[System[(Level <= 3) and TimeCreated[timediff(@SystemTime) <= 86400000]]]

See docs.microsoft.com for more examples of XPath queries. 

Note: An XPath event query starts with ‘*’ or ‘Event‘. wevtutil and Get-WinEvent support XPath queries.

To create an XPath query, Event Viewer would be the reference point.

We look at the bottom of the middle pane, click on the “Details” tab and select the “XML View”. The sructure presented would help use construct a valid XPath query.

The first tag is the starting point. This can either be an ‘*' or Event.

The command would look like this:

Get-WinEvent -LogName Application -FilterXPath '*'

Working our way down, the next tag is System.

Let’s add that to our command:

Get-WinEvetnt -LogName Application -FilterXPath '*/System/'

Next is the EventID tag. We would use the tag name and include the Event ID we want to filter. In this example, the Event ID is 100.

The command would look like something like this:

Get-WinEvetnt -LogName Application -FilterXPath '*/System/EventID=100'

The following would be the result if using wevtutil.exe and XPath to query for the same event log and ID.:

wevtutil.exe qe Application /q:*/System[EventID=100] /f:text /c:1

Two additional options were added to filter only one event with no XML tags.

If we want to query a different element, such as the Provider Name, we need to use the Name attribute of Provider.

Therefore, to query for the Provider name with XPath:

Get-WinEvent -LogName Application -FilterXPath '*/System/Provider[@Name="WLMS"]'

We can also combine two queries in one command.

For example, if we want to query Event IDs of 100 with the Provider Name “WLMS”, we would arrive at this command:

Get-WinEvent -LogName Application -FilterXPath '*/System/Provider[@Name="WLMS"]'

Creating XPath queries with EventData

Querying for elements within EventData with XPath will be a little bit different

Note: The EventData element doesn’t always contain information.

We will use the below XML view of an event to build the XPath query

For this example, we will be creating a query for the TargetUserName of System. The XPath query would be:

Get-WinEvent -LogName Security -FilterXPath '*/EventData/Data[@Name="TargetUserName"]="System"' -MaxEvents 1

The parameter -MaxEvents will return just 1 event.

Read the official Microsoft XPath Reference for more information.

Answer the questions below

Using the knowledge gained on Get-WinEvent and XPath, what is the query to find WLMS events with a System Time of 2020-12-15T01:09:08.940277500Z?

Answer: Get-WinEvent -LogName Application -FilterXPath ‘*/System/Provider[@Name=”WLMS”] and */System/TimeCreated[@SystemTime=”2020-12-15T01:09:08.940277500Z”]’

The steps provided above in building an XPath query would help us create the command.

Using Get-WinEvent and XPath, what is the query to find a user named Sam with an Logon Event ID of 4720?

Answer: Get-WinEvent -LogName Security -FilterXPath ‘*/EventData/Data[@Name=”TargetUserName”]=”Sam” and */System/EventID=4720’

We will be be creating two queries in one command. The first query is to query within the EventData the tag TargetUsername, and specifying the username to be “Sam”. The second query is within Event, looking through System, and specifying the EventID of 4720.

Based on the previous query, how many results are returned?

Answer: 2

We got two results.

Based on the output from the question #2, what is Message?

Answer: A user account was created

The query filters user account creation.

Still working with Sam as the user, what time was Event ID 4724 recorded? (MM/DD/YYYY H:MM:SS [AM/PM])

Answer: 12/17/2020 1:57:14 PM

Working with the same command from above, we just need to change the EventID to 4724.

Get-WinEvent -LogName Security -FilterXPath '*/EventData/Data[@Name="TargetUserName"]="Sam" and */System/EventID=4724'

What is the Provider Name?

Answer: Microsoft-Windows-Security-Auditing

We found the answer when we run the command from above.


Task 6: Event IDs

With the large number of Event IDs in use, we will definitely need resources to help us monitor and hunt events. This section will be covering us in that aspect.

First on the list is The Windows Logging Cheat Sheet (Windows 7 – Windows 2012). The last version update is October 2016, but it’s still a good resource. The document covers a few things that need to be enabled and configured and what event IDs to look for based on different categories, such as Accounts, Processes, Log Clear, etc.

From the resource, if we want to detect if a new service was installed, look for Event ID 7045 within the System Log. The command would be as follows

wevtutil qe System /q:"*/System[EventID=7045]" /c:5 /rd:true /f:text

Spotting the Adversary with Windows Event Log Monitoring is another resource.

I was unable though to connect and download the resource.

But from the room, a snippet is provided from the document where we see Event IDs related to Firewall Rules.

MITRE ATT&CK is also on the list for monitoring or hunting Event IDs.

We can look at a Technique and identify the related Event IDs that we should monitor and hunt. For example, if we look at ATT&CK ID T1098 (Account Manipulation), the “Detection” section contains the Event IDs that are triggered.

The MITRE ATT&CK framework also contains information on how to mitigate each techniques.

The last two resources are from Microsoft:

  • Events to Monitor (Best Practices for Securing Active Directory)
  • The Windows 10 and Windows Server 2016 Security Auditing and Monitoring Reference (a comprehensive list [over 700 pages])
  • Here is a snippet of the 700-page Windows 10 and Windows Server 2016 Security Auditing and Monitoring Reference

Note: There are certain events that are not generated by default, one of them is PowerShell logging. This feature can be enabled via Group Policy or the Registry.

Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell

Press the Windows icon on the keyboard + R to open the Run dialog and type gedit.msc to open the Group Policy Management Console.

Some resources to provide more information about enabling this feature, along with its associated event IDs:

  • About Logging Windows
  • Greater Visibility Through PowerShell Logging
  • Configure PowerShell logging to see PowerShell anomalies in Splunk UBA

Another feature to enable/configure is Audit Process Creation, which will generate event ID 4688 and will allow command-line process auditing.

Local Computer Policy > Computer Configuration > Administrative Templates > System > Audit Process Creation

We have already enabled Audit Process Creation

We will now perform step 2.

I run a simple command of whoami

Go to Event Viewer to see if the command was logged. We should look under Windows Logs > Security. It can be observed that it was not logged at all.

Now for step 3, Enable the command line process auditing.

  • In the Group Policy Editor, go to “Computer Configuration” > “Windows Settings” > “Security Settings” > “Advanced Audit Policy Configuration” > “Audit Policies” > “Detailed Tracking.”
  • In the right pane, locate the “Audit Process Creation” policy, and double-click on it to open the properties.
  • In the properties window, select the “Define these policy settings” option.
  • Check the “Success” and “Failure” boxes to enable auditing for successful and failed process creations. Click Apply and Ok.

We’ll run the same command and notice if there’s a difference.

The command was logged this time.

The steps to test the configuration are at the bottom of the document.

The resources are not exhaustive list, hence we need to read more about this topic.

To effectively monitor and hunt, we need to know what to look for.

Answer the questions below

I’m ready to look at some event logs…


Task 7: Putting theory into practice

Let’s now test our newly acquired pool of knowledge on Windows Event Logs with the different scenarious presented below.

The next scenarios/questions are based on the external event log file titled merged.evtx found on the Desktop. 

Scenario 1 (Questions 1 & 2): The server admins have made numerous complaints to Management regarding PowerShell being blocked in the environment. Management finally approved the usage of PowerShell within the environment. Visibility is now needed to ensure there are no gaps in coverage. You researched this topic: what logs to look at, what event IDs to monitor, etc. You enabled PowerShell logging on a test machine and had a colleague execute various commands.

Scenario 2 (Questions 3 & 4): The Security Team is using Event Logs more. They want to ensure they can monitor if event logs are cleared. You assigned a colleague to execute this action.

Scenario 3 (Questions 5, 6 & 7): The threat intel team shared its research on Emotet. They advised searching for event ID 4104 and the text “ScriptBlockText” within the EventData element. Find the encoded PowerShell payload.

Scenario 4 (Questions 8 & 9): A report came in that an intern was suspected of running unusual commands on her machine, such as enumerating members of the Administrators group. A senior analyst suggested searching for “C:\\Windows\\System32\\net1.exe“. Confirm the suspicion.

Answer the questions below

Open the merged.evtx file with event viewer

What event ID is to detect a PowerShell downgrade attack?

Answer: 400

A search on google would yield us about detecting PowerShell downgrade attacks. Here is an interesting article why attackers would downgrade to older versions of PowerShell.

What is the Date and Time this attack took place? (MM/DD/YYYY H:MM:SS [AM/PM])

Answer: 12/18/2020 7:50:33 AM

I used PowerShell for this task, added –Path parameter to indicate the source of the log file.

Get-WinEvent -Path .\\Desktop\\merged.evtx -FilterXPath '*/System/EventID=400' -MaxEvents 10

We can add the following to sort the results.

Sort-Object -Property TimeCreated -Descending

A Log clear event was recorded. What is the ‘Event Record ID’?

Answer: 27736

In one of the resources provided, an EventID of 104 is generated when the Application or System log were cleared.

Now that we know the Event ID, let’s filter the logs with eEentID 104.

Select the windows event. In the lower pane, click on the “Details” tab and select “XML View”. We now see the ID for the recorded event.

What is the name of the computer?

Answer: PC01.example.corp

The computer name is seen in the tag “Computer” or in the “General” tab.

What is the name of the first variable within the PowerShell command?

Answer: $Va5w3n8=

It is important to know, that only when Script Block Logging is enabled, that these blocks of code, when executed by PowerShell are logged. Such events are recorded with EventID 4104.

The following command would query, using XPath, all events with a 4104 ID, within “EventData” focusing on the tag “Data” that has the strings “ScriptBlockText”. Note: Variables always start with ‘$’.

Get-WinEvent -Path .\\Desktop\\merged.evtx -FilterXPath '*/System/EventID=4104 and */EventData/Data[@Name="ScriptBlockText"]' -Oldest -MaxEvents 1 | Format-List

It took me a while to realize that the details displayed are incomplete, and I try not to rely on Event Viewer too much, because imagine if we have thousands of events to crumb through.

These commands would display all the info about the events and would also provide the answer for the next two questions.

Get-WinEvent -Path .\Desktop\merged.evtx -FilterXPath '*/System/EventID=4104 and */EventData/Data[@Name="ScriptBlockText"]' -Oldest -MaxEvents 1 | Select-Object -Property *

What is the Date and Time this attack took place? (MM/DD/YYYY H:MM:SS [AM/PM])

Answer: 8/25/2020 10:09:28 PM

What is the Execution Process ID?

Answer: 6620

What is the Group Security ID of the group she enumerated?

Answer:S-1-5-32-544

To confirm if she enumerated the “Administrators” group in her local machine, we would run the following commands. We will filter events with XPath within the elements of “EventData” and include the location of the suspected executed file. The piped results would display all the information about the queried events.

Get-WinEvent -Path .\merged.evtx -FilterXPath '*/EventData/Data[@Name="CallerProcessName"]="C:\Windows\System32\net1.exe"' | Select-Object -Property *

There were three events logged, but we are interested in the event where the local group “Administrators” was enumerated.

What is the event ID?

Answer: 4799

For reference, check this out.


Task 8: Conclusion

We have covered a lot about Windows Event Logs, the important Event IDs we should monitor and hunt, and how to query them with the different tools and techniques.

We also touched on the features that need to be enabled or configured so that they can be logged for further visibility.

Windows event logs from various endpoints are also forwarded to SIEMs for easy filtering of evnts, correlating rules, generating reports, and detecting suspicous activities.

TryHackme provided us parting gifts for additional reading:

  • EVTX Attack Samples (a few were used in this room)
  • PowerShell ❤ the Blue Team
  • Tampering with Windows Event Tracing: Background, Offense, and Defense

That concludes this room.


Thank you for reading 🙂

Happy learning!.

In this article…

  • What is the Windows Event Log (EventLog) service?
  • What happens if I stop EventLog?
  • Is it OK to disable the Windows Event Log service?
  • Questions? Problems?

What is the Windows Event Log (EventLog) service?

The EventLog service manages event logs — repositories of events generated by services, scheduled tasks and applications working closely with the Windows operating system.

The service’s display name is Windows Event Log and it runs inside the service host process, svchost.exe. By default, the service is set to start automatically when your computer boots:

EventLog Windows Service

You can use the Windows Event Viewer to browse the event logs managed by the service. For example, here are some of the records captured in the Windows Security event log:

Event Viewer: Windows Security log

What happens if I stop EventLog?

You may find it virtually impossible to stop the Windows Event Log service.

That’s because the service supports several important system services. You can see that list on the service’s Dependencies tab:

Windows Event Log Dependencies

And because of those dependency relationships, attempting to stop EventLog triggers a “cascade” that causes all dependent services to stop too. Here you can see Windows alerting us of that situation:

But after we clicked “Yes”, Windows failed to stop EventLog and the dependent services! A peculiar error was returned:

Error stopping the EventLog service

We tracked the issue to “Network List Service” (netprofm). That service refused every attempt to stop it, consistently failing with the error above. And since we could not stop “Network List Service”, we could not stop EventLog either.

Is it OK to disable the Windows Event Log service?

No — it’s not safe to disable the Windows Event Log service.

Indeed, in the very description of the service, Microsoft warns:

 Stopping this service may compromise security and reliability of the system.

That advice makes sense because EventLog provides essential support for Windows Services, scheduled tasks, and other background programs. Those components typically run “headless”, without a user interface, and rely on the event logs to record important events.

If the EventLog service stops, those background components will have no way to chronicle their activities. There would be an ominous gap in the operating system’s low-level records.

With that in mind, it’s easy to see why the EventLog service is an alluring target for attackers looking to compromise a system. Once the service has been crippled, vital forensics records may not be captured and intruders could operate with impunity.

Questions? Problems?

If you would like to know more about the Windows Event Log service, or you have a specific problem, please feel free to get in touch. We will do our best to help you!

You may also like…

Event Viewer – How to Access the Windows 10 Activity Log

The Windows 10 Event Viewer is an app that shows a log detailing information about significant events on your computer. This information includes automatically downloaded updates, errors, and warnings.

In this article, you’ll learn what the event viewer is, the different logs it has, and most importantly, how to access it on a Windows 10 computer.

What is the Event Viewer?

Each program you open on your Windows 10 computer sends a notification to a particular activity log in the Event Viewer.

All other activity such as OS changes, security updates, driver quirks, hardware failure, and so on are also posted to a particular log. So you can think of the event viewer as a database that records every activity on your computer.

With the event viewer, you can troubleshoot different Windows and application issues.

If you explore the event viewer in-depth, you will see different information, warnings, and plenty of errors. Don’t freak out – this is normal. Even the best-maintained computers show plenty of errors and warnings.

There are 3 main ways you can gain access to the event viewer on Windows 10 – via the Start menu, Run dialogue, and the command line.

Step 1: Click on Start or press the WIN (Windows) key on your keyboard
Step 2: Search for “Event Viewer”
Step 3: Click on the first search result or press ENTER

ss-1-5

You will be greeted with this page:

ss-2-1

How to Access the Windows 10 Activity Log through the Run Dialogue

Step 1: Right-click on Start (Windows log) and select “Run”, or press WIN (Windows key) + R on your keyboard

ss-3-4

Step 2: Type in “eventvwr” to the editor and click “Ok” or hit ENTER

ss-4-5

ss-5-5

How to Access the Windows 10 Activity Log through the Command Prompt

Step 1: Click on Start (Windows logo) and search for “cmd”
Step 2: Hit Enter or click on the first search result (should be the command prompt) to launch the command prompt

ss-6-3

Step 3: Type in “eventvwr” and hit ENTER

ss-7-2

ss-8-2

Event Viewer Activity Logs

When you open the event viewer to see your computer’s activity logs, you are automatically shown the Event Viewer (Local) tab. But this might not contain the details you need, as it’s just a page you are greeted with when you open the Event Viewer.

There is lots more to the Event Viewer than this.

The Administrative Events Log

You can expand the Custom Views tab to see your computer’s administrative events, like this:

ss-9

The Windows Activity Logs

You can also expand the Windows Logs to show various activities such as:

  • Application Events: Information, errors, and warning reports of program activities

    ss-10

  • Security Events: This shows the results of various security actions. They are called audits and each of them can be a success or a failure

    ss-11

  • Setup Event: this has to do with domain controllers, which is a server that verifies users on computer networks. You shouldn’t worry about them day-to-day.

    ss-12

  • System Events: these are reports from system files detailing the errors they have encountered

    ss-13-1

  • Forwarded Events: these are sent to your computer from other computers in the same network. They help you keep track of the event logs of other computers in the same newtwork.

    ss-14-1

In addition, there are the Application and Service logs, which show hardware and Internet Explorer activities, alongside Microsoft Office apps activities.

You can double click on an error to check its properties, and look up the event ID of the error online. This can help you discover more information on the error so you can fix it if you need to.

ss-15

Conclusion

In this article, you learned about the Windows 10 Event Viewer, which is a very powerful tool Windows users should know how to use.

Apart from viewing various activity logs, it also helps you be aware of what’s happening on your computer.

Thank you for reading. If you consider this article helpful, please share it with your friends and family.



Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started

What is Windows Event Log?

A Windows event log is an extensive archive of system, security, and application-related events kept on a Windows operating system. Event logs can be used to monitor and predict potential issues with the system and certain applications.

Microsoft first made the Windows event log available with the release of Windows Vista and Windows Server 2008. It is now part of every Windows version.

What are the Elements of a Windows Event Log?

The Windows event log contains a Windows operating system’s hardware and software events. Network operators can use it to monitor risks and problems that could cause performance degradation. Besides, Windows stores event logs in a common format, making the data understandable.

The primary components of a Windows event log are as follows:

Log Key

The Eventlog key is made up of multiple logs or subkeys. When an application contributes to or examines an event log, the event logging service utilizes the data contained in each log to find the resources.

Event Categories

Organizing events using categories makes it easier for Event Viewers to locate them. Each event source can define the listed categories and text strings into which they belong independently.

Event Sources

Event sources are subkeys found in each log within the Eventlog key. The program that generates the event is known as the event source. It is frequently the application’s name or the title of one of its subcomponents.

Event Identifiers

A specific event can be distinctively identified by its event identifier. In its message folder, every event source can establish its own set of listed events and the description strings that specify where they are assigned.

Event Log Record

Every event has its information recorded in an event log record like time, type, and category.

Event Data

Every event may have activity-specific data attached. The event log allows for an event’s total size of 0x3FFFF bytes.

Kinds of Data Saved in the Windows Event Log

Windows event logs store information regarding various system events. The categories an event log falls under determine what information is stored there.

There are mainly five Windows event log types:

1. Application Events

These are connected to instances involving locally installed software. When an application breaks down, its name and the reason it crashed are recorded in an application log entry that is created in the Windows event log.

2. Security Events

These keep data according to the audit policies of the Windows operating system. Logs of attempted logins and resource access are common events that are kept. For instance, when a user attempts to sign on to a computer, the system checks their account credentials and records them in the Windows security log.

3. Setup Events

These comprise domain-control-related enterprise-focused events, like the location of logs following a disc configuration. Additionally, events about Active Directory on domain controllers will be recorded in this log.

4. Forwarded Events

When an admin wishes to make use of a computer that collects multiple logs, these come from different systems on the very same network.

5. System Events

This Windows system event log records occurrences on the system and its elements. An illustration of a system-level event is the inability to launch the boot-start driver.

Different Levels of Windows Event Severity

Windows event levels highlight the severity of recorded events. These fall into the following categories:

Information: Shows that everything went according to plan. Information events can be found in most logs.

Verbose: Provides updates or success stories regarding a specific event.

Caution: This indicates a possible issue that system administrators ought to keep an eye on.

Error: Indicates problems with the system or service that don’t need to be fixed right away.

Critical: Denotes a serious problem that requires immediate attention in a system or application.

How to Examine and See Windows Event Log?

The C:\WINDOWS\system32\config\ folder is where Windows event logs are kept. ‘Event Viewer’ can be used to monitor event logs and identify system problems. How to do it is as follows:

Step 1: To launch the run window, use the keyboard shortcut Windows key + R.

Step 2: Enter “eventvwr” in the run dialogue box, then click OK.

Step 3: The Windows Logs menu can be expanded in the Event Viewer window.

Step 4: You can find several types of event logs under the Windows Logs menu, including application, security, setup, system, and forwarded events.

Step 5: To examine and view the events listed under a particular event log, click on it.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Как включить быстродействие на windows 10 про
  • Extensa 2510g драйвера windows 8
  • Терминальный клиент windows 10
  • Sims 4 peacemaker windows
  • Характеристики сетевого адаптера не соответствуют требованиям данной сети как исправить windows 7