Author: Andrew Rathbun
Description: The handle to an object was closed
EventId: 4658
Channel: Security
Provider: Microsoft-Windows-Security-Auditing
Maps:
  -
    Property: UserName
    PropertyValue: "%domain%\\%user%"
    Values:
      -
        Name: domain
        Value: "/Event/EventData/Data[@Name=\"SubjectDomainName\"]"
      -
        Name: user
        Value: "/Event/EventData/Data[@Name=\"SubjectUserName\"]"
  -
    Property: ExecutableInfo
    PropertyValue: "%ProcessName% (PID: %ProcessId%)"
    Values:
      -
        Name: ProcessName
        Value: "/Event/EventData/Data[@Name=\"ProcessName\"]"
      -
        Name: ProcessId
        Value: "/Event/EventData/Data[@Name=\"ProcessId\"]"
  -
    Property: PayloadData1
    PropertyValue: "SID: %SubjectUserSid%"
    Values:
      -
        Name: SubjectUserSid
        Value: "/Event/EventData/Data[@Name=\"SubjectUserSid\"]"
  -
    Property: PayloadData2
    PropertyValue: "ObjectServer: %ObjectServer%"
    Values:
      -
        Name: ObjectServer
        Value: "/Event/EventData/Data[@Name=\"ObjectServer\"]"
  -
    Property: PayloadData3
    PropertyValue: "HandleId: %HandleId%"
    Values:
      -
        Name: HandleId
        Value: "/Event/EventData/Data[@Name=\"HandleId\"]"

# Documentation:
# https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=4658
# https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4658
# https://github.com/nasbench/EVTX-ETW-Resources/blob/main/ETWProvidersCSVs/Internal/Microsoft-Windows-Security-Auditing.csv
#
# Example Event Data:
# <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
# <System>
# <Provider Name="Microsoft-Windows-Security-Auditing" Guid="{54849625-5478-4994-A5BA-3E3B0328C30D}" />
# <EventID>4658</EventID>
# <Version>0</Version>
# <Level>0</Level>
# <Task>12800</Task>
# <Opcode>0</Opcode>
# <Keywords>0x8020000000000000</Keywords>
# <TimeCreated SystemTime="2015-09-22T00:15:42.910428100Z" />
# <EventRecordID>276724</EventRecordID>
# <Correlation />
# <Execution ProcessID="4" ThreadID="5056" />
# <Channel>Security</Channel>
# <Computer>DC01.contoso.local</Computer>
# <Security />
# </System>
# <EventData>
# <Data Name="SubjectUserSid">S-1-5-21-3457937927-2839227994-823803824-1104</Data>
# <Data Name="SubjectUserName">dadmin</Data>
# <Data Name="SubjectDomainName">CONTOSO</Data>
# <Data Name="SubjectLogonId">0x4367b</Data>
# <Data Name="ObjectServer">Security</Data>
# <Data Name="HandleId">0x18a8</Data>
# <Data Name="ProcessId">0xef0</Data>
# <Data Name="ProcessName">C:\\Windows\\explorer.exe</Data>
# </EventData>
# </Event>
