0% found this document useful (0 votes)
120 views6 pages

Sysmon Installation and Uninstallation Guide

The document provides guidance on installing, upgrading, and uninstalling the Sysmon monitoring tool on Windows systems. It describes how to install Sysmon with a single executable and configuration file. Upgrading is not supported as the service must first be uninstalled. Uninstalling can sometimes fail, leaving registry keys and files behind. The document details the files and registry locations Sysmon affects and provides PowerShell scripts to check for leftover Sysmon components and manually remove them if uninstallation fails. This allows a clean reinstallation of Sysmon.

Uploaded by

Daniel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views6 pages

Sysmon Installation and Uninstallation Guide

The document provides guidance on installing, upgrading, and uninstalling the Sysmon monitoring tool on Windows systems. It describes how to install Sysmon with a single executable and configuration file. Upgrading is not supported as the service must first be uninstalled. Uninstalling can sometimes fail, leaving registry keys and files behind. The document details the files and registry locations Sysmon affects and provides PowerShell scripts to check for leftover Sysmon components and manually remove them if uninstallation fails. This allows a clean reinstallation of Sysmon.

Uploaded by

Daniel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Sysmon: How to install, upgrade,

and uninstall
2021-06-02

• Introduction
• Helpful Links
• Install
• Upgrade
• Uninstall
o The Problem
o The Investigation
o The Solution

Introduction
If you’re on this page you probably don’t need me to explain much about what
Sysmon is or why it is an excellent tool for security monitoring. In short:

• It’s part of Microsoft’s Sysinternals Suite


o So it should play nice with Windows
• It can monitor almost anything that happens on a Windows host
o So it can detect all the most common MITRE ATT&CKs
• It logs using Windows Event Logs
o So it’s easy to export to a SIEM etc for analysis
However, if you’ve tried rolling Sysmon out to a large number of machines, and
then removing or updating it, you may have experienced some issues. At least, I
did. So I’ve collated some of my findings.

At the time of writing Sysmon is on version 13.20.

Helpful Links
Main website: [Link]
us/sysinternals/downloads/sysmon
Sysmon
guide: [Link]
[Link]
Sysmon support: [Link]
[Link]

Install
This is the easy bit. Download [Link] from the main website, extract, then
run:
[Link] -i
If you have a config file you want to use:
[Link] -i <[Link]>
Done.

Upgrade
This is where it gets more complicated. You can’t upgrade:
The service Sysmon64 is already registered. Uninstall Sysmon before
reinstalling.

Uninstall
And even this isn’t simply. While Sysmon has a built-in uninstall action:
[Link] -u

The Problem
Except, sometimes it fails. And when it does, you’re kind of stuck. You can’t
reinstall Sysmon, as it claims Sysmon is already installed, but you also can’t
uninstall it by rerunning the command, as it says it’s not installed. Catch 22!

There is another option:


[Link] -u force
Although there is no documentation on exactly what it forces. See my forum
post: [Link]
[Link]
And it doesn’t seem to make much difference anyway.

The Investigation
This led me to further investigation. I ran several installs and uninstalls and took
snapshots using Regshot, an awesome tool that lets you do before-and-afters
for the filesystem and registry.
From this, I found Sysmon affects the following:
• C:\Windows\[Link]
• C:\Windows\[Link]
• HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64
• HKLM:\SYSTEM\CurrentControlSet\Services\SysmonDrv
• HKLM:\SYSTEM\ControlSet001\Services\Sysmon64
• HKLM:\SYSTEM\ControlSet001\Services\SysmonDrv
• HKLM:\SYSTEM\ControlSet002\Services\Sysmon64
• HKLM:\SYSTEM\ControlSet002\Services\SysmonDrv
• HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\Micros
oft-Windows-Sysmon/Operational
• HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{577
0385f-c22a-43e0-bf4c-06f5698ffbd9}
• HKLM:\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-
Microsoft-Windows-Sysmon-Operational
Other findings:
1. Even though it says Sysmon64 removed., uninstalling Sysmon
does not remove the [Link] file itself. This needs to be done
manually.
2. If it fails, often even a machine reboot won’t fix it. This is because
the Services\SysmonDrv registry keys, and [Link], still exist. When
the machine restarts, the service will start (note it’s not visible in Task
Manager or the Services manager). If you try to uninstall or reinstall, you
get the above “already exists” issue.
This means, if the [Link] -u fails, you’ll need to do some manual
intervention. This is the best I’ve found.

