Performance Monitoring and Event Viewer
Windows event logs are a detection engineer's primary data source. Understanding how the logging infrastructure works — what channels exist, how events get there, what an attacker can do to interfere — is prerequisite knowledge for building detection that is actually reliable.
An incident responder reviewing logs after a breach notices something odd: the Security event log shows Event ID 1102 (audit log cleared) at 02:47 AM. Everything before that timestamp is gone from the Security log. The attacker had ~4 hours of dwell time and cleared the log before exiting to cover their tracks.
What the attacker didn't know: the organization was forwarding all Security events to a SIEM within 60 seconds of generation. The SIEM had everything the attacker thought they'd erased. The 1102 event itself told the responder exactly when the attacker decided to clean up, which correlated to the final lateral movement activity. The lesson: logs matter only if they're collected somewhere the attacker can't reach. This chapter explains how Windows event logging works, which events matter most, and how attackers interfere with logging — so you know what the gaps are.
The Event Log Architecture
Windows event logging is built around the ETW (Event Tracing for Windows) infrastructure. Applications, drivers, and the kernel generate events by calling ETW APIs. The Windows Event Log service reads from ETW and writes structured events to .evtx files on disk. Event Viewer and the wevtutil tool are the built-in consumers.
Windows Event Logging Architecture
══════════════════════════════════════════════════════════════════════
Event Sources:
┌─────────────┐ ┌─────────────┐ ┌──────────────┐ ┌───────────┐
│ Kernel │ │ Services │ │ User apps │ │ Audit │
│ (nt/hal) │ │ (svchost) │ │ (.exe) │ │ Policy │
└──────┬──────┘ └──────┬──────┘ └──────┬───────┘ └─────┬─────┘
│ │ │ │
└────────────────┴────────────────┴──────────────────┘
│
ETW (Event Tracing for Windows)
Providers register with ETW;
events written to ETW buffers
│
▼
┌──────────────────────────────┐
│ Windows Event Log Service │
│ (EventLog / wevtsvc) │
│ │
│ Subscribes to ETW providers │
│ Writes to .evtx files │
└────────────┬─────────────────┘
│
┌───────────────────┼───────────────────┐
▼ ▼ ▼
Security.evtx System.evtx Application.evtx
(auth, audit) (OS, drivers) (app errors)
+
many channel-specific .evtx files:
Microsoft-Windows-PowerShell/Operational.evtx
Microsoft-Windows-Sysmon/Operational.evtx
Microsoft-Windows-WMI-Activity/Operational.evtx
Microsoft-Windows-TerminalServices-*/Operational.evtx
...and hundreds more
Default location: C:\Windows\System32\winevt\Logs\
Critical Event IDs for Detection
Of the hundreds of event IDs that Windows can generate, a small set covers the majority of attacker techniques. These are the events every detection engineer should know by memory.
| Event ID | Channel | What It Records | Why Attackers Care |
|---|---|---|---|
| 4624 | Security | Successful logon. Logon type field is critical: 2=interactive, 3=network, 4=batch, 5=service, 7=unlock, 9=runAs, 10=RDP, 11=cached | Logon type 3 (network) with unusual accounts = lateral movement. Logon type 10 = RDP. Missing 4624 where expected = attacker cleared logs. |
| 4625 | Security | Failed logon. Failure code shows why: 0xC000006A = wrong password, 0xC0000064 = bad username, 0xC000006D = bad credentials | Brute force shows as rapid 4625s. Password spray shows many 4625s across many accounts with same timestamp spread. |
| 4648 | Security | Logon attempt with explicit credentials (RunAs, alternative credentials). Logs: who initiated it, what account was used, what process. | Lateral movement: attacker logs in as user A and then uses explicit creds for user B. 4648 shows the credential switch. |
| 4688 | Security | Process creation. With command line auditing enabled: full command line arguments included. Parent process name included. | Shows cmd.exe spawning from Word.exe, PowerShell with -enc arguments, net.exe user additions, etc. |
| 4698/4702 | Security | 4698: Scheduled task created. 4702: Scheduled task modified. Both include task XML with the full action definition. | Scheduled tasks are a persistence mechanism. 4698 fires when the attacker installs their task for reboot persistence. |
| 4720/4728/4732 | Security | 4720: User account created. 4728: Member added to global group. 4732: Member added to local group. | Persistence via account creation. Privilege escalation via group membership changes. |
| 4768/4769/4771 | Security (DC only) | 4768: TGT requested (Kerberos pre-auth). 4769: Service ticket requested. 4771: Pre-auth failed. | Kerberoasting: bulk 4769s for service accounts from one source. AS-REP roasting: 4768 with pre-auth disabled accounts. |
| 4776 | Security | NTLM authentication attempt. Includes account name, workstation name, error code. | NTLM relay detection: 4776 on unexpected hosts. Pass-the-hash: NTLM auth from unusual source/time. |
| 1102 | Security | Security audit log cleared. Includes who cleared it and timestamp. | Attacker covering tracks. Ironically, this event fires before the log is cleared, so the 1102 itself is preserved in SIEM. |
| 4104 | PS/Operational | PowerShell Script Block Logging. Full decoded script text. | See Chapter 7. The most important PowerShell detection event. |
| 7045 | System | New service installed. Includes service name, path, start type, account. | Service installation is a persistence and privilege escalation vector. Malicious drivers and services appear here. |
How Attackers Interfere with Logging
An attacker with administrative access can interfere with event logging in several ways. Each technique leaves a different evidence pattern, and understanding them tells you both what to detect and what log gaps to account for.
Log Tampering Techniques and Evidence
══════════════════════════════════════════════════════════════════════
TECHNIQUE 1: Clear the log
──────────────────────────
Command: wevtutil cl Security
Evidence: Event ID 1102 (Security) or 104 (System) fires
BEFORE the log is cleared — preserved in SIEM
Gap: Local copy of log gone; SIEM-forwarded events preserved
Detection: Alert on any 1102/104 outside of authorized maintenance
TECHNIQUE 2: Stop the Event Log service
─────────────────────────────────────────
Command: sc stop EventLog (requires SYSTEM/local admin)
Evidence: System log records service stop. If SIEM was collecting,
gap in event stream is visible.
Gap: Events generated while service is stopped are LOST permanently
Detection: Alert on sudden gap in event stream per host;
event log service stop events
TECHNIQUE 3: Disable specific audit policies
─────────────────────────────────────────────
Command: AuditPol.exe /set /subcategory:"Logon" /success:disable
Evidence: Policy change generates its own Security events (4719)
Gap: After disabling, that category no longer generates events
Detection: Monitor for 4719 (audit policy changes);
baseline expected audit policy and alert on drift
TECHNIQUE 4: Manipulate .evtx files directly
──────────────────────────────────────────────
Method: Open handle to .evtx file; delete specific records
Requires: stopping EventLog service or using special
APIs to corrupt records; or boot from external OS
Evidence: Corrupted .evtx shows in Event Viewer as "damaged log"
Gap: Targeted removal of specific events without clearing all
Detection: Hash-based integrity monitoring of .evtx files;
SIEM forwarding (events forwarded before manipulation)
TECHNIQUE 5: Patch ETW in memory
──────────────────────────────────
Method: Patch the EtwEventWrite function in ntdll.dll in process
memory to NOP out ETW calls — process-level ETW silencing
Evidence: Only affects that process's ETW output — other processes
still log normally
Gap: Malicious process can avoid generating ETW events for itself
Detection: Memory integrity monitoring; EDR behavioral detection;
absence of expected events for a running process
(e.g., process creates children but no 4104 events)
Windows Event Forwarding (WEF) pushes events from endpoints to a central Windows Event Collector (WEC) server. SIEM agents pull from the WEC. Once events leave the endpoint and arrive at the WEC, an attacker who owns the endpoint cannot delete them. The event's fate is determined at forwarding time, not log-clear time. This is why an attacker clearing the Security log after being forwarded to a SIEM loses nothing except the local copy. The SIEM already has the events. From the attacker's perspective, log clearing on an organization with centralized log collection is mostly cosmetic — it might slow a local responder without SIEM access, but it doesn't defeat central collection. The practical implication for detection engineers: the 1102 event (log cleared) tells you the attacker doesn't know you're forwarding logs. It's a tradecraft gap on their part, and it's worth alerting on.
Sysmon: Extending Windows Event Logging
Windows Defender events and native audit logging have gaps — process creation (4688) requires a policy change to include command lines, and many attack techniques leave no native events. Sysmon (System Monitor), a Sysinternals tool that installs as a kernel driver, fills these gaps with much richer telemetry.
| Sysmon Event | ID | What it captures that native logging misses |
|---|---|---|
| Process Create | 1 | Always includes full command line, user context, parent process, and MD5/SHA256 hash of the executable — no policy configuration needed. |
| Network Connection | 3 | Process-level network connections (which process connected to which IP:port). Native logging doesn't tie network connections to processes. |
| File Creation Time Changed | 2 | Timestomping detection — when a file's creation time is retroactively modified (a classic anti-forensics technique). |
| Driver/Image Load | 6/7 | DLL loads with hash and signature verification. Detects DLL hijacking and unsigned driver loading. |
| CreateRemoteThread | 8 | When one process creates a thread in another process — code injection signal. Detects process injection techniques. |
| File Stream Created | 15 | NTFS Alternate Data Stream creation — a hiding technique (see Chapter 3). Zone.Identifier tracking for downloaded files. |
| WMI Activity | 19/20/21 | WMI subscriptions (a persistence mechanism) that generate no native events. |
| DNS Query | 22 | Process-level DNS lookups with the resolved addresses. Detects C2 domain communication and DNS exfiltration. |
Performance Monitoring as a Security Signal
Performance Monitor (perfmon) tracks CPU, memory, disk, and network metrics. These aren't usually thought of as security data, but performance anomalies are a detection signal for several attack patterns.
| Performance Anomaly | Possible Security Meaning |
|---|---|
| Sustained high CPU on a server with no known workload | Cryptominer running. Coinminers are resource-intensive and show up as a process consuming unusual CPU. |
| Disk I/O spike across all drives simultaneously | Ransomware encryption. Ransomware reads every file, encrypts it, and writes back — generates extreme disk I/O across the volume. |
| Unusual sustained network throughput outbound | Data exfiltration. Large transfers to external IPs at unusual times of day. |
| Memory pressure caused by a non-production process | In-memory malware running large payloads. Some loaders reflectively load large DLLs or frameworks into memory. |
Think of Windows event logs the way you'd think of an append-only ledger. Events are written and never modified — only the entire log can be cleared (which generates its own event). This means that for any event that has already been written and forwarded to a SIEM, the attacker cannot retroactively remove just that event. They can clear the whole log (which itself creates evidence), stop the logging service going forward (creating a gap), or patch their own process's ETW output (preventing future events but not touching past ones). No Windows mechanism exists to surgically delete a specific event from a running log file without corrupting the entire log. This append-only model is why centralized log forwarding is the foundation of detection infrastructure — once the event leaves the endpoint, it's out of reach.
Q & A
1. An attacker has SYSTEM on a box and stops the Windows Event Log service. What evidence exists?
Multiple evidence sources survive. First: if the organization is forwarding logs centrally (WEF/SIEM), all events generated before the service stop were already transmitted and are preserved. Second: the service stop itself generates events — in the System log (Event 7036: service entered stopped state; Event 7040: start type changed) and potentially in the Security log. These events would have been forwarded before the service stopped. Third: if Sysmon is deployed as a separate kernel driver (it logs to a separate ETW channel, not through the Event Log service), Sysmon events may continue even after EventLog service stops — Sysmon's ring buffer persists and can be collected when the service restarts. Fourth: EDR agents typically have their own telemetry channels independent of the Windows Event Log service and are not affected by stopping EventLog. The practical impact: on an organization with a SIEM, stopping EventLog service creates a visible gap in the event stream (SIEM alerts on missing heartbeats or event gaps from that host) but doesn't delete historical events. The attacker has created more evidence, not less.
2. What is ETW patching and how does it differ from clearing the event log?
ETW patching is a technique where a process modifies its own memory to disable ETW event emission from within that process. The key distinction: it affects only the patching process, not the entire system. The Windows Event Log service runs in svchost.exe and writes events from all sources — patching ETW in your malicious process doesn't affect svchost.exe's ability to write events from other sources. What ETW patching does: it prevents the malicious process from emitting ETW events. If the malicious process was expected to generate events (e.g., it's a PowerShell session that should generate 4104 events), the absence of those events is itself detectable — the process exists (visible in process list) but generates no events. Compare to clearing the event log: log clearing is loud (generates 1102/104), affects the entire log (all events gone), and is permanent for local storage. ETW patching is quieter (no notification event), process-local (other events continue normally), and silences future events rather than deleting past ones. EDRs that hook the ETW write functions at the kernel level can detect ETW patching attempts.
3. Logon type 9 (NewCredentials) — when does it appear and why is it suspicious?
Logon type 9 (NewCredentials) is generated when a process is launched with
runas /netonly or when a script uses explicit credentials for network access
only. The key characteristic: the local session uses the original token, but outbound network
connections from that session use the specified credentials. This means the process appears
to run as the original user locally, but makes network connections as a different user.
Attackers use logon type 9 to use stolen credentials for lateral movement while running their
local session as the compromised user — the local access token doesn't change (so local
permission checks pass), but the network credentials are different. Detection signal: Event
4648 (explicit credential use) combined with Event 4624 with logon type 9 from an account
that doesn't normally use /netonly patterns. Legitimate use cases exist (domain-joined machines
accessing different domain resources), but logon type 9 at unusual times from non-admin
accounts, particularly combined with subsequent network authentication events, is worth
investigating.
4. What's the difference between Windows Event Forwarding (WEF) and a SIEM agent, and which is better?
Windows Event Forwarding (WEF) is a native Windows mechanism: endpoints push events to a Windows Event Collector (WEC) server using the WS-Management protocol over HTTP/HTTPS. No third-party software required; uses built-in Windows authentication. The WEC aggregates events; a SIEM agent on the WEC then ships to the SIEM. Advantages: native, no agent installation on endpoints, lower endpoint overhead, uses standard Windows protocols. Disadvantages: only forwards Windows events (not Sysmon binary data or other sources well); requires a WEC server; filtering is subscription-based (XPath queries). SIEM agents (Splunk Universal Forwarder, Elastic Agent, etc.) install on each endpoint and ship events directly to the SIEM. Advantages: can collect any data source (not just Windows events), richer filtering, supports real-time streaming, lower latency. Disadvantages: agent to install and maintain, additional endpoint resource usage, agent itself becomes an attack surface. In practice: large environments often use WEF for broad Windows event collection (cheap, scalable) plus Sysmon + SIEM agent on high-value targets (rich telemetry where it matters). The "better" answer depends on scale, budget, and what you're trying to collect.