sysmon-modular- A Sysmon configuration repository for everybody to customise.
System Monitor (Sysmon) is a Windows system service and device driver that, once installed on a system, remains resident across system reboots to monitor and log system activity to the Windows event log. It provides detailed information about process creations, network connections, and changes to file creation time.
By collecting the events it generates using Windows Event Collection or SIEM agents and subsequently analyzing them, you can identify malicious or anomalous activity and understand how intruders and malware operate on your network.
Overview of Sysmon Capabilities as follow
- Logs process creation with full command line for both current and parent processes.
- Records the hash of process image files using SHA1 (the default), MD5, SHA256 or IMPHASH.
- Multiple hashes can be used at the same time.
- Includes a process GUID in process create events to allow for correlation of events even when Windows reuses process IDs.
- Includes a session GUID in each event to allow correlation of events on same logon session.
- Logs loading of drivers or DLLs with their signatures and hashes.
- Logs opens for raw read access of disks and volumes.
- Optionally logs network connections, including each connection’s source process, IP addresses, port numbers, hostnames and port names.
- Detects changes in file creation time to understand when a file was really created. Modification of file create timestamps is a technique commonly used by malware to cover its tracks.
- Automatically reload configuration if changed in the registry.
- Rule filtering to include or exclude certain events dynamically.
- Generates events from early in the boot process to capture activity made by even sophisticated kernel-mode malware.
- -i Install service and driver. Optionally take a configuration file.
- -c Update configuration of an installed Sysmon driver or dump the current configuration if no other argument is provided. Optionally take a configuration file.
- -m Install the event manifest (done on service install as well).
- -s Print configuration schema definition.
- -u Uninstall service and driver. Adding force causes uninstall to proceed even when some components are not installed.
Install with default settings (process images hashed with sha1 and no network monitoring)
sysmon -accepteula -i
Install Sysmon with a configuration file (as described below)
sysmon -accepteula -i c:\windows\config.xml
Dump the current configuration
Change the configuration of sysmon with a configuration file (as described below)
sysmon -c c:\windows\config.xml
Change the configuration to default settings
sysmon -c —
Show the configuration schema:
This is a Microsoft Sysinternals Sysmon download here configuration repository, set up modular for easier maintenance and generation of specific configs.
The sysmonconfig.xml within the repo is automatically generated after a successful merge by the PowerShell script and a successful load by Sysmon in an Azure Pipeline run.
An overview of all improvements
- Empty strings are replaced with “-“ to work around a WEF bug
- Adds DnsLookup configuration entry to support disabling of reverse DNS lookups
- Adds copy-on-delete support to preserve files specified by SID of deleting account, file extension, executables, or specific processes, including logic to preserve files that are shredded (overwritten before delete)
- Avoids hashing main data stream when it’s marked with FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS, which is used by cloud storage services like OneDrive and Dropbox
- Synchronously processes ProcessAccess events to ensure that it occurs before the responsible process terminates
- Sysmon now uses non-executable non-paged pool
- Several bug fixes addressing configuration parsing issues
I highly recommend looking at the configs before implementing them in your production environment. This enables you to have as actionable logging as possible and as litte noise as possible.
You will need to install and observe the results of the configuration in your own environment before deploying it widely. For example, you will need to exclude actions of your antivirus, which will otherwise likely fill up your logs with useless information.
Generating a config
$> git clone https://github.com/olafhartong/sysmon-modular.git
$> cd sysmon modular
$> . .\Merge-SysmonXml.ps1
$> Merge-AllSysmonXml -Path ( Get-ChildItem '[0-9]**.xml') -AsString | Out-File sysmonconfig.xml
Generating custom configs
Below functions with great thanks to mbmy
New Function: Find-RulesInBasePath – takes a base path (i.e. C:\folder\sysmon-modular) and finds all candidate xml rule files based upon regex pattern
Example: PS C:\Users\sysmon\sysmon-modular> Find-RulesInBasePath -BasePath C:\users\sysmon\sysmon-modular\ -OutputRules | Out-File available_rules.txt
Merge-AllSysmonXml New Parameters:
-BasePath – finds all candidate xml rule files from a provided path based upon regex pattern and merges them
Example: PS C:\Users\sysmon\sysmon-modular> Merge-AllSysmonXml -AsString -BasePath C:\Users\sysmon\sysmon-modular\
-ExcludeList – Combined with -BasePath, takes a list of rules and excludes them from found rules prior to merge
Example: PS C:\Users\sysmon\sysmon-modular> Merge-AllSysmonXml -AsString -BasePath C:\Users\sysmon\sysmon-modular\ -ExcludeList C:\users\sysmon\sysmon-modular\exclude_rules.txt
-IncludeList – Combined with -BasePath, finds all available rules from base path but only merges those defined in a list
Example: PS C:\Users\sysmon\sysmon-modular> Merge-AllSysmonXml -AsString -BasePath C:\Users\sysmon\sysmon-modular\ -IncludeList C:\users\sysmon\sysmon-modular\include_rules.txt
Include/Exclude List Format Example:
3_network_connection_initiated\include_native_windows_tools.xml 12_13_14_registry_event\exclude_internet_explorer_settings.xml 12_13_14_registry_event\exclude_webroot.xml 17_18_pipe_event\include_winreg.xml 19_20_21_wmi_event\include_wmi_create.xml 2_file_create_time\exclude_chrome.xml 3_network_connection_initiated\include_native_windows_tools.xml 3_network_connection_initiated\include_ports_proxies.xml 8_create_remote_thread\include_general_commment.xml 8_create_remote_thread\include_psinject.xml 9_raw_access_read\include_general_commment.xml
Run with administrator rights
sysmon.exe -accepteula -i sysmonconfig.xml
Update existing configuration
Run with administrator rights
sysmon.exe -c sysmonconfig.xml