Windows Logging for SOC
Anatomy of a Log Entry
- Windows logs are stored in binary format inside
C:\Windows\System32\winevt\Logs - Every
evtxfile corresponds to a specific log category
Reading Event Logs
Event Viewer is a built in tool to view and manage log events.
- Log Sources
- Every EVTX file corresponds to a single item on the left panel
- Log List: Each row you see is a single event that contains a few properties you can sort by:
- Keywords
- For some events, indicates if the action was successful or not
- Date and Time
- The timestamp when the event occurred (system time, not UTC)
- Event ID
- A unique number for the event name (e.g. a failed login is always 4625)
- Keywords
- Log Details
- The actual content of the log, in a plaintext or XML format (“Details” tab)
- Filters Menu
- Use the “Filter Current Log” and “Find” buttons to filter the logs
Security Log: Authentication
- Two most important security logs:
- EventID 4624 (Successful Logon)
- detects suspicious RDP/network logins and identify the attack starting point
- logged on the machine
- limitation:
- very noise, can see hundreds per minute
- EventID 4625 (Failed Logon)
- detect brute force, password spraying, or vulnerability scanning
- logged on the machine
- limitation:
- inconsistent
- logs have lots of caveats that may trick you into the wrong understanding of the event
- EventID 4624 (Successful Logon)
Structure of 4624
- Can cover most L1/L2 cases with a few core fields:
// Ignore this misleading section. Use "New Logon" instead!
Subject:
Security ID: SYSTEM
Account Name: THM-PC$
Acount Domain: WORKGROUP
Logon ID: 0x3E7
Logon Information:
Logon Type: 10 <- This is the login method (10=RDP, 3=Network)
[...]
// This is the actual logged in user
New Logon:
Security ID: THM-PC\Administrator
Account Name: Administrator
Account Domain: THM-PC
Logon ID: 0x5D6AC
// Source IP can be trusted. Hostname is not reliable
Network Information:
Workstation Name: THM-PC
Source Network Address: 10.12.99.54
[...]Usage of 4624/4625
Detect RDP Brute Force
- Open Security logs and filter for 4625 event ID (Failed login attempts)
- Look for events with Logon Type 3 and 10 (Network and RDP logins)
- For most modern systems, the logon type will be 3 (since NLA is enabled by default)
- For older or misconfigured systems, the logon type will be 10 (since NLA is not used)
- Every event is now worth your attention, but the main red flags are:
- Many attempted users like admin, helpdesk, and cctv (Indicates password spraying)
- Many login failures on a single account, usually Administrator (Indicates brute force)
- Workstation Name does not match a corporate pattern (e.g. kali instead of THM-PC-06)
- Source IP is not expected (e.g. your printer trying to connect to your Windows Server)
Anayze RDP Logons
- Open Security logs and filter for 4624 event ID (Successful logins)
- Look for events with Logon Type 10 (RDP logins)
- If NLA is enabled, every RDP logon event is preceded by another 4624 with logon type 3
- To get a real Workstation Name, you need to check the preceding logon type 3 event
- Your red flags are either a preceding brute force or a suspicious source IP / hostname
- If you assume that the login was indeed malicious, find out what happened next:
- Windows assigns a Logon ID to every successful login (e.g. 0x5D6AC)
- Logon ID is a unique session identifier. Save it for future analysis!
Security Log: User Management
- Common Event IDs:
| Event ID | Description | Malicious Usage |
|---|---|---|
| 4720 / 4722 / 4738 | A user account was created / enabled / changed | Attackers might create a backdoor account or even enable an old one to avoid detection |
| 4725 / 4726 | A user account was disabled / deleted | In some advanced cases, threat actors may disable privileged SOC accounts to slow down their actions |
| 4723 / 4724 | A user changed their password / User’s password was reset | Given enough permissions, threat actors might reset the password and then access the required user |
| 4732 / 4733 | A user was added to / removed from a security group | Attackers often add their backdoor accounts to privileged groups like “Administrators” |
Structure of User Management Events
- All user management events have a similar structure and can be split into three parts:
- who did the action (Subject)
- who was the target (Object)
- and which exact changes were made (Details)
- Subject
- The account doing the action
- Note the Logon ID field - you can use it to correlate this event with the preceding 4624 login event
- Object
- This can be named differently depending on an event ID (e.g. New Account or Member), but it always means the same - the target of the action
- Details
- A target group for 4732 and 4733 events, or new user’s attributes like full name or password expiration settings for the 4720 event
Usage of User Management Events
Hunt for Backdoored Users
- Open Security logs and filter for 4720 / 4732 event IDs
- Manually review every event; your red flags are:
- No one from your IT department can confirm the action
- Changes were made during non-working hours or on weekends
- The subject user’s name is unknown or unexpected to you
(e.g. “adm.old.2008” creating new Windows users)- The target user’s name does not follow a usual naming pattern
(e.g. “backup” instead of “thm_svc_backup”)- If you confirmed that the action was malicious, find out the login details:
- Copy the Logon ID field from your 4720 / 4732 event
- Find the corresponding login event with the same Logon ID
- Refer to the workbooks from the previous task for further analysis
Sysmon: Process Monitoring
Two ways to enable process monitoring on Windows:
| Event Code | Purpose | Limitations |
|---|---|---|
| 4688 (Security Log: Process Creation) | Log an event every time a new process is launched, including its command line and parent process details | Disabled by default, you need to enable it by following the official documentation |
| 1 (Sysmon: Process Creation) | Replace 4688 event code and provide more advanced fields like process hash and its signature | Sysmon is an external tool not installed by default. Check out the Sysmon official page |
Sysmon Event ID 1
- event ID 1 has a lot of different fields, the most important of which can be grouped as:
- Process Info: Context of the launched process, including its PID, path (image), and command line
- Parent Info: Context of the parent process
- very useful to build a process tree or an attack chain
- Binary Info: Process hash, signature, and PE metadata
- User Context: A user running the process and, most importantly, Logon ID - same as in the Security logs
Analyze Process Launch
- Open Sysmon logs and filter for event ID 1
- Review the fields from the process and binary info groups. The red flags are:
- Image is in an uncommon directory like C:\Temp or C:\Users\Public
- Process is suspiciously named like aa.exe or jqyvpqldou.exe
- Process hash (MD5 or SHA256) matches as malware on VirusTotal(opens in new tab)
- Review the fields from the parent process group. The red flags are:
- Parent matches red flags from step 2 (suspicious name, path, or hash)
- Parent is not expected (e.g. Notepad launching some CMD commands)
- If still in doubt, go up the process tree until you are confident in your verdict:
- Find the preceding event where ProcessId equals ParentProcessId in your event
- Analyze it by following steps 2 and 3 (suspicious parent, name, path, or hash)
- Finally, trace the attack chain by filtering all Security and Sysmon events with the same Logon ID
Sysmon: Files and Network
| Event ID | Security Log Alternative | Event Purpose |
|---|---|---|
| 11 / 13 (File Create / Registry Value Set) | 4656 for file changes and 4657 for registry changes, both disabled by default | Detect files dropped by malware or its changes to the registry (e.g. for persistence) |
| 3 / 22 (Network Connection / DNS Query) | No direct alternative, requires additional firewall and DNS configuration | Detect traffic from untrusted processes or to known malicious destinations |
Structure of Sysmon Events
Sysmon 3: Network Connection
[Process Info]
ProcessId: 1922
Image: C:\Program Files\Program\program.exe
[User Info]
User: THM-PC\sarah.miller
[Network Info]
Protocl: tcp
SourceIp: x.x.x.x
SourcePort: 50558
DestinationIp: x.x.x.x
DestinationPort: 443- The first to sections have the same structure across events
- The last has the event specific information
- e.g., Network Connects, DNS query, File creation, Registry value set, etc.
- use the ProcessId field to find the corresponding event ID 1 (process creation) to get full context
Usage of Sysmon Events
Analyze Process Activities
- Copy the ProcessId field from the event ID 1
- Search for other Sysmon events with the same ProcessId
- Your red flags for network connection events are:
- Connection to external IPs on port 80 or on non-standard ports like 4444
- Connection to known malicious IPs (e.g. by checking on VirusTotal(opens in new tab))
- DNS queries to suspicious domains (*.top, *.click, or hpdaykfpadvsl.com)
- Your red flags for file and registry changes are:
- Files dropped to staging directories like C:\Temp or C:\Users\Public
- Dropped file is a script (.bat or .ps1) or an executable file (.exe or .com)
- Created files or registry keys are used for persistence (soon on it later!)
PowerShell: Logging Commands
- Powershell history file
- plain text file
- automatically created by PowerShell
- records every command entered
- updated immediately when you press enter to submit a command
C:\Users\<USER>\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
- very useful for tracking malicious actions like system discovery or malware download
- created for every user
- may see five files if there are five active system users
- survives system reboots unless manually deleted
- saves all PowerShell commands entered for all time
- does not log command outputs
- does not show script content
Reference
Windows Logging for SOC. (2023). TryHackMe. https://tryhackme.com/room/windowsloggingforsoc