Author: Andrew Rathbun
Description: A new trust was created to a domain
EventId: 4706
Channel: Security
Provider: Microsoft-Windows-Security-Auditing
Maps:
  -
    Property: UserName
    PropertyValue: "%domain%\\%user% (%sid%)"
    Values:
      -
        Name: domain
        Value: "/Event/EventData/Data[@Name=\"SubjectDomainName\"]"
      -
        Name: user
        Value: "/Event/EventData/Data[@Name=\"SubjectUserName\"]"
      -
        Name: sid
        Value: "/Event/EventData/Data[@Name=\"SubjectUserSid\"]"
  -
    Property: PayloadData1
    PropertyValue: "DomainName: %DomainName% (%DomainSid%)"
    Values:
      -
        Name: DomainSid
        Value: "/Event/EventData/Data[@Name=\"DomainSid\"]"
      -
        Name: DomainName
        Value: "/Event/EventData/Data[@Name=\"DomainName\"]"
  -
    Property: PayloadData2
    PropertyValue: "SidFilteringEnabled: %SidFilteringEnabled%"
    Values:
      -
        Name: SidFilteringEnabled
        Value: "/Event/EventData/Data[@Name=\"SidFilteringEnabled\"]"
  -
    Property: PayloadData3
    PropertyValue: "LogonId: %SubjectLogonId%"
    Values:
      -
        Name: SubjectLogonId
        Value: "/Event/EventData/Data[@Name=\"SubjectLogonId\"]"
  -
    Property: PayloadData4
    PropertyValue: "TdoType: %TdoType%"
    Values:
      -
        Name: TdoType
        Value: "/Event/EventData/Data[@Name=\"TdoType\"]"
  -
    Property: PayloadData5
    PropertyValue: "TdoDirection: %TdoDirection%"
    Values:
      -
        Name: TdoDirection
        Value: "/Event/EventData/Data[@Name=\"TdoDirection\"]"
  -
    Property: PayloadData6
    PropertyValue: "TdoAttributes: %TdoAttributes%"
    Values:
      -
        Name: TdoAttributes
        Value: "/Event/EventData/Data[@Name=\"TdoAttributes\"]"

Lookups:
  -
    Name: TdoType
    Default: Unknown code
    Values:
      1: TRUST_TYPE_DOWNLEVEL
      2: TRUST_TYPE_UPLEVEL
      3: TRUST_TYPE_MIT
      4: TRUST_TYPE_DCE
  -
    Name: TdoDirection
    Default: Unknown code
    Values:
      O: TRUST_DIRECTION_DISABLED
      1: TRUST_DIRECTION_INBOUND
      2: TRUST_DIRECTION_OUTBOUND
      3: TRUST_DIRECTION_BIDIRECTIONAL
  -
    Name: TdoAttributes
    Default: Unknown code
    Values:
      0x1: TRUST_ATTRIBUTE_NON_TRANSITIVE
      0x2: TRUST_ATTRIBUTE_UPLEVEL_ONLY
      0x4: TRUST_ATTRIBUTE_QUARANTINED_DOMAIN
      0x8: TRUST_ATTRIBUTE_FOREST_TRANSITIVE
      0x10: TRUST_ATTRIBUTE_CROSS_ORGANIZATION
      0x20: TRUST_ATTRIBUTE_WITHIN_FOREST
      0x40: TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL
      0x80: TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION
      0x200: TRUST_ATTRIBUTE_CROSS_ORGANIZATION_NO_TGT_DELEGATION
      0x400: TRUST_ATTRIBUTE_PIM_TRUST

# Documentation:
# https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=4706
# https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4706
# 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>4706</EventID>
# <Version>0</Version>
# <Level>0</Level>
# <Task>13569</Task>
# <Opcode>0</Opcode>
# <Keywords>0x8020000000000000</Keywords>
# <TimeCreated SystemTime="2015-10-01T20:41:13.189445500Z" />
# <EventRecordID>1049759</EventRecordID>
# <Correlation />
# <Execution ProcessID="500" ThreadID="4900" />
# <Channel>Security</Channel>
# <Computer>DC01.contoso.local</Computer>
# <Security />
# </System>
# <EventData>
# <Data Name="DomainName">corp.contoso.local</Data>
# <Data Name="DomainSid">S-1-5-21-2226861337-2836268956-2433141405</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">0x3e99d6</Data>
# <Data Name="TdoType">2</Data>
# <Data Name="TdoDirection">3</Data>
# <Data Name="TdoAttributes">32</Data>
# <Data Name="SidFilteringEnabled">%%1796</Data>
# </EventData>
# </Event>
