Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsoft Protected Event Logging #41896

Open
PowerPress opened this issue Dec 4, 2024 · 1 comment
Open

Microsoft Protected Event Logging #41896

PowerPress opened this issue Dec 4, 2024 · 1 comment
Labels
needs_team Indicates that the issue/PR needs a Team:* label

Comments

@PowerPress
Copy link

PowerPress commented Dec 4, 2024

Microsoft Protected Event Logging is a feature that encrypts sensitive data written to event logs from Windows 10 and Windows Server 2016 and later.

This protects the data from attackers who might compromise a machine that has logged it.

This feature ideally when ingesting these logs would alert the ELK to process them using a certificate file ELK already has to decrypt them before being added to the logs.

Here is example code to do this in powershell I found online


#############################################################################
#.SYNOPSIS
# Decrypts protected event log messages with Unprotect-CmsMessage.
#
#.NOTES
# When piping encrypted event log messages through Unprotect-CmsMessage, 
# only the plaintext of the body of the message is returned, not the
# entire original message object with all of its properties, hence, a
# wrapper script like this is necessary to retain those other properties.
# The performance of Add-Member and Unprotect-CmsMessage is not good.
#############################################################################

[CmdletBinding()]
Param (
       [String] $ComputerName = $env:COMPUTERNAME, 
       [String] $LogName = 'Microsoft-Windows-PowerShell/Operational', 
       [Int] $EventID = 4104,
       [Int] $MaxEvents = 10
      )


$XPath = '*[System[(EventID=' + $EventID + ')]]'

Get-WinEvent -ComputerName $ComputerName -LogName $LogName -FilterXPath $XPath -MaxEvents $MaxEvents |
ForEach { 
    if ($_.Message.IndexOf('-----BEGIN CMS-----') -ne -1)
    { 
        Write-Verbose ("Encrypted: " + $_.RecordID)
        Add-Member -PassThru -InputObject $_ -NotePropertyName 'Plaintext' -NotePropertyValue $($_.Message | Unprotect-CmsMessage -IncludeContext) 
    }
    else
    {
        Write-Verbose ("Plaintext: " + $_.RecordID)
        $_
    }
}




@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 4, 2024
@botelastic
Copy link

botelastic bot commented Dec 4, 2024

This issue doesn't have a Team:<team> label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

No branches or pull requests

1 participant