> For the complete documentation index, see [llms.txt](https://lswsec.gitbook.io/lswsec-blueteam/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lswsec.gitbook.io/lswsec-blueteam/siem/logging.md).

# Logging

### What is logging? <a href="#docs-internal-guid-1554ee2d-7fff-1eac-9346-967d4f8029fe" id="docs-internal-guid-1554ee2d-7fff-1eac-9346-967d4f8029fe"></a>

* Detailed lists of application information, system performance statistics and user activity
* Can be useful to keep track of computer use, network activity, security issues and error reports

### Syslog

* Actions generate events which are logged on many devices
* Impractical to review these locally
* &#x20;Available on unix and linux
* Can be used on windows
* Uses UDP 514 by default  TCP 514 can be used for more reliability
* Some more secure standards require TCP 6514 is used
* Made up for 3 components: priority value, header and message.

#### Priority value

* Derived from facility code and severity level
* Use   (facility code \* 8 ) + Severity Value = PRI&#x20;

<div><figure><img src="https://142152975-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9b4qpO6dSzFRrCp5o4Y7%2Fuploads%2FKbVGfRsY6l2qypQfMjrX%2F2023-05-03%2011_59_50-SIEM%20-%20Google%20Docs%20%E2%80%94%20Mozilla%20Firefox.png?alt=media&amp;token=99adf043-c332-43e2-a8d9-0606a8d606e2" alt=""><figcaption></figcaption></figure> <figure><img src="https://142152975-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9b4qpO6dSzFRrCp5o4Y7%2Fuploads%2Fy2hoZKIBbhXoYmttUHYb%2F2023-05-03%2012_00_05-SIEM%20-%20Google%20Docs%20%E2%80%94%20Mozilla%20Firefox.png?alt=media&amp;token=4bf9d71b-b23a-4175-b79a-22f9a6b5c902" alt=""><figcaption></figcaption></figure></div>

#### Header <a href="#docs-internal-guid-b3292f22-7fff-7ee8-a9f3-c9aa69b13877" id="docs-internal-guid-b3292f22-7fff-7ee8-a9f3-c9aa69b13877"></a>

* Contains information like timestamps, hostnames, application names, message IDs.

#### Message

* Each message can either be plane text or machine readable
* First label is function/facility. For example, mail servers usually use the mail facility.
* Second label specifies the severity level.&#x20;
* The action is then specified which is usually a file in /var/log.

### Windows event Logs <a href="#docs-internal-guid-b8d909ae-7fff-b9b8-6ddc-7ca2bb7ac239" id="docs-internal-guid-b8d909ae-7fff-b9b8-6ddc-7ca2bb7ac239"></a>

* Binary files with the .evtx extension
* Stored locally in the windows directory of an operating system.
* %WinDir%\system32\Config\*.evt
* %WinDir%\system32\WinEVT\Logs\*.evtx
* Keep a detailed log of the majority of events
* Registered events include: Application, System, Security, Directory service, DNS and File Replication.

#### Security Event logs

* Information about events which relate to the Windows Security Audit Policies
* Account logon events
* Account Management
* Privilege use
* Account Management
* Resource Usage

{% embed url="<https://www.andreafortuna.org/2019/06/12/windows-security-event-logs-my-own-cheatsheet/>" %}

#### Sysmon <a href="#docs-internal-guid-89e637af-7fff-4349-818e-252f0286143e" id="docs-internal-guid-89e637af-7fff-4349-818e-252f0286143e"></a>

* Windows system service and device driver.
* Monitor and log system activity
* Logs process creation with fill command line for both current and parent processes
* Includes session GUID
* Logs loading of drivers and DLLs with their signatures and hashes
* Optionally logs network connections.
* Detects changes in file creation time.
* Rule filtering to include or exclude certain events

<https://www.youtube.com/watch?v=9qsP5h033Qk&t=491s>

#### Installing Sysmon

Download sysmon, go to directory and run sysmon -i

<br>

### Other Logs

* Azure is usually monitored through Azure monitor and Log Analytic Workspace.
* Can automatically acquire logs from lots of devices
* Azure can be connected to lots of different siem platforms
* Uses kusto query language (KQL)

<br>

* Osquery is a universal and open source project developed by facebook
* Its an open source project
* Uses sql to explore data
* Creates one agent for multiple OS

### Aggregation

* Process of collecting logs, parsing them, extracting structured data then putting them in a format that's easy to understand
* Syslog - standard logging protocol, syslog server can be set up which receives logs from multiple sources
* Event Streaming -  Protocols like SNMP, Netflow adn IPFIX allow network devices to provide standard information about their operations.
* Log Collectors - software agents which run on network devices which capture logs parse it and send it to a centralized aggregator.
* Direct access - log aggregators that can directly access devices
* Structured data - usually logs for Apache, IIS, Windows events, cisco logs and some other manufacturers. They have clearly defined fields/
* Unstructured data -  usually from custom built applications. Most likely the majority of data being sent to siem