The Solution
First, I wrote a script to check the above files, to see what exists and what doesn’t.
In production I used a more complex one that feeds into our SIEM, but this is the
core of it:

$log_file = '[Link]'

$items = @(
"C:\Windows\[Link]",
"C:\Windows\[Link]",
"HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64",
"HKLM:\SYSTEM\CurrentControlSet\Services\SysmonDrv",
"HKLM:\SYSTEM\ControlSet001\Services\Sysmon64",
"HKLM:\SYSTEM\ControlSet001\Services\SysmonDrv",
"HKLM:\SYSTEM\ControlSet002\Services\Sysmon64",
"HKLM:\SYSTEM\ControlSet002\Services\SysmonDrv",

"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\Micros
oft-Windows-Sysmon/Operational",

"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{577
0385f-c22a-43e0-bf4c-06f5698ffbd9}",
"HKLM:\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-
Microsoft-Windows-Sysmon-Operational"
)

$services = @(
"Sysmon64",
"SysmonDrv"
)

foreach ( $i in $items ) {
If ( Test-Path $i ) {
$result = 'O'
} Else {
$result = 'X'
}
Write-Output "$result : $i".ToString() | Out-File -Filepath
$log_file -Append -NoClobber -Encoding UTF8
}

foreach ( $s in $services ) {
$status = (Get-Service $s -ErrorAction SilentlyContinue).Status
Write-Output "$status : $s".ToString() | Out-File -Filepath
$log_file -Append -NoClobber -Encoding UTF8
}
view rawsysmon-checks.ps1 hosted with ❤ by GitHub

I like to use O for success and X for fail, from my teaching in Korea days.
For a fresh install, the output is something like this:

O : C:\Windows\[Link]
O : C:\Windows\[Link]
O : HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64
O : HKLM:\SYSTEM\CurrentControlSet\Services\SysmonDrv
O : HKLM:\SYSTEM\ControlSet001\Services\Sysmon64
O : HKLM:\SYSTEM\ControlSet001\Services\SysmonDrv
X : HKLM:\SYSTEM\ControlSet002\Services\Sysmon64
X : HKLM:\SYSTEM\ControlSet002\Services\SysmonDrv
O : HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\Microsoft
-Windows-Sysmon/Operational
O : HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{577038
5f-c22a-43e0-bf4c-06f5698ffbd9}
O : HKLM:\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-Microsoft-
Windows-Sysmon-Operational
Running : Sysmon64
Running : SysmonDrv

However, a failed uninstall might look something like this:

O : C:\Windows\[Link]
O : C:\Windows\[Link]
X : HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64
O : HKLM:\SYSTEM\CurrentControlSet\Services\SysmonDrv
X : HKLM:\SYSTEM\ControlSet001\Services\Sysmon64
O : HKLM:\SYSTEM\ControlSet001\Services\SysmonDrv
X : HKLM:\SYSTEM\ControlSet002\Services\Sysmon64
O : HKLM:\SYSTEM\ControlSet002\Services\SysmonDrv
X : HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\Microsoft
-Windows-Sysmon/Operational
X : HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{577038
5f-c22a-43e0-bf4c-06f5698ffbd9}
X : HKLM:\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-Microsoft-
Windows-Sysmon-Operational
: Sysmon64
Running : SysmonDrv
The executable is there, but the service relating to it doesn’t exist. Yet the driver
is still up and running. If you try to stop the driver manually after a failed -
u uninstall, it often doesn’t - you get a Stopping the service failed error, or it just
hangs at Stopping.
There is a solution, however. If the registry keys relating to the service don’t exist,
then, on the next reboot, the service doesn’t exist either. Hence, it doesn’t start
(and therefore doesn’t need stopping), so you can delete [Link] and
you’re good to go!
To make this easier - yeah, another PowerShell script, with error logging:

