Windows Event Logs & Sysmon
Find logons, process creation and service installs in Windows logs.
By Invicly Tech, , in Cyber Security Fundamentals. About 10 minutes to read.
In short
Windows records security events with numeric IDs, such as 4624 for a logon and 4688 for process creation. Sysmon adds richer telemetry. Knowing the key event IDs and how to query them turns raw logs into an investigation trail.
Explained simply
Windows keeps a diary of what happens on each computer: who signed in, which programs started, which services were installed. Each kind of entry has a number called an event ID. Learning a handful of these numbers lets you follow an attacker's footsteps.
The diary is split into channels. The Security channel holds sign-ins and account changes. The System channel holds service and driver events. Applications and Windows features have their own channels, such as PowerShell's. Event Viewer is the built-in app to browse them all.
The default logs miss many details an investigator wants, like the full command line of every program or which program opened a network connection. Sysmon (System Monitor), a free Microsoft tool, fills that gap with much richer events.
Clicking through Event Viewer is slow when you have thousands of events. PowerShell can filter and count events in seconds, and the same skills transfer to a SIEM (a central log search system) where all computers send their logs.
Press Play on a diagram to walk through it one step at a time.
- Logon
- 4624 success
- 4625 failure
- Process
- 4688 process created
- Account
- 4720 user created
- 4672 admin logon
- Sysmon
- 1 process
- 3 network
- 14625 x many
Password guessing over RDP (type 10)
- 24624 type 10
A guess works; attacker signs in
- 34688 / Sysmon 1
Tools run from a temp folder
- 47045
New service for persistence
- 54720 + 4732
New user added to Administrators
- 61102
Security log cleared to hide tracks
In depth
Logon events and logon types
Event 4624 records a successful logon and 4625 a failed one. Both carry a Logon Type field that tells you how the logon happened, and this changes the meaning a lot. Type 2 is someone at the keyboard. Type 3 is a network logon, such as opening a file share. Type 4 is a scheduled task, type 5 a service starting. Type 10 is Remote Desktop (RDP), and type 11 uses cached credentials when no domain controller is reachable.
For 4625, the Status and Sub Status codes explain why it failed. 0xC000006A means the user exists but the password is wrong. 0xC0000064 means the user name does not exist, a sign of guessing. 0xC0000234 means the account is locked out.
Other useful events: 4672 means special privileges (admin-level rights) were assigned at logon, and 4648 means someone used explicit credentials, as with runas.
- Many 4625 type 3 or 10 from one IP: password guessing
- 4625 with 0xC0000064 for many names: username spraying
- 4740: account locked out
Process, service and tamper events
Event 4688 records a new process, with its parent. It is off by default: enable Audit Process Creation, and turn on "Include command line in process creation events" so you see the arguments too. Without the command line, powershell.exe tells you little; with it, you can see a hidden encoded command.
Attackers often install services for persistence or remote execution. Event 7045 in the System log records a new service, with its file path, and 4697 is the Security log version when that auditing is on. Event 4698 records a new scheduled task. For PowerShell, enable Script Block Logging: event 4104 in the PowerShell Operational channel then stores the code that ran, even after it was decoded.
Watch for tampering too. Event 1102 means the Security log was cleared, which honest admins rarely do.
- 4688: process created (enable auditing + command line)
- 7045 / 4697: service installed
- 4698: scheduled task created
- 4104: PowerShell script block
- 1102: Security log cleared
What Sysmon adds and how to install it
Sysmon is a free Sysinternals tool that runs as a service and writes to the Microsoft-Windows-Sysmon/Operational channel. Event 1 (process create) includes the full command line, the parent process and file hashes. Event 3 links network connections to the program that made them. Event 11 records file creation, 13 registry value changes, 22 DNS queries, and 10 a process opening another process, such as a tool reading LSASS (the process that holds sign-in secrets) memory.
Sysmon logs nothing useful without a good config, because logging everything is far too noisy. Start from a community config such as SwiftOnSecurity's sysmon-config or Olaf Hartong's sysmon-modular, which already filter out common noise. Install with sysmon64.exe -accepteula -i config.xml and update the config later with sysmon64.exe -c config.xml.
Test in a lab first and watch the event volume before rolling it out.
- Logons and account changes
- 4688 process start, if enabled
- No network-to-process link
- Configured by audit policy
- Process start with hashes (ID 1)
- Network connection per process (ID 3)
- File, registry and DNS events
- Configured by an XML file
Querying events with PowerShell
Get-WinEvent is the modern cmdlet. Always filter at the source with -FilterHashtable, which is much faster than reading everything and piping to Where-Object. You can filter by LogName, Id, ProviderName, StartTime and EndTime.
The fields you want, such as TargetUserName or IpAddress, are inside the event's XML. Convert each event with [xml]$event.ToXml() and read Event.EventData.Data, which is a list of Name and value pairs. This works the same for every event ID, so you can reuse the pattern.
Remember that the Security log has a size limit (often only 20 MB by default) and old events are overwritten. On a busy server that may be just a few hours. Forward events to a central collector or SIEM so evidence survives, and raise the log size on important machines.
- Reading the Security log needs an elevated PowerShell
- wevtutil qe Security /c:5 /rd:true /f:text shows the 5 newest events
- Use -MaxEvents to keep test queries fast
Learn it in 4 short steps
About 45m each. Track them with a timer in your plan.
- 1Navigate Event Viewer channels~45m
- 2Know key event IDs like 4624 and 4688~45m
- 3Install Sysmon with a community config~45m
- 4Query events with PowerShell~45m
Key points
- 4624 is a successful logon, 4625 a failed one.
- 4688 records process creation, useful for spotting malware.
- Sysmon adds process, network and file telemetry.
- PowerShell can query the event logs for analysis.
Key terms
Tap a card to flip it. 0/4 known
Examples
Who is failing to log in, and from where?
Step 1: query 4625 events from the last 24 hours. Step 2: turn each event's XML data into named fields. Step 3: group by source IP and user. Step 4: read the result: hundreds of failures from one external IP against many different user names is password spraying. Step 5: check for a 4624 from the same IP afterwards. If there is one, that account is likely compromised: reset it, and review its activity.
$f = @{LogName='Security'; Id=4625; StartTime=(Get-Date).AddDays(-1)}
Get-WinEvent -FilterHashtable $f | ForEach-Object {
$d = @{}
([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }
[pscustomobject]@{ Ip = $d.IpAddress; User = $d.TargetUserName; Type = $d.LogonType }
} | Group-Object Ip | Sort-Object Count -Descending |
Select-Object -First 10 Count, NameSpotting a suspicious new service
Step 1: list 7045 events from the System log for the last week. Step 2: look at the service file path. Normal services run from C:\Program Files or C:\Windows\System32. Step 3: a service named something random, running a file from C:\Users\Public or a temp folder, or running cmd.exe or powershell.exe with arguments, is a red flag. Step 4: check the time against 4624 logons to see which account was signed in, and get the file's hash from Sysmon event 1 to look it up.
Get-WinEvent -FilterHashtable @{LogName='System'; Id=7045; StartTime=(Get-Date).AddDays(-7)} |
ForEach-Object {
$d = @{}
([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }
[pscustomobject]@{ Time = $_.TimeCreated; Name = $d.ServiceName; Path = $d.ImagePath }
} | Format-Table -AutoSizeQuick reference
- 4624 logon success, 4625 failure, 4634 logoff, 4672 admin-level logon
- Logon types: 2 keyboard, 3 network, 5 service, 10 RDP, 11 cached
- 4625 status 0xC000006A wrong password; 0xC0000064 no such user
- 4688 needs Audit Process Creation plus the command-line setting
- 7045 (System) new service; 4698 new scheduled task; 1102 log cleared
- Sysmon: 1 process, 3 network, 11 file create, 22 DNS, 10 process access
- Get-WinEvent -FilterHashtable is far faster than Where-Object filtering
- Install Sysmon: sysmon64.exe -accepteula -i config.xml; update with -c
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
On your own Windows PC, find your 5 most recent successful logons and note their logon types.
- Exercise 2medium
In a lab VM, install Sysmon with a community config, run ping example.com and find the matching Sysmon process and DNS events.
- Exercise 3hard
Write a script that finds IPs with 10 or more failed logons followed by at least one successful logon in the last 24 hours.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Where are Windows event logs stored on disk?
- As .evtx files in C:\Windows\System32\winevt\Logs. You can copy them for analysis and open them in Event Viewer or with Get-WinEvent -Path.
- Is Sysmon free and safe to use in production?
- Yes, it is a free Microsoft Sysinternals tool used widely in production. The main risk is too much event volume, so start with a tuned community config and test first.
- Why do I not see event 4688 at all?
- Process creation auditing is off by default. Enable Audit Process Creation under Advanced Audit Policy, through Group Policy or auditpol.
- What is the difference between 4624 and 4672?
- 4624 says a logon succeeded. 4672 appears alongside it when that logon received special, admin-level privileges, so it helps you spot admin sign-ins.