Author: Mike Pilkington
Description: Network share object access
EventId: 5145
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: RemoteHost
    PropertyValue: "%ipAddress%:%port%"
    Values:
      -
        Name: ipAddress
        Value: "/Event/EventData/Data[@Name=\"IpAddress\"]"
      -
        Name: port
        Value: "/Event/EventData/Data[@Name=\"IpPort\"]"
  -
    Property: PayloadData1
    PropertyValue: "Share: %ShareName% (%ShareLocalPath%)"
    Values:
      -
        Name: ShareName
        Value: "/Event/EventData/Data[@Name=\"ShareName\"]"
      -
        Name: ShareLocalPath
        Value: "/Event/EventData/Data[@Name=\"ShareLocalPath\"]"
  -
    Property: PayloadData2
    PropertyValue: "Object: %RelativeTargetName%"
    Values:
      -
        Name: RelativeTargetName
        Value: "/Event/EventData/Data[@Name=\"RelativeTargetName\"]"
  -
    Property: PayloadData3
    PropertyValue: "AccessList: %AccessList%"
    Values:
      -
        Name: AccessList
        Value: "/Event/EventData/Data[@Name=\"AccessList\"]"
        Refine: "%%(.{4})"
  -
    Property: PayloadData4
    PropertyValue: "AccessMask: %AccessMask%"
    Values:
      -
        Name: AccessMask
        Value: "/Event/EventData/Data[@Name=\"AccessMask\"]"
  -
    Property: PayloadData5
    PropertyValue: "SID: %SubjectUserSid%"
    Values:
      -
        Name: SubjectUserSid
        Value: "/Event/EventData/Data[@Name=\"SubjectUserSid\"]"

Lookups:
  -
    Name: AccessList
    Default: Unknown code
    Values:
      "%%4416": ReadData (or ListDirectory)
      "%%4417": WriteData (or AddFile)
      "%%4418": AppendData (or AddSubdirectory or CreatePipeInstance)
      "%%4419": ReadEA (or Enumerate SubKeys)
      "%%4420": WriteEA
      "%%4421": Execute/Traverse
      "%%4422": DeleteChild
      "%%4423": ReadAttributes
      "%%4424": WriteAttributes
      "%%1537": DELETE
      "%%1538": READ_CONTROL
      "%%1539": WRITE_DAC
      "%%1540": WRITE_OWNER
      "%%1541": SYNCHRONIZE
      "%%1542": ACCESS_SYS_SEC
  -
    Name: AccessMask
    Default: Unknown code
    Values:
      "%%4416": ReadData (or ListDirectory)
      "%%4417": WriteData (or AddFile)
      "%%4418": AppendData (or AddSubdirectory or CreatePipeInstance)
      "%%4419": ReadEA (or Enumerate SubKeys)
      "%%4420": WriteEA
      "%%4421": Execute/Traverse
      "%%4422": DeleteChild
      "%%4423": ReadAttributes
      "%%4424": WriteAttributes
      "%%1537": DELETE
      "%%1538": READ_CONTROL
      "%%1539": WRITE_DAC
      "%%1540": WRITE_OWNER
      "%%1541": SYNCHRONIZE
      "%%1542": ACCESS_SYS_SEC

# Documentation:
# https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=5145
# https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-5145
# 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>5145</EventID>
# <Version>0</Version>
# <Level>0</Level>
# <Task>12811</Task>
# <Opcode>0</Opcode>
# <Keywords>0x8020000000000000</Keywords>
# <TimeCreated SystemTime="2015-09-17T23:54:48.941761700Z" />
# <EventRecordID>267092</EventRecordID>
# <Correlation />
# <Execution ProcessID="516" ThreadID="524" />
# <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">0x38d34</Data>
# <Data Name="ObjectType">File</Data>
# <Data Name="IpAddress">fe80::31ea:6c3c:f40d:1973</Data>
# <Data Name="IpPort">56926</Data>
# <Data Name="ShareName">\\\\\*\\Documents</Data>
# <Data Name="ShareLocalPath">\\??\\C:\\Documents</Data>
# <Data Name="RelativeTargetName">Bginfo.exe</Data>
# <Data Name="AccessMask">0x100081</Data>
# <Data Name="AccessList">%%1541 %%4416 %%4423</Data>
# <Data Name="AccessReason">%%1541: %%1801 D:(A;;FA;;;WD) %%4416: %%1801 D:(A;;FA;;;WD) %%4423: %%1801 D:(A;;FA;;;WD)</Data>
# </EventData>
# </Event>