$log_file = '[Link]'

$items = @(
"HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64",
"HKLM:\SYSTEM\CurrentControlSet\Services\SysmonDrv",
"HKLM:\SYSTEM\ControlSet001\Services\Sysmon64",
"HKLM:\SYSTEM\ControlSet001\Services\SysmonDrv",
"HKLM:\SYSTEM\ControlSet002\Services\Sysmon64",
"HKLM:\SYSTEM\ControlSet002\Services\SysmonDrv",

"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\Micros
oft-Windows-Sysmon/Operational",

"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{577
0385f-c22a-43e0-bf4c-06f5698ffbd9}",
"HKLM:\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-
Microsoft-Windows-Sysmon-Operational"
)

foreach ( $i in $items ) {
$[Link]();
Remove-Item -Path $i -Force -Recurse -ErrorAction SilentlyContinue
If($error) {
$result = $[Link]
} Else {
$result = "O : $i"
}
Write-Output "$result".ToString() | Out-File -Filepath $log_file -
Append -NoClobber -Encoding UTF8
}
view rawsysmon-reg-keys-deleter hosted with ❤ by GitHub

The output from my clean install above was (note O means successfully deleted):
O : HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64
O : HKLM:\SYSTEM\CurrentControlSet\Services\SysmonDrv
Cannot find path 'HKLM:\SYSTEM\ControlSet001\Services\Sysmon64' because it do
es not exist.
Cannot find path 'HKLM:\SYSTEM\ControlSet001\Services\SysmonDrv' because it d
oes not exist.
Cannot find path 'HKLM:\SYSTEM\ControlSet002\Services\Sysmon64' because it do
es not exist.
Cannot find path 'HKLM:\SYSTEM\ControlSet002\Services\SysmonDrv' because it d
oes not exist.
O : HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\Microsoft
-Windows-Sysmon/Operational
O : HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{577038
5f-c22a-43e0-bf4c-06f5698ffbd9}
O : HKLM:\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-Microsoft-
Windows-Sysmon-Operational

Then, after a reboot, you can


delete C:\Windows\[Link] (and C:\Windows\[Link] if you haven’t
already). If you run sysmon-checks.ps1 again you’ll get this:
X : C:\Windows\[Link]
X : C:\Windows\[Link]
X : HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64
X : HKLM:\SYSTEM\CurrentControlSet\Services\SysmonDrv
X : HKLM:\SYSTEM\ControlSet001\Services\Sysmon64
X : HKLM:\SYSTEM\ControlSet001\Services\SysmonDrv
X : HKLM:\SYSTEM\ControlSet002\Services\Sysmon64
X : HKLM:\SYSTEM\ControlSet002\Services\SysmonDrv
X : HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Channels\Microsoft
-Windows-Sysmon/Operational
X : HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WINEVT\Publishers\{577038
5f-c22a-43e0-bf4c-06f5698ffbd9}
X : HKLM:\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-Microsoft-
Windows-Sysmon-Operational
: Sysmon64
: SysmonDrv

And then you can install as normal!

Common questions

Powered by AI

When troubleshooting an incomplete Sysmon uninstall, it is crucial to check the registry keys and files related to the Sysmon service. These include 'C:\Windows\Sysmon64.exe', 'HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64', and several related services and channels within the registry like 'HKLM:\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-Microsoft-Windows-Sysmon-Operational'. Checking and potentially removing these ensures that the service will not start upon reboot, facilitating clean reinstallation .

