Author: Mike Pilkington
Description: A computer account was changed
EventId: 4742
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: "Target: %TargetDomainName%\\%TargetUserName%"
    Values:
      -
        Name: TargetDomainName
        Value: "/Event/EventData/Data[@Name=\"TargetDomainName\"]"
      -
        Name: TargetUserName
        Value: "/Event/EventData/Data[@Name=\"TargetUserName\"]"
  -
    Property: PayloadData2
    PropertyValue: "Changed Attribute SamAccountName: %SamAccountName% DisplayName: %DisplayName% UserPrincipalName: %UserPrincipalName% HomeDirectory: %HomeDirectory% HomePath: %HomePath% ScriptPath: %ScriptPath% ProfilePath: %ProfilePath% UserWorkstations: %UserWorkstations% PasswordLastSet: %PasswordLastSet% AccountExpires: %AccountExpires% PrimaryGroupId: %PrimaryGroupId% AllowedToDelegateTo: %AllowedToDelegateTo% OldUacValue: %OldUacValue% NewUacValue: %NewUacValue% UserAccountControl: %UserAccountControl% UserParameters: %UserParameters% SidHistory: %SidHistory% LogonHours: %LogonHours% DnsHostName: %DnsHostName% ServicePrincipalNames: %ServicePrincipalNames%"
    Values:
      -
        Name: SamAccountName
        Value: "/Event/EventData/Data[@Name=\"SamAccountName\"]"
      -
        Name: DisplayName
        Value: "/Event/EventData/Data[@Name=\"DisplayName\"]"
      -
        Name: UserPrincipalName
        Value: "/Event/EventData/Data[@Name=\"UserPrincipalName\"]"
      -
        Name: HomeDirectory
        Value: "/Event/EventData/Data[@Name=\"HomeDirectory\"]"
      -
        Name: HomePath
        Value: "/Event/EventData/Data[@Name=\"HomePath\"]"
      -
        Name: ScriptPath
        Value: "/Event/EventData/Data[@Name=\"ScriptPath\"]"
      -
        Name: ProfilePath
        Value: "/Event/EventData/Data[@Name=\"ProfilePath\"]"
      -
        Name: UserWorkstations
        Value: "/Event/EventData/Data[@Name=\"UserWorkstations\"]"
      -
        Name: PasswordLastSet
        Value: "/Event/EventData/Data[@Name=\"PasswordLastSet\"]"
      -
        Name: AccountExpires
        Value: "/Event/EventData/Data[@Name=\"AccountExpires\"]"
      -
        Name: PrimaryGroupId
        Value: "/Event/EventData/Data[@Name=\"PrimaryGroupId\"]"
      -
        Name: AllowedToDelegateTo
        Value: "/Event/EventData/Data[@Name=\"AllowedToDelegateTo\"]"
      -
        Name: OldUacValue
        Value: "/Event/EventData/Data[@Name=\"OldUacValue\"]"
      -
        Name: NewUacValue
        Value: "/Event/EventData/Data[@Name=\"NewUacValue\"]"
      -
        Name: UserAccountControl
        Value: "/Event/EventData/Data[@Name=\"UserAccountControl\"]"
      -
        Name: UserParameters
        Value: "/Event/EventData/Data[@Name=\"UserParameters\"]"
      -
        Name: SidHistory
        Value: "/Event/EventData/Data[@Name=\"SidHistory\"]"
      -
        Name: LogonHours
        Value: "/Event/EventData/Data[@Name=\"LogonHours\"]"
      -
        Name: DnsHostName
        Value: "/Event/EventData/Data[@Name=\"DnsHostName\"]"
      -
        Name: ServicePrincipalNames
        Value: "/Event/EventData/Data[@Name=\"ServicePrincipalNames\"]"

# Documentation:
# https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=4742
# https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4742
# 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>4742</EventID>
# <Version>0</Version>
# <Level>0</Level>
# <Task>13825</Task>
# <Opcode>0</Opcode>
# <Keywords>0x8020000000000000</Keywords>
# <TimeCreated SystemTime="2015-08-14T02:35:01.252397000Z" />
# <EventRecordID>171754</EventRecordID>
# <Correlation />
# <Execution ProcessID="520" ThreadID="1108" />
# <Channel>Security</Channel>
# <Computer>DC01.contoso.local</Computer>
# <Security />
# </System>
#  <EventData>
# <Data Name="ComputerAccountChange">-</Data>
# <Data Name="TargetUserName">WIN81$</Data>
# <Data Name="TargetDomainName">CONTOSO</Data>
# <Data Name="TargetSid">S-1-5-21-3457937927-2839227994-823803824-6116</Data>
# <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">0x2e80c</Data>
# <Data Name="PrivilegeList">-</Data>
# <Data Name="SamAccountName">-</Data>
# <Data Name="DisplayName">-</Data>
# <Data Name="UserPrincipalName">-</Data>
# <Data Name="HomeDirectory">-</Data>
# <Data Name="HomePath">-</Data>
# <Data Name="ScriptPath">-</Data>
# <Data Name="ProfilePath">-</Data>
# <Data Name="UserWorkstations">-</Data>
# <Data Name="PasswordLastSet">-</Data>
# <Data Name="AccountExpires">-</Data>
# <Data Name="PrimaryGroupId">-</Data>
# <Data Name="AllowedToDelegateTo">%%1793</Data>
# <Data Name="OldUacValue">0x80</Data>
# <Data Name="NewUacValue">0x2080</Data>
# <Data Name="UserAccountControl">%%2093</Data>
# <Data Name="UserParameters">-</Data>
# <Data Name="SidHistory">-</Data>
# <Data Name="LogonHours">-</Data>
# <Data Name="DnsHostName">-</Data>
# <Data Name="ServicePrincipalNames">-</Data>
# </EventData>
# </Event>
