Cyber Security · Advanced

Detecting Attacks with Windows Event Logs: The Event IDs to Monitor

Attackers often move around for days, leaving traces. We explain which Windows events to monitor, how to turn on auditing and how to query them with PowerShell.

SistemON Technical Team · · 5 min read

In short

  • Default Windows settings don’t record many of the events needed for attack detection; advanced audit policies must be turned on.
  • Priority events: failed sign-ins, privileged sign-ins, new services and tasks, group changes and the log being cleared.
  • Logs must be collected centrally; otherwise the attacker can erase their tracks.

The time from an attack’s initial entry to encryption is often days, even weeks. During that time the attacker leaves traces in the Windows event logs: failed sign-in attempts, newly created accounts, installed services, cleared logs… The problem is that these traces are either never recorded or never read by anyone. This article summarises for IT teams which events should be monitored and how to do it.

First, make sure events are being recorded

The default audit settings are inadequate. In Group Policy, under Computer Configuration › Windows Settings › Security Settings › Advanced Audit Policy Configuration, turn on at least the following:

  • Account Logon: Credential Validation, Kerberos Authentication Service, Kerberos Service Ticket Operations
  • Account Management: User Account Management, Security Group Management
  • Logon/Logoff: Logon, Account Lockout, Special Logon
  • Detailed Tracking: Process Creation (plus the “Include command line in process creation events” policy)
  • Object Access: Other Object Access Events (for scheduled tasks)
  • PowerShell: Script Block Logging

You can see the current state on a server with this command:

auditpol /get /category:*

Event IDs to monitor

EventLogWhat does it mean?When to be suspicious
4625SecurityFailed sign-inMany in a short time, especially logon type 3 (network) and 10 (remote desktop)
4624SecuritySuccessful sign-inStraight after many failed attempts; an unusual time or source
4740SecurityAccount locked outOn several accounts at once: password spraying
4672SecuritySign-in with special privilegesAn admin account signing in on an unexpected machine
4648SecuritySign-in with explicit credentialsConnecting from a user computer to servers with a different identity
4688SecurityNew process createdSuspicious command lines: encoded PowerShell, vssadmin delete shadows, wmic
4720SecurityUser account createdOut of hours or by an unknown admin
4728 / 4732 / 4756SecurityMember added to a security groupAdditions to privileged groups such as Domain Admins or Administrators
4697 / 7045Security / SystemNew service installedRandomly named services or ones running from a temp folder; remote management tools
4698SecurityScheduled task createdTasks created for persistence
4769Security (DC)Kerberos service ticket requestedMany from one user in a short time with encryption type 0x17 (RC4): Kerberoasting
4771Security (DC)Kerberos pre-authentication failedAcross many accounts: password guessing
4104PowerShell/OperationalPowerShell script blockEncoded commands, downloading scripts from the internet, disabling security tools
1102SecuritySecurity log clearedAlmost always: an attacker may be erasing their tracks

Quick PowerShell queries

Even without a central log solution, you can run a quick check on critical servers with these queries:

# Failed sign-ins in the last 24 hours: the most targeted accounts
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625; StartTime=(Get-Date).AddDays(-1)} |
  ForEach-Object { $_.Properties[5].Value } |
  Group-Object | Sort-Object Count -Descending | Select-Object -First 10 Count, Name

# Additions to privileged groups in the last 7 days
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4728,4732,4756; StartTime=(Get-Date).AddDays(-7)} |
  Select-Object TimeCreated, Id, Message

# New services installed in the last 7 days
Get-WinEvent -FilterHashtable @{LogName='System'; Id=7045; StartTime=(Get-Date).AddDays(-7)} |
  Select-Object TimeCreated, Message

# Has the security log been cleared?
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=1102} -ErrorAction SilentlyContinue

Note: the index of event properties (for example Properties[5]) varies by event type. Check the queries against a sample event in your own environment.

Warning signs specific to ransomware

  • Shadow copies being deleted (vssadmin delete shadows, wmic shadowcopy delete)
  • The recovery environment being disabled (boot settings changed with bcdedit)
  • Security software services being stopped or new exclusions being added
  • Backup services being stopped and backup catalogues being deleted
  • The same new service or scheduled task appearing on many servers in a short time

When any of these signs appears, time is critical: affected systems must be disconnected from the network and incident response steps started.

Collect and retain logs centrally

  1. Increase log size: on domain controllers and critical servers, the security log fills up within a few days at its default size.
  2. Central collection: with Windows Event Forwarding (WEF), you can forward events to a single collector server without extra licences; larger environments prefer a SIEM solution.
  3. Alert rules: set up instant notifications for 1102, privileged group changes and new service installations.
  4. Retention period: keeping records for at least a few months is recommended for incident investigation. For businesses that process personal data, access logs are also part of KVKK technical measures.
  5. Sysmon: add Sysmon with a well-tuned configuration for detail the built-in logs can’t see (network connections, process tree, file creation). See our Sysmon guide.

Conclusion

Event logs are the attacker’s footprints on your network, but they are only useful if they are recorded, collected and read. With the right audit policies, central collection and instant alerts for a few critical events, your chances of spotting an attack before encryption begins rise sharply. For measures on the Active Directory side, see our article on Active Directory hardening. At SistemON, as part of our cyber security service, we configure audit policies, collect logs centrally and set up alert rules for critical events.

Frequently Asked Questions

Should we review event logs on each server one by one?

No. Logs should be collected in a central location with Windows Event Forwarding (WEF) or a SIEM/log management solution. That makes review easier, and when an attacker clears the logs on one server, the copy stays safe.

How large should the security log be?

On most servers the default size fills up within a few days and old records are overwritten. On domain controllers and critical servers, increase the log size to hold at least a few weeks of records, and store them centrally.

What is Sysmon, and should we install it?

Sysmon is one of Microsoft’s Sysinternals tools; it records events such as process creation, network connections and file changes in far more detail than the built-in logs. Used with a well-tuned configuration file, it makes a serious difference to attack detection.

Need help with this?

Let us review your infrastructure free for the first month and share a clear list of risks and priorities.

Talk to an expert

First month free

Keep your systems ON.
Leave the rest to us.

Let us review your infrastructure free of charge for a month and walk you through the state of your backups, security and performance.

Chat with us