<!--
=============================================================================
 Sysmon baseline — ENTROPY//WATCH

 Companion to:
   https://entropywatch.dev/articles/sysmon-without-drowning/
 License: MIT — ENTROPY//WATCH
 Version: 2026-10-20
 Schema 4.50 = Sysmon 13 or later. Written for current Sysmon 15; newer
 versions accept older schema versions.

 Philosophy: log every process start and the few event types that are rare
 and valuable; log the noisy types (network, file, registry) ONLY for an
 include list. Anything not listed is not logged.

 BEFORE YOU DEPLOY
   - ADAPT every block marked ADAPT: exclusions for your EDR, backup and
     monitoring agents, and the paths your software really uses.
   - Test on a few machines first and measure events per day per event ID:
       Get-WinEvent -LogName Microsoft-Windows-Sysmon/Operational |
         Group-Object Id | Sort-Object Count -Descending
   - Install:  sysmon64.exe -accepteula -i sysmon-baseline.xml
     Update:   sysmon64.exe -c sysmon-baseline.xml
     Show:     sysmon64.exe -c
=============================================================================
-->
<Sysmon schemaversion="4.50">
  <HashAlgorithms>SHA256,IMPHASH</HashAlgorithms>
  <CheckRevocation>False</CheckRevocation>
  <EventFiltering>

    <!-- Event 1: process creation. Log everything; exclude only proven noise. -->
    <RuleGroup name="ProcessCreate" groupRelation="or">
      <ProcessCreate onmatch="exclude">
        <!-- ADAPT: add high-frequency, known-good parents, e.g. your monitoring agent:
        <ParentImage condition="is">C:\Program Files\ExampleMonitor\agent.exe</ParentImage>
        -->
      </ProcessCreate>
    </RuleGroup>

    <!-- Event 3: network connections. Include only processes and ports that matter. -->
    <RuleGroup name="NetworkConnect" groupRelation="or">
      <NetworkConnect onmatch="include">
        <Image condition="end with">\powershell.exe</Image>
        <Image condition="end with">\pwsh.exe</Image>
        <Image condition="end with">\rundll32.exe</Image>
        <Image condition="end with">\regsvr32.exe</Image>
        <Image condition="end with">\mshta.exe</Image>
        <Image condition="end with">\certutil.exe</Image>
        <Image condition="end with">\bitsadmin.exe</Image>
        <Image condition="end with">\wscript.exe</Image>
        <Image condition="end with">\cscript.exe</Image>
        <Image condition="end with">\msbuild.exe</Image>
        <Image condition="end with">\installutil.exe</Image>
        <DestinationPort condition="is">22</DestinationPort>
        <DestinationPort condition="is">3389</DestinationPort>
        <DestinationPort condition="is">5985</DestinationPort>
        <DestinationPort condition="is">5986</DestinationPort>
      </NetworkConnect>
    </RuleGroup>

    <!-- Event 5: process terminated. Off. -->
    <RuleGroup name="ProcessTerminate" groupRelation="or">
      <ProcessTerminate onmatch="include" />
    </RuleGroup>

    <!-- Event 6: driver loaded. Log all except drivers signed by Microsoft Windows with a valid signature. -->
    <RuleGroup name="DriverLoad" groupRelation="or">
      <DriverLoad onmatch="exclude">
        <Rule name="MicrosoftSigned" groupRelation="and">
          <Signature condition="is">Microsoft Windows</Signature>
          <SignatureStatus condition="is">Valid</SignatureStatus>
        </Rule>
      </DriverLoad>
    </RuleGroup>

    <!-- Event 7: image (DLL) loaded. Off: very high volume. -->
    <RuleGroup name="ImageLoad" groupRelation="or">
      <ImageLoad onmatch="include" />
    </RuleGroup>

    <!-- Event 8: CreateRemoteThread. Log all; rare on most machines. -->
    <RuleGroup name="CreateRemoteThread" groupRelation="or">
      <CreateRemoteThread onmatch="exclude">
        <!-- ADAPT: exclude your EDR / AV if it shows up here constantly. -->
      </CreateRemoteThread>
    </RuleGroup>

    <!-- Event 9: raw disk read. Log all; expect backup and defrag tools. -->
    <RuleGroup name="RawAccessRead" groupRelation="or">
      <RawAccessRead onmatch="exclude">
        <!-- ADAPT: exclude your backup agent. -->
      </RawAccessRead>
    </RuleGroup>

    <!-- Event 10: process access. Only access to LSASS. -->
    <RuleGroup name="ProcessAccess" groupRelation="or">
      <ProcessAccess onmatch="include">
        <TargetImage condition="is">C:\Windows\System32\lsass.exe</TargetImage>
      </ProcessAccess>
    </RuleGroup>
    <RuleGroup name="ProcessAccessExclusions" groupRelation="or">
      <ProcessAccess onmatch="exclude">
        <!-- ADAPT: your EDR / AV reads LSASS all the time. Exclude it by full path:
        <SourceImage condition="is">C:\Program Files\ExampleEDR\sensor.exe</SourceImage>
        -->
      </ProcessAccess>
    </RuleGroup>

    <!-- Event 11: file created. Only persistence locations and executables in user-writable paths. -->
    <RuleGroup name="FileCreate" groupRelation="or">
      <FileCreate onmatch="include">
        <TargetFilename condition="contains">\Start Menu\Programs\Startup\</TargetFilename>
        <TargetFilename condition="begin with">C:\Windows\System32\Tasks\</TargetFilename>
        <TargetFilename condition="begin with">C:\Windows\Tasks\</TargetFilename>
        <Rule name="ExecutableInUserProfile" groupRelation="and">
          <TargetFilename condition="begin with">C:\Users\</TargetFilename>
          <TargetFilename condition="end with">.exe</TargetFilename>
        </Rule>
        <Rule name="ScriptInUserProfile" groupRelation="and">
          <TargetFilename condition="begin with">C:\Users\</TargetFilename>
          <TargetFilename condition="end with">.ps1</TargetFilename>
        </Rule>
      </FileCreate>
    </RuleGroup>

    <!-- Events 12/13/14: registry. Only autostart and service locations. -->
    <RuleGroup name="RegistryEvent" groupRelation="or">
      <RegistryEvent onmatch="include">
        <TargetObject condition="contains">\Software\Microsoft\Windows\CurrentVersion\Run</TargetObject>
        <TargetObject condition="contains">\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Run</TargetObject>
        <TargetObject condition="contains">\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\</TargetObject>
        <TargetObject condition="contains">\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\</TargetObject>
        <Rule name="ServiceImagePath" groupRelation="and">
          <TargetObject condition="contains">\CurrentControlSet\Services\</TargetObject>
          <TargetObject condition="end with">\ImagePath</TargetObject>
        </Rule>
      </RegistryEvent>
    </RuleGroup>

    <!-- Event 15: alternate data stream hash. Off. -->
    <RuleGroup name="FileCreateStreamHash" groupRelation="or">
      <FileCreateStreamHash onmatch="include" />
    </RuleGroup>

    <!-- Events 17/18: named pipes. Off. ADAPT: enable when you have a detection that needs it. -->
    <RuleGroup name="PipeEvent" groupRelation="or">
      <PipeEvent onmatch="include" />
    </RuleGroup>

    <!-- Events 19/20/21: WMI event subscriptions. Log all; rare and a known persistence method. -->
    <RuleGroup name="WmiEvent" groupRelation="or">
      <WmiEvent onmatch="exclude" />
    </RuleGroup>

    <!-- Event 22: DNS queries. Off by default: high volume.
         ADAPT: if your DNS servers do not log queries, consider enabling with an exclude list. -->
    <RuleGroup name="DnsQuery" groupRelation="or">
      <DnsQuery onmatch="include" />
    </RuleGroup>

    <!-- Event 23: file delete with archiving. Off: copies deleted files to disk. -->
    <RuleGroup name="FileDelete" groupRelation="or">
      <FileDelete onmatch="include" />
    </RuleGroup>

    <!-- Event 24: clipboard. Off: may capture sensitive data. -->
    <RuleGroup name="ClipboardChange" groupRelation="or">
      <ClipboardChange onmatch="include" />
    </RuleGroup>

    <!-- Event 25: process tampering (hollowing, herpaderping). Log all; rare. -->
    <RuleGroup name="ProcessTampering" groupRelation="or">
      <ProcessTampering onmatch="exclude" />
    </RuleGroup>

  </EventFiltering>
</Sysmon>