If Sysmon's automated uninstall options fail, manual interventions include using PowerShell scripts to verify the presence of and then remove Sysmon-related files and registry entries manually. The files to check include 'C:\Windows\Sysmon64.exe' and 'C:\Windows\SysmonDrv.sys'. Key registry paths such as 'HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64' should be examined and deleted. These actions ensure that no remnants of Sysmon remain, allowing for a complete uninstallation and avoiding issues during future installs .

The output of a failed Sysmon uninstall includes indications such as the presence of Sysmon executables and drivers like 'C:\Windows\Sysmon64.exe' and 'SysmonDrv.sys' while lacking active service entries like 'HKLM:\SYSTEM\CurrentControlSet\Services\Sysmon64'. This output helps in troubleshooting by clearly showing which components remain and which are missing. It guides the administrator in knowing what needs to be removed manually to resolve issues, thus facilitating a more targeted approach to uninstallation and cleaning up system resources .

Sysmon's verbose logging capability significantly enhances its utility for security monitoring by providing detailed logs of almost every event occurring on a Windows host. These logs, generated through Windows Event Logs, are crucial for detecting common MITRE ATT&CK techniques and provide comprehensive data that can be exported to and analyzed in a Security Information and Event Management (SIEM) system. This depth of monitoring allows for effective identification and response to potential security threats, making it an excellent tool for security operations in Windows environments .

A reboot may not resolve issues related to a failed Sysmon uninstall because the Sysmon service components, like 'SysmonDrv.sys', and associated registry keys may still persist, causing the service to run upon reboot unnoticed. Post-reboot, manual intervention involving scripts or commands to remove or reconfigure the services and registry entries is necessary. This approach ensures the residual service components do not interfere with subsequent installs or system operations .

Upgrading Sysmon can be problematic because the service Sysmon64 is already registered, and thus, a direct upgrade isn't possible. The user must uninstall before reinstalling, which is not straightforward. If the uninstall command 'Sysmon64.exe -u' fails, it creates a situation where Sysmon can't be reinstalled because it's seen as both installed and not installed. To address this, a manual intervention is necessary, including using the 'Sysmon64.exe -u force' command and removing leftover files and registry keys. Running scripts that check and remove these files and registry entries is recommended to resolve the "already exists" issues .

Using a script for Sysmon uninstallation in a production environment provides several benefits over manual uninstallation. It offers consistency and repeatability across multiple systems, reducing human error and ensuring that all relevant files and registry entries are properly checked and removed. Additionally, scripts can be integrated into larger system management routines or SIEM integrations, providing automation that saves time and resources. This approach enhances reliability and efficiency, particularly important in large-scale deployments where manual efforts may be impractical .

The proposed strategy for handling failed Sysmon uninstalls involves the use of PowerShell scripts to check the presence of specific Sysmon files and registry entries and remove them if necessary. Key components include listing known files and registry paths used by Sysmon, verifying their existence, and using commands to forcefully remove them. This approach ensures that upon reboot, there is no record of Sysmon, thereby avoiding installation conflicts and allowing a fresh installation .

PowerShell scripting plays a crucial role in resolving Sysmon installation and uninstallation issues by automating the detection and removal of Sysmon files and registry entries that may not be correctly handled by Sysmon's built-in commands. Scripts can log and notify about the existent components and execute clean-up commands without manual intervention. This capability is essential for admins managing multiple systems, as it simplifies the process, ensures thoroughness, and can be tailored to report results directly into a SIEM, further enhancing system monitoring and problem resolution workflows .

Sysmon contributes to effective incident response practices by providing detailed event logging, critical for tracing the activities on a machine during an incident. Its ability to log comprehensive data on process creations, network connections, and file modifications can help in identifying breach vectors or malicious activities. Moreover, Sysmon logs are compatible with SIEM systems, enabling the correlation of data to spot patterns and respond to incidents quickly. This capability is essential in analyzing and understanding the full scope of a cybersecurity incident .

You might also like