Author: Mark Hallman mark.hallman@gmail.com
Description: A service was installed on the system
EventId: 4697
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: PayloadData1
    PropertyValue: "ServiceName: %ServiceName%"
    Values:
      -
        Name: ServiceName
        Value: "/Event/EventData/Data[@Name=\"ServiceName\"]"
  -
    Property: PayloadData2
    PropertyValue: "ServiceFileName: %ServiceFileName%"
    Values:
      -
        Name: ServiceFileName
        Value: "/Event/EventData/Data[@Name=\"ServiceFileName\"]"
  -
    Property: PayloadData3
    PropertyValue: "ServiceType: %ServiceType%"
    Values:
      -
        Name: ServiceType
        Value: "/Event/EventData/Data[@Name=\"ServiceType\"]"
  -
    Property: PayloadData4
    PropertyValue: "ServiceStartType: %ServiceStartType%"
    Values:
      -
        Name: ServiceStartType
        Value: "/Event/EventData/Data[@Name=\"ServiceStartType\"]"
  -
    Property: PayloadData5
    PropertyValue: "ServiceAccount: %ServiceAccount%"
    Values:
      -
        Name: ServiceAccount
        Value: "/Event/EventData/Data[@Name=\"ServiceAccount\"]"

Lookups:
  -
    Name: ServiceType
    Default: Unknown code
    Values:
      0x1: Kernel Driver
      0x2: File System Driver
      0x8: Recognizer Driver
      0x10: Win32 Own Process
      0x20: Win32 Share Process
      0x110: Interactive Own Process
      0x120: Interactive Share Process
  -
    Name: ServiceStartType
    Default: Unknown code
    Values:
      0: Boot
      1: System
      2: Automatic
      3: Manual
      4: Disabled

# Documentation:
# https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=4697
# https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4697
# https://github.com/nasbench/EVTX-ETW-Resources/blob/main/ETWProvidersCSVs/Internal/Microsoft-Windows-Security-Auditing.csv
# https://www.socinvestigation.com/threat-hunting-using-windows-security-log/
#
# 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>4697</EventID>
# <Version>0</Version>
# <Level>0</Level>
# <Task>12289</Task>
# <Opcode>0</Opcode>
# <Keywords>0x8020000000000000</Keywords>
# <TimeCreated SystemTime="2015-11-12T01:36:11.991070500Z" />
# <EventRecordID>2778</EventRecordID>
# <Correlation ActivityID="{913FBE70-1CE6-0000-67BF-3F91E61CD101}" />
# <Execution ProcessID="736" ThreadID="2800" />
# <Channel>Security</Channel>
# <Computer>WIN-GG82ULGC9GO.contoso.local</Computer>
# <Security />
# </System>
# <EventData>
# <Data Name="SubjectUserSid">S-1-5-18</Data>
# <Data Name="SubjectUserName">WIN-GG82ULGC9GO$</Data>
# <Data Name="SubjectDomainName">CONTOSO</Data>
# <Data Name="SubjectLogonId">0x3e7</Data>
# <Data Name="ServiceName">AppHostSvc</Data>
# <Data Name="ServiceFileName">%windir%\\system32\\svchost.exe -k apphost</Data>
# <Data Name="ServiceType">0x20</Data>
# <Data Name="ServiceStartType">2</Data>
# <Data Name="ServiceAccount">localSystem</Data>
# </EventData>
# </Event>
