[
  {
    "path": ".github/workflows/buildsplunkapp.yml",
    "content": "name: Build Splunk App\n\non:\n  push:\n    branches:\n      - 'master'\n\njobs:\n  build_splunk_app:\n    runs-on: ubuntu-22.04\n    steps:\n      - uses: actions/checkout@v4\n\n      - name: Change permissions of folders\n        run: find $GITHUB_WORKSPACE/SA-ADTimeline -type d -exec chmod 700 {} +\n\n      - name: Change permissions of files\n        run: find $GITHUB_WORKSPACE/SA-ADTimeline -type f -exec chmod 600 {} +\n\n      - name: Setup Python\n        uses: actions/setup-python@v5\n        with:\n          python-version: '3.7'\n\n      - name: Install Splunk Packaging Toolkit\n        run: pip install 'https://download.splunk.com/misc/packaging-toolkit/splunk-packaging-toolkit-1.0.1.tar.gz'\n\n      - name: SLIM Package App\n        run: slim package $GITHUB_WORKSPACE/SA-ADTimeline\n        \n      - name: Upload Artifact\n        uses: actions/upload-artifact@v4\n        with:\n          name: \"SA-ADTimeline_${{github.sha}}\"\n          path: SA-ADTimeline*.gz"
  },
  {
    "path": "ADTimeline.ps1",
    "content": "# Active directory timeline generated with replication metadata\n# Leonard SAVINA - ANSSI\\SDO\\DR\\INM - CERT-FR\n# Issues and PR welcome https://github.com/ANSSI-FR/ADTimeline\n\n# Use paramater server if running offline mode or GC is not found\n# Use parameter customgroups to retrieve replication metadata from specific groups.\n# customgroups argument can be a string with multiple group comma separated (no space)\n# PS>./ADTimeline -customgroups \"VIP-group1,ESX-Admins,Tier1-admins\"\n# customgroups can also be an array, in case you import the list from a file (one group per line)\n# PS>$customgroups = get-content customgroups.txt\n# PS>./ADTimeline -customgroups $customgroups\n# Use parameter groupslike to search for groups using \"like\" instead of exact match operator\n# Note that the names will be automatically surrounded by '*'\n# PS>./ADTimeline -customgroups \"admin\"\n# -> will use a search filter { Name -eq \"admin\" }\n# PS>./ADTimeline -customgroups \"admin\" -groupslike\n# -> will use a search filter { Name -like \"*admin*\" }\n# Use parameter nofwdSMTP in a large MSExchange organization context with forwarders massively used.\n# PS>./ADTimeline -nofwdSMTPaltRecipient\n\nParam (\n[parameter(Mandatory=$false)][string]$server = $null,\n[parameter(Mandatory=$false)]$customgroups = $null,\n[parameter(Mandatory=$false)][switch]$nofwdSMTP,\n[parameter(Mandatory = $false)][switch]$groupslike = $False\n)\n\nif($customgroups)\n\t{\n\tif(($customgroups.gettype()).FullName -eq \"System.String\")\n\t\t{\n\t\t$groupscustom = $customgroups.split(\",\")\n\t\twrite-output -inputobject \"---- Custom groups argument is a string ----\"\n\t\t}\n\telseif(($customgroups.gettype()).FullName -eq \"System.Object[]\")\n\t\t{\n\t\t$groupscustom = $customgroups\n\t\t\"---- Custom groups argument is an array ----\"\n\t\t}\n\telse\n\t\t{\n\t\twrite-output -inputobject \"---- Wrong argument object type ----\"\n\t\tExit $WRONG_ARG_TYPE\n\t\t}\n\n\t}\n\n# You can also directly uncomment and edit the below $customgroups variable if you do not want to set an argument\n# Example of custom groups variable\n# $groupscustom = (\"VIP-group1\",\"ESX-Admins\",\"Tier1-admins\")\n\n\n# Set Variables for error handling\nSet-Variable -name ERR_BAD_OS_VERSION -option Constant -value 1\nSet-Variable -name ERR_NO_AD_MODULE   -option Constant -value 2\nSet-Variable -name ERR_NO_GC_FOUND   -option Constant -value 3\nSet-Variable -name ERR_GC_BIND_FAILED   -option Constant -value 4\nSet-Variable -name WRONG_ARG_TYPE   -option Constant -value 5\n\n\n# AD Timeline is supported on Windows 6.1 +\nif([Environment]::OSVersion.version -lt (new-object 'Version' 6,1))\n\t{\n\twrite-output -inputobject \"---- Script must be launched on a Windows 6.1 + computer ----\"\n\tExit $ERR_BAD_OS_VERSION\n\t}\n\n# Check AD Psh module\nIf(-not(Get-Module -name activedirectory -listavailable))\n\t{\n\twrite-output -inputobject \"---- Script must be launched on a computer with Active Directory PowerShell module installed ----\"\n\tExit $ERR_NO_AD_MODULE\n\t}\nElse\n\t{import-module activedirectory}\n\n# Check Global Catalog\n$GCsinmysite = $null\n\nif(-not($server))\n\t{\n\t$mySite = (nltest /dsgetsite 2>$null)[0]\n\t$ADroot = $(get-adDomain).DNSroot\n\t$GCsinmysite = get-ADDomainController -Filter {(IsGlobalCatalog -eq $true) -and (Site -eq $mySite) -and (Domain -eq $ADroot) -and (Enabled -eq $true)}\n\tif($GCsinmysite)\n\t\t{ $server = ($GCsinmysite  | select-object -first 1).Hostname }\n\tElse\n\t\t{\n\t\twrite-output -inputobject \"---- No Global Catalog found in current AD site, please run the script and specify a Global Catalog name with the server argument ----\"\n\t\tExit $ERR_NO_GC_FOUND\n\t\t}\n\t}\n\n$error.clear()\n# LDAP root information, to retrieve partitions paths\n$root = Get-ADRootDSE -server $server\n\nif($error)\n\t{\n\twrite-output -inputobject \"---- Retrieving AD root on $($server) failed ----\"\n\tExit $ERR_GC_BIND_FAILED\n\t}\n\n# Check if script is running offline or online and set GC port\nif([string]$server.contains(\":\") -eq $true)\n\t{\n\t$gcport = [int]::parse($server.split(\":\")[1]) + 2\n\t$gc = $server.split(\":\")[0] + \":\" + $gcport\n\t$isonline = $false\n\t}\nelse {\n\t$error.clear()\n\t$dntstroot = [void]([adsi]\"LDAP://$server\").distinguishedName\n\t[void][adsi]\"GC://$server/$dntstroot\"\n\tif($error)\n\t\t{\n\t\twrite-output -inputobject \"---- DC is not Global Catalog, please provide a GC with the server argument ----\"\n\t\tExit $ERR_NO_GC_FOUND\n\t\t}\n\tElse\n\t\t{\n\t\t$gc = $server + ':3268'\n\t\t$isonline = $true\n\t\t}\n\t}\n\nwrite-output -inputobject \"---- Running script on: $($server) ----\"\n\nwrite-output -inputobject \"---- Collecting AD objects ----\"\n\n# TimeStamp formating for log file\nfunction Get-TimeStamp\n    {\n    return \"{0:yyyy-MM-dd} {0:HH:mm:ss}\" -f (get-date)\n    }\n\n\"$(Get-TimeStamp) Starting script on $($server)\" | out-file logfile.log\n\nif($isonline -eq $true)\n\t{\n\t\"$(Get-TimeStamp) Script running in online mode\" | out-file logfile.log -append\n\t}\nelse\n\t{\n\t\"$(Get-TimeStamp) Script running in offline mode\" | out-file logfile.log -append\n\t}\n\n# Getting folder fully qualifed name length to compute MAX_PATH\n$maxfilenamelen = 0\n$folderlen = ((get-item .\\logfile.log).directoryName).length\n$maxfilenamelen = 256 - $folderlen + 2\n\n# Function adapted from https://www.petri.com/expanding-active-directory-searcher-powershell Added SID processing\nFunction Convert-ADSearchResult\n{\n\t[cmdletbinding()]\n\tParam(\n\t[Parameter(Position = 0,Mandatory = $true,ValueFromPipeline = $true)]\n\t[ValidateNotNullorEmpty()]\n\t[System.DirectoryServices.SearchResult]$SearchResult\n\t)\n\tBegin {\n    Write-Verbose \"Starting $($MyInvocation.MyCommand)\"\n\t}\n\tProcess {\n    Write-Verbose \"Processing result for $($searchResult.Path)\"\n    #create an ordered hashtable with property names alphabetized\n    $props = $SearchResult.Properties.PropertyNames | Sort-Object\n\t$objHash = @{}\n    foreach ($p in $props)\n\t{\n\t\tif(($p -eq \"objectSID\") -or ($p -eq \"SIDHistory\"))\n\t\t\t{\n\t\t\t$value = @()\n\t\t\t$binaryvalue =  $searchresult.Properties.item($p)\n\t\t\t\tforeach($SID in $binaryvalue)\n\t\t\t\t{\n\t\t\t\t$value += (New-Object System.Security.Principal.SecurityIdentifier($SID,0)).value\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t{\n\t\t$value =  $searchresult.Properties.item($p)\n\t\t}\n\t\tif ($value.count -eq 1)\n\t\t\t{$value = $value[0]}\n     $objHash.add($p,$value)\n    }\n\tnew-object psobject -property $objHash\n\n\t}\n\tEnd\n\t{\n    Write-Verbose \"Ending $($MyInvocation.MyCommand)\"\n\t}\n}\n\n\n# Initializing PowerShell objects in order to store results from LDAP queries\n$criticalobjects = @()\n$gcobjects = @()\n\n#Getting root domain information\n$dom = Get-ADObject -SearchBase ($root.defaultNamingContext) -SearchScope Base -Server $server  -Filter * -properties *\n#If operation times out a different ResultPageSize is used\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$dom = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.defaultNamingContext) -SearchScope Base -Server $server  -Filter * -properties *\n\t\t$i++\n\t\t}\n\tif($dom){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n\n$criticalobjects += $dom\n\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving domain root information $($error)\" | out-file logfile.log -append ; $error.clear() }\nelse\n\t{\n\t#Get current domain SID and PDCe, will be used later\n\t$domSID = $dom.ObjectSID.value\n\t$PDCe = ((($dom.fsmoRoleOwner).replace($root.configurationNamingContext,\"\")).replace(\"CN=NTDS Settings,\",\"\")).replace(\"CN=Sites,\",\"CN=Sites\")\n\t\"$(Get-TimeStamp) Domain root information retrieved\" | out-file logfile.log -append\n\t\"$(Get-TimeStamp) Domain DistinguishedName is: $($dom.distinguishedName) \" | out-file logfile.log -append\n\t\"$(Get-TimeStamp) Domain SID is: $($domSID)\" | out-file logfile.log -append\n\t$domainfqdn = (($dom.distinguishedName).replace(\"DC=\",\"\")).replace(\",\",\".\")\n\t#Getting accounts having an ACE on domain root\n\n\t$accountsACEondomain = ($dom.ntsecuritydescriptor).getaccessrules($true , $true , [System.Security.Principal.SecurityIdentifier]) | Where-Object {$_.IdentityReference -like \"S-1-5-21-*\"} | group-object -property IdentityReference\n\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while retrieving accounts having an ACE on domain $($error)\" | out-file logfile.log -append ; $error.clear() }\n\telse\n\t\t{\n\t\t$usrcount = 0\n\t\t$ismsol = $false\n\t\t$userACE = $null\n\t\tforeach($accountACE in $accountsACEondomain)\n\t\t\t{#If SID is from current domain launch LDAP query, otherwise try GC\n\t\t\tif($accountACE.Name -like \"$domSID*\")\n\t\t\t\t{\n\t\t\t\t$userACE = Get-ADObject -Filter {ObjectSID -eq $accountACE.Name} -Server $server -properties *\n\t\t\t\tif($userACE){$criticalobjects += $userACE}\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t\t\t$search.filter = \"(ObjectSID=$($accountACE.Name))\"\n\t\t\t\t$userACE = $search.findone() | Convert-ADSearchResult\n\t\t\t\tif($userACE){$gcobjects += $userACE}\n\t\t\t\t}\n\t\t\tif($error)\n\t\t\t\t{ \"$(Get-TimeStamp) Error while getting object SID $($accountACE.Name) with error $($error)\" | out-file logfile.log -append ; $error.clear() }\n\t\t\telse\n\t\t\t\t{#Check if objectclass is user, if yes check if name matches AADConnect account\n\t\t\t\tif(($userACE.ObjectClass -eq \"user\") -or ($userACE.ObjectClass -eq \"inetOrgPerson\"))\n\t\t\t\t\t{$usrcount++\n\t\t\t\t\tif($userACE.SamAccountName -like \"MSOL_*\")\n\t\t\t\t\t\t{$ismsol = $true}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t\t \"$(Get-TimeStamp) Number of user accounts having an ACE on domain root: $($usrcount)\" | out-file logfile.log -append\n\t\t\tif($ismsol)\n\t\t\t\t{\"$(Get-TimeStamp) Account starting with MSOL having an ACE on domain root, Default Azure AD connect installation might be setup\" | out-file logfile.log -append}\n\n\t}\n\n#Renaming log file and setting filenames for result files\nif($domainfqdn)\n\t{\n\tif($domainfqdn.length -ge $maxfilenamelen)\n\t\t{\n\t\t$logfilename = \"logfile_\" + $domainfqdn.substring(0,$maxfilenamelen) + \".log\"\n\t\t$timelinefilename = \"timeline_\" + $domainfqdn.substring(0,$maxfilenamelen) + \".csv\"\n\t\t$adobjectsfilename = \"ADobjects_\" + $domainfqdn.substring(0,$maxfilenamelen) + \".xml\"\n\t\t$gcADobjectsfilename = \"gcADobjects_\" + $domainfqdn.substring(0,$maxfilenamelen) + \".xml\"\n\t\t}\n\telse {\n\t\t$logfilename = \"logfile_\" + $domainfqdn + \".log\"\n\t\t$timelinefilename = \"timeline_\" + $domainfqdn + \".csv\"\n\t\t$adobjectsfilename = \"ADobjects_\" + $domainfqdn + \".xml\"\n\t\t$gcADobjectsfilename = \"gcADobjects_\" + $domainfqdn + \".xml\"\n\t\t}\n\tif(test-path($logfilename)){remove-item $logfilename -force -confirm:$false}\n\tRename-item \".\\logfile.log\" $logfilename -force -confirm:$false\n\tNew-Item -ItemType File -Name $timelinefilename -force -confirm:$false | Out-Null\n\tNew-Item -ItemType File -Name $adobjectsfilename -force -confirm:$false | Out-Null\n\tNew-Item -ItemType File -Name $gcADobjectsfilename -force -confirm:$false | Out-Null\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while setting setting filenames for output files with error $($error)\" | out-file logfile.log -append\n\t\t$error.clear()\n\t\t$logfilename = \"logfile.log\"\n\t\t$timelinefilename = \"timeline.csv\"\n\t\t$adobjectsfilename = \"ADobjects.xml\"\n\t\t$gcADobjectsfilename = \"gcADobjects.xml\"\n\t\t}\n\n\t}\nelse\n\t{\n\t$logfilename = \"logfile.log\"\n\t$timelinefilename = \"timeline.csv\"\n\t$adobjectsfilename = \"ADobjects.xml\"\n\t$gcADobjectsfilename = \"gcADobjects.xml\"\n\t}\n\n#Getting root of the configuration partition\n$rootconf = Get-ADObject -SearchBase ($root.ConfigurationNamingContext) -SearchScope Base -Server $server  -Filter * -properties *\n#If operation times out a different ResultPageSize is used\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$rootconf = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.ConfigurationNamingContext) -SearchScope Base -Server $server  -Filter * -properties *\n\t\t$i++\n\t\t}\n\tif($rootconf){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $rootconf\n\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving root of the configuration partition $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t\"$(Get-TimeStamp) Root of the configuration partition retrieved\" | out-file $logfilename -append\n\t}\n\n#Getting root of the schema partition\n$rootschema = Get-ADObject -SearchBase ($root.SchemaNamingContext) -SearchScope Base -Server $server  -Filter * -properties *\n#If operation times out a different ResultPageSize is used\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$rootschema = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.SchemaNamingContext) -SearchScope Base -Server $server  -Filter * -properties *\n\t\t$i++\n\t\t}\n\tif($rootschema){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $rootschema\n\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving root of the schema partition $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t$SchemaMaster = ((($rootschema.fsmoRoleOwner).replace($root.configurationNamingContext,\"\")).replace(\"CN=NTDS Settings,\",\"\")).replace(\"CN=Sites,\",\"CN=Sites\")\n\t\"$(Get-TimeStamp) Root of the schema partition retrieved\" | out-file $logfilename -append\n\t\"$(Get-TimeStamp) Schema version is $($rootschema.objectVersion)\" | out-file $logfilename -append\n\t}\n\n\n#Check if current user is DA or EA when online mode running\nif($isonline -eq $true)\n\t{\n\t$mygrps = whoami /groups /fo csv | ConvertFrom-Csv\n\t$Dasid = $domsid + \"-512\"\n\t$isda = $mygrps | where-object{($_.SID -eq $Dasid) -or ($_.SID -like \"*-519\")}\n\tif($isda)\n\t\t{\n\t\t\"$(Get-TimeStamp) Current user is domain admin or enterprise admin\" | out-file $logfilename -append\n\t\t}\n\telse\n\t\t{\n\t\twrite-output -inputobject \"Script not running as domain or enterprise admin, some objects might be missing\"\n\t\t\"$(Get-TimeStamp) Script not running as domain or enterprise admin, some objects might be missing\" | out-file $logfilename -append\n\t\t}\n\t}\n\n\n#Retrieving objects located directly under the root domain, except Organizational Units\n$dom1 = Get-ADObject -SearchBase ($root.defaultNamingContext) -SearchScope OneLevel -Server $server  -filter {ObjectClass -ne \"organizationalUnit\"} -properties *\n#If operation times out a different ResultPageSize is used\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$dom1 = Get-ADObject -SearchBase ($root.defaultNamingContext) -SearchScope OneLevel -Server $server  -filter {ObjectClass -ne \"organizationalUnit\"} -properties *\n\t\t$i++\n\t\t}\n\tif($dom1){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n\n\n\n$criticalobjects += $dom1\n$countdom1 = ($dom1 | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving objects directly under domain root $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of objects directly under domain root, OU excluded:  $($countdom1)\" | out-file $logfilename -append\n\t$inframaster = (((($dom1 | where-object{($_.Name -eq \"Infrastructure\") -and ($_.ObjectClass -eq \"infrastructureUpdate\")}).fsmoRoleOwner).replace($root.configurationNamingContext,\"\")).replace(\"CN=NTDS Settings,\",\"\")).replace(\"CN=Sites,\",\"CN=Sites\")\n\t}\n\n#Objects protected by the SDProp process (AdminSDHolder ACL, Admincount=1)\n$SDPropObjects = Get-ADObject  -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -filter {AdminCount -eq 1} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$SDPropObjects = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -filter {AdminCount -eq 1} -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($SDPropObjects){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $SDPropObjects\n$countSDPROP = ($SDPropObjects | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving objects protected by the SDProp process $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of objects protected by the SDProp process: $($countSDPROP)\" | out-file $logfilename -append}\n\n\n#Objects with mail forwarders (msExchGenericForwardingAddress, altRecipient)\n\nif(-not($nofwdSMTP))\n\t{\n$ForwardedObjects = Get-ADObject  -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -filter {(msExchGenericForwardingAddress -like \"*\") -or (altRecipient -like \"*\")} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$ForwardedObjects = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -filter {(msExchGenericForwardingAddress -like \"*\") -or (altRecipient -like \"*\")} -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($ForwardedObjects){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $ForwardedObjects\n$countForwardedObjects = ($ForwardedObjects | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving objects with forwarders $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of objects with forwaders: $($countForwardedObjects)\" | out-file $logfilename -append}\n    }\n\n\n#Grabing \"Pre Windows 2000 Compatibility access group\", not recursive...\n$pre2000SID = \"S-1-5-32-554\"\n$pre2000grp =  Get-ADObject -filter {ObjectSID -eq $pre2000SID} -Server $server -properties *\nif($error)\n\t{ \"$(Get-TimeStamp) Error while retrieving Pre Windows 2000 Compatibility access group $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\tif($pre2000grp)\n\t\t{\n\t\t$criticalobjects += $pre2000grp\n\t\t$countpre2000grp = ($pre2000grp | measure-object).count\n\t\tif($countpre2000grp -eq 1)\n\t\t\t{\n\t\t\tif($pre2000grp.member -eq ('CN=S-1-1-0,CN=ForeignSecurityPrincipals,'+ $root.defaultNamingContext))\n\t\t\t\t{ \"$(Get-TimeStamp) Member of Pre Windows 2000 Compatibility access group is Everyone\" | out-file $logfilename -append}\n\t\t\tElseif($pre2000grp.member -eq ('CN=S-1-5-11,CN=ForeignSecurityPrincipals,'+ $root.defaultNamingContext))\n\t\t\t\t{ \"$(Get-TimeStamp) Member of Pre Windows 2000 Compatibility access group is Authenticated users\" | out-file $logfilename -append}\n\t\t\tElseif($pre2000grp.member -eq ('CN=S-1-5-7,CN=ForeignSecurityPrincipals,'+ $root.defaultNamingContext))\n\t\t\t\t{ \"$(Get-TimeStamp) Member of Pre Windows 2000 Compatibility access group is Anonymous logon\" | out-file $logfilename -append}\n\t\t\telse\n\t\t\t\t{ \"$(Get-TimeStamp) Member of Pre Windows 2000 Compatibility access group is $($pre2000grp.member)\" | out-file $logfilename -append}\n\t\t\t}\n\t\telse\n\t\t{\"$(Get-TimeStamp) Number of Pre Windows 2000 Compatibility access group members: $($countpre2000grp)\" | out-file $logfilename -append}\n\t\t}\n\t}\n#Grabing Guest Account\n$guestaccsid = $domSID + \"-501\"\n$guestacc =  Get-ADObject -filter {ObjectSID -eq $guestaccsid} -Server $server -properties *\nif($error)\n\t\t{ \"$(Get-TimeStamp) Error while retrieving Guest account $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\tif($guestacc)\n\t\t{\n\t\t$criticalobjects += $guestacc\n\t\tif(($guestacc.UserAccountControl -band 2) -eq 2)\n\t\t\t{\n\t\t\t\"$(Get-TimeStamp) Guest account is disabled\" | out-file $logfilename -append\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\t\"$(Get-TimeStamp) Guest account is enabled!\" | out-file $logfilename -append\n\t\t\t}\n\t\t}\n\t}\n\n#Grabing the DNSAdmin groups and its members well knwon SID is S-1-5-21-<Domain>-1101\n$dndnsadminSID = $domSID + \"-1101\"\n$dnsadmin =  Get-ADObject -filter {ObjectSID -eq $dndnsadminSID} -Server $server -properties *\n#Group might not exist if DNS role not installed\nif($dnsadmin)\n\t{\n\t$criticalobjects += $dnsadmin\n\tif($isonline -eq $true)\n\t\t{\n\t\t#Get recursive membership\n\t\t$dnsadminsmembers = (Get-ADGroupMember -recursive $dnsadmin -server $server  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t#Get groups till level 2 is reached if groups are nested.\n\t\t\tif($dnsadminsmembers)\n\t\t\t{\n\t\t\t$criticalobjects += $dnsadminsmembers\n\t\t\t$nestedgrp = @()\n\t\t\t$level1 = Get-ADGroupMember $dnsadmin  -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName\n\t\t\t\tif($level1)\n\t\t\t\t{\n\t\t\t\t$nestedgrp += $level1\n\t\t\t\t$nestedgrp  += $level1 | foreach-object{Get-ADGroupMember $_.DistinguishedName -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName}\n\t\t\t\t$criticalobjects += ($nestedgrp | foreach-object{get-adobject $_.DistinguishedName -server $server -properties *})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\t#Cannot use recursive membership cmdlet in offline mode, get direct members only\n\t\t$dnsadminsmembers = ($dnsadmin | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t$criticalobjects += $dnsadminsmembers\n\t\t#Get groups till level 2 is reached if groups are nested.\n\t\t$continue = $dnsadminsmembers | where-object{$_.ObjectClass -eq \"Group\"}\n\t\t\tif($continue)\n\t\t\t\t{foreach($grp in $continue){$dnsadmingrpcn2 = $grp | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *};$criticalobjects += $dnsadmingrpcn2}}\n\t\t}\n\t\t\t\t$countdnsadminsmembers = ($dnsadminsmembers | measure-object).count\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving DNSADmins group members $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\telse\n\t\t\t{\"$(Get-TimeStamp) Number of DNSAdmins group members: $($countdnsadminsmembers)\" | out-file $logfilename -append}\n\t}\n\n\n\n\n#Grabing the DNSUpdateProxy groups and its members well knwon SID is S-1-5-21-<Domain>-1102\n$DNSUpdateProxySID = $domSID + \"-1102\"\n$DNSUpdateProxy =  Get-ADObject -filter {ObjectSID -eq $DNSUpdateProxySID} -Server $server -properties *\n#Group might not exist if DNS role not installed\nif($DNSUpdateProxy)\n\t{\n\t$criticalobjects += $DNSUpdateProxy\n\tif($isonline -eq $true)\n\t\t{\n\t\t#Get recursive membership\n\t\t$DNSUpdateProxymembers = (Get-ADGroupMember -recursive $DNSUpdateProxy -server $server  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t#Get groups till level 2 is reached if groups are nested.\n\t\t\tif($DNSUpdateProxymembers)\n\t\t\t{\n\t\t\t$criticalobjects += $DNSUpdateProxymembers\n\t\t\t$nestedgrp = @()\n\t\t\t$level1 = Get-ADGroupMember $DNSUpdateProxy  -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName\n\t\t\t\tif($level1)\n\t\t\t\t{\n\t\t\t\t$nestedgrp += $level1\n\t\t\t\t$nestedgrp  += $level1 | foreach-object{Get-ADGroupMember $_.DistinguishedName -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName}\n\t\t\t\t$criticalobjects += ($nestedgrp | foreach-object{get-adobject $_.DistinguishedName -server $server -properties *})\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\t#Cannot use recursive membership cmdlet in offline mode, get direct members only\n\t\t$DNSUpdateProxymembers = ($DNSUpdateProxy | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t$criticalobjects += $DNSUpdateProxymembers\n\t\t#Get groups till level 2 is reached if groups are nested.\n\t\t$continue = $DNSUpdateProxymembers | where-object{$_.ObjectClass -eq \"Group\"}\n\t\t\tif($continue)\n\t\t\t\t{foreach($grp in $continue){$dnsadmingrpcn2 = $grp | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *};$criticalobjects += $dnsadmingrpcn2}}\n\t\t}\n\t\t\t\t$countDNSUpdateProxymembers = ($DNSUpdateProxymembers | measure-object).count\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving DNSUpdateProxy group members $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\telse\n\t\t\t{\"$(Get-TimeStamp) Number of DNSUpdateProxy group members: $($countDNSUpdateProxymembers)\" | out-file $logfilename -append}\n\t}\n\n\n#Grabing Group Policy Creators owners, using SID because name depends on the installation language\n$gpoownersSID = $domSID + \"-520\"\n$gpoowners = Get-ADObject -filter {ObjectSID -eq $gpoownersSID} -Server $server -properties *\n$criticalobjects += $gpoowners\nif($isonline -eq $true)\n\t{\n\t#Get recursive membership\n\t$gpoownersmembers = (Get-ADGroupMember -recursive $gpoowners -server $server  | foreach-object{get-adobject $_ -server $server -properties *})\n\t#Get groups till level 2 is reached if groups are nested.\n\t\tif($gpoownersmembers)\n\t\t{\n\t\t$criticalobjects += $gpoownersmembers\n\t\t$nestedgrp = @()\n\t\t$level1 = Get-ADGroupMember $gpoowners  -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName\n\t\t\tif($level1)\n\t\t\t{\n\t\t\t$nestedgrp += $level1\n\t\t\t$nestedgrp  += $level1 | foreach-object{Get-ADGroupMember $_.DistinguishedName -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName}\n\t\t\t$criticalobjects += ($nestedgrp | foreach-object{get-adobject $_.DistinguishedName -server $server -properties *})\n\t\t\t}\n\t\t}\n\t}\nelse\n\t{\n\t#Cannot use recursive membership cmdlet in offline mode, get direct members only\n\t$gpoownersmembers = ($gpoowners | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *})\n\t$criticalobjects += $gpoownersmembers\n\t#Get groups till level 2 is reached if groups are nested.\n\t$continue = $gpoownersmembers | where-object{$_.ObjectClass -eq \"Group\"}\n\t\tif($continue)\n\t\t\t{foreach($grp in $continue){$gpoownersgrpcn2 = $grp | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *};$criticalobjects += $gpoownersgrpcn2}}\n\t}\n\t\t\t$countgpoownersmembers = ($gpoownersmembers | measure-object).count\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while retrieving GPO owners group members $($error)\" | out-file $logfilename -append ; $error.clear() }\n\telse\n\t\t{\"$(Get-TimeStamp) Number of GPO creators ownners group members: $($countgpoownersmembers)\" | out-file $logfilename -append}\n\n#Grabing Cert publishers, using SID because name depends on the installation language\n$certpublishersSID = $domSID + \"-517\"\n$certpublishers = Get-ADObject -filter {ObjectSID -eq $certpublishersSID} -Server $server -properties *\n$criticalobjects += $certpublishers\nif($isonline -eq $true)\n\t{\n\t#Get recursive membership\n\t$certpublishersmembers = (Get-ADGroupMember -recursive $certpublishers -server $server  | foreach-object{get-adobject $_ -server $server -properties *})\n\t#Get groups till level 2 is reached if groups are nested.\n\t\tif($certpublishersmembers)\n\t\t{\n\t\t$criticalobjects += $certpublishersmembers\n\t\t$nestedgrp = @()\n\t\t$level1 = Get-ADGroupMember $certpublishers  -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName\n\t\t\tif($level1)\n\t\t\t{\n\t\t\t$nestedgrp += $level1\n\t\t\t$nestedgrp  += $level1 | foreach-object{Get-ADGroupMember $_.DistinguishedName -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName}\n\t\t\t$criticalobjects += ($nestedgrp | foreach-object{get-adobject $_.DistinguishedName -server $server -properties *})\n\t\t\t}\n\t\t}\n\t}\nelse\n\t{\n\t#Cannot use recursive membership cmdlet in offline mode, get direct members only\n\t$certpublishersmembers = ($certpublishers | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *})\n\t$criticalobjects += $certpublishersmembers\n\t#Get groups till level 2 is reached if groups are nested.\n\t$continue = $certpublishersmembers | where-object{$_.ObjectClass -eq \"Group\"}\n\t\tif($continue)\n\t\t\t{foreach($grp in $continue){$certpublishersgrpcn2 = $grp | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *};$criticalobjects += $certpublishersgrpcn2}}\n\t}\n\t\t\t$countcertpublishersmembers = ($certpublishersmembers | measure-object).count\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while retrieving Cert publishers group members $($error)\" | out-file $logfilename -append ; $error.clear() }\n\telse\n\t\t{\"$(Get-TimeStamp) Number of Cert publishers group members: $($countcertpublishersmembers)\" | out-file $logfilename -append}\n\n#Retrieving deleted Group Policy Objects\n$DeleteBase = \"CN=Deleted Objects,\" + $root.defaultNamingContext\n$deletedgpo = Get-ADObject -searchbase $DeleteBase -filter {(IsDeleted -eq $true) -and (ObjectClass -eq \"groupPolicyContainer\")} -IncludeDeletedObjects -Server $server -properties *\n\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$deletedgpo = Get-ADObject -ResultPageSize $resultspagesize -searchbase $DeleteBase -filter {(IsDeleted -eq $true) -and (ObjectClass -eq \"groupPolicyContainer\")} -IncludeDeletedObjects -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($deletedgpo){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $deletedgpo\n$countdeletedgpo = ($deletedgpo  | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Erreur while retrieving deleted GPOs $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of deleted (tombstoned) GPOs: $($countdeletedgpo)\" | out-file $logfilename -append}\n\n\n\n#Retrieving Deleted (tombstoned) users, NTSecurityDescriptor porperty is excluded because with a large number of tombstoned users it can take a large amount of RAM. This property is not relevant for analysis if object is in the \"Deleted Objects\" container.\n$deletedusers = Get-ADObject -searchbase $DeleteBase -filter {(IsDeleted -eq $true) -and ((ObjectClass -eq \"User\") -or (ObjectClass -eq \"InetOrgPerson\"))} -IncludeDeletedObjects -Server $server -properties CanonicalName, CN, Deleted, Description, DisplayName, DistinguishedName, instanceType, isDeleted, isRecycled, LastKnownParent, Modified, modifyTimeStamp, Name, ObjectCategory, ObjectClass, ObjectGUID, objectSid, ProtectedFromAccidentalDeletion, sAMAccountName, sDRightsEffective, userAccountControl, uSNChanged, uSNCreated, whenChanged, whenCreated\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$deletedusers = Get-ADObject -ResultPageSize $resultspagesize -searchbase $DeleteBase -filter {(IsDeleted -eq $true) -and ((ObjectClass -eq \"User\") -or (ObjectClass -eq \"InetOrgPerson\"))} -IncludeDeletedObjects -Server $server -properties CanonicalName, CN, Deleted, Description, DisplayName, DistinguishedName, instanceType, isDeleted, isRecycled, LastKnownParent, Modified, modifyTimeStamp, Name, ObjectCategory, ObjectClass, ObjectGUID, objectSid, ProtectedFromAccidentalDeletion, sAMAccountName, sDRightsEffective, userAccountControl, uSNChanged, uSNCreated, whenChanged, whenCreated\n\t\t$i++\n\t\t}\n\tif($deletedusers){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$countdeletedusers = ($deletedusers  | measure-object).count\nif($countdeletedusers -ge 3000)\n\t{\n\t#If number of deleted objects is larger than 3000, metadata retrieval might take a while. As a consequence we sort them by creation date and take only the last 3000 created accounts.\n\t$criticalobjects += $deletedusers |  where-object{$_.WhenCreated -ne $null} | Sort-Object -Property whencreated -Descending | select-object -first 3000\n\t\"$(Get-TimeStamp) Number of deleted (tombstoned) user objects is $($countdeletedusers), because it is larger than 3000 only last 3000 newly created accounts will be retrieved\" | out-file $logfilename -append\n\t}\nelse\n\t{\n\t$criticalobjects += $deletedusers\n\t\"$(Get-TimeStamp) Number of deleted (tombstoned) user objects: $($countdeletedusers)\" | out-file $logfilename -append\n\t}\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving deleted (tombstoned) user objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\n\n#Retrieving deleted objects located in configuration partition, msExchActiveSyncDevice objectclass is excluded as it can generate some noise\n$deleteconf =  Get-ADObject -searchbase $root.configurationNamingContext  -filter {(IsDeleted -eq $true) -and (ObjectClass -ne \"msExchActiveSyncDevice\")} -IncludeDeletedObjects -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$deleteconf = Get-ADObject -ResultPageSize $resultspagesize -searchbase $root.configurationNamingContext  -filter {(IsDeleted -eq $true) -and (ObjectClass -ne \"msExchActiveSyncDevice\")} -IncludeDeletedObjects -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($deleteconf){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $deleteconf\n$countdeleteconf = ($deleteconf | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving deleted (tombstoned) objects located in configuration partition $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of deleted (tombstoned) objects located in configuration partition: $($countdeleteconf)\" | out-file $logfilename -append}\n\n\n\n\n\n#Retrieving classSchema objects (defaultSecurityDescriptor backdoor)\n$Classesschema = Get-ADObject -searchbase $root.schemaNamingContext -Filter {ObjectClass -eq \"classSchema\"} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$Classesschema = Get-ADObject -ResultPageSize $resultspagesize -searchbase $root.schemaNamingContext -Filter {ObjectClass -eq \"classSchema\"} -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($Classesschema){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $Classesschema\n$countClassesschema = ($Classesschema | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving classSchema objects $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of classSchema objects:  $($countClassesschema)\" | out-file $logfilename -append}\n\n\n#Retrieving Service Connection Point class objects of interest located in the domain partition\n\n#SCP Objectclass/categories of interest mSSMSManagementPoint = SCCM, Service-Administration-Point holds binding information for connecting to a service to administer it, intellimirrorSCP contains configuration information for the service that responds to Remote Boot clients that request attention from a Remote Install Server.\n$SAdminPointCat = \"CN=Service-Administration-Point,\" + $root.SchemaNamingContext\n$scpsdomain1 = Get-ADObject -searchbase $root.defaultNamingContext -Filter {(objectclass -eq \"mSSMSManagementPoint\") -or (ObjectCategory -eq $SAdminPointCat) -or (objectclass -eq \"intellimirrorSCP\")} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$scpsdomain1 = Get-ADObject -ResultPageSize $resultspagesize -searchbase $root.defaultNamingContext -Filter {(objectclass -eq \"mSSMSManagementPoint\") -or (ObjectCategory -eq $SAdminPointCat) -or (objectclass -eq \"intellimirrorSCP\")} -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($scpsdomain1){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $scpsdomain1\n$countscpsdomain1 = ($scpsdomain1 | measure-object).count\n\n#SCP serviceClassName of interest\n$scpsdomain2 = Get-ADObject -searchbase $root.defaultNamingContext -Filter {(objectclass -eq \"serviceConnectionPoint\") -and (serviceClassName -like \"*\")} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$scpsdomain2 = Get-ADObject -ResultPageSize $resultspagesize -searchbase $root.defaultNamingContext -Filter {(objectclass -eq \"serviceConnectionPoint\") -and (serviceClassName -like \"*\")} -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($scpsdomain2){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n#Known list of relevant serviceClassName ldap = ADLDS, Vcenter..., TSGateway = RDS Gateway, BEMainService = BackupExec server, Groupwise = Novell Groupwise\n$knowrelevantscpsdomain2 = $scpsdomain2 | where-object{($_.serviceClassName -eq \"ldap\") -or ($_.serviceClassName -eq \"TSGateway\") -or ($_.serviceClassName -eq \"BEMainService\") -or ($_.serviceClassName -eq \"groupwise\")}\n$criticalobjects += $knowrelevantscpsdomain2\n$countscpsdomain2 = ($knowrelevantscpsdomain2 | measure-object).count\n#Get serviceClassName with few occurences outisde known list to discover new intersting serviceClassName.\n$remainingscpsdomain2  = $scpsdomain2 | where-object{($_.serviceClassName -ne \"ldap\") -and ($_.serviceClassName -ne \"TSGateway\") -and ($_.serviceClassName -ne \"BEMainService\") -and ($_.serviceClassName -ne \"groupwise\")}\nif($remainingscpsdomain2)\n\t{\n\t$rarescp = $remainingscpsdomain2 | Group-Object -Property serviceClassName | where-object{($_.count -le 3)}\n\tif($rarescp)\n\t\t{\n\t\tforeach($rareserviceclassname in $rarescp)\n\t\t\t{\n\t\t\t$rarescptoadd = $remainingscpsdomain2 | Where-Object{$_.serviceClassName -eq $rareserviceclassname.Name}\n\t\t\t$countscpsdomain2 = $countscpsdomain2 + $rareserviceclassname.count\n\t\t\t$criticalobjects += $rarescptoadd\n\t\t\t}\n\t\t}\n\t}\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving Service Connection Point class objects of interest located in the domain partition $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {$countscpsdomain = $countscpsdomain1 + $countscpsdomain2; \"$(Get-TimeStamp) Number of Service Connection Point class objects of interest located in the domain partition:  $($countscpsdomain)\" | out-file $logfilename -append}\n\n\n#Retrieving Service Connection Point class objects located in the configuration partition\n$countallscps = 0\n$scps =  Get-ADObject -searchbase $root.configurationNamingContext -filter {ObjectClass -eq 'ServiceConnectionPoint'} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$scps = Get-ADObject -ResultPageSize $resultspagesize -searchbase $root.configurationNamingContext -filter {ObjectClass -eq 'ServiceConnectionPoint'} -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($scps){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n#Might be read rights issues, trying GC\nif($error -like '*Directory object not found*')\n\t{\n\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t$search.pagesize = 256\n\t$scpCategory = \"CN=Service-Connection-Point,\" + $root.SchemaNamingContext\n\t$search.filter = \"((ObjectCategory=$($scpCategory)))\"\n\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t$scpquery =  $search.findall()\n\t$scpsgc = $scpquery | where-object{$_.properties.distinguishedname -like \"*CN=Services,CN=Configuration*\"} | Convert-ADSearchResult\n\tif($scpsgc){\n\t\t\t\t$error.clear()\n\t\t\t\t$countallscps = ($scpsgc | measure-object).count\n\t\t\t\t$gcobjects += $scpsgc\n\t\t\t\t}\n\t}\n\nif($scps){\n\t\t$criticalobjects += $scps\n\t\t$countallscps = ($scps | measure-object).count\n\t\t}\n\nif($error)\n\t{ \"$(Get-TimeStamp) Error while retrieving Service Connection Point objects located in the configuration partition $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{   if($scps){\"$(Get-TimeStamp) Number of Service Connection Point objects located in the configuration partition retrieved via LDAP: $($countallscps)\" | out-file $logfilename -append}\n\t\telseif($scpsgc){\"$(Get-TimeStamp) Number of Service Connection Point objects located in the configuration partition retrieved via GC: $($countallscps)\" | out-file $logfilename -append}\n\t\telse{\"$(Get-TimeStamp) Number of Service Connection Point objects located in the configuration partition: $($countallscps)\" | out-file $logfilename -append}\n\t}\n\n#Retrieving server and ntdsdsa class objects located in the configuration partition (Domain Controllers)\n$dcrepls =  Get-ADObject -searchbase $root.configurationNamingContext -filter {(ObjectClass -eq 'Server') -or (ObjectClass -eq 'nTDSDSA')} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$dcrepls = Get-ADObject -ResultPageSize $resultspagesize -searchbase $root.configurationNamingContext -filter {(ObjectClass -eq 'Server') -or (ObjectClass -eq 'nTDSDSA')} -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($dcrepls){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $dcrepls\n$countdcrepls = ($dcrepls | measure-object).count\n$countserverd = ($deleteconf | where-object{$_.ObjectClass -eq 'Server'} | measure-object).count\n$countnTDSDSAd = ($deleteconf | where-object{$_.ObjectClass -eq 'nTDSDSA'} | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving server and ntdsdsa class objects located in the configuration partition and in the tombstone $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t\t\"$(Get-TimeStamp) Number of server and ntdsdsa class objects located in the configuration partition: $($countdcrepls)\" | out-file $logfilename -append\n\t\tif(($countnTDSDSAd -ge 1) -or ($countserverd -ge 1))\n\t\t\t{\"$(Get-TimeStamp) Domain Controller demotion or use of DCShadow: $($countserverd) deleted server objects and $($countnTDSDSAd) deleted nTDSDSA objects located in the tombstone\" | out-file $logfilename -append}\n\t}\n\n#Domain controller computer objects (existing en deleted)\n$OUDCs = \"OU=Domain Controllers,\" + $root.defaultNamingContext\n#Existing Domain controllers in current domain\n$DCpresents = Get-ADObject -searchbase $OUDCs -filter {(ObjectClass -eq 'Computer') -and ((PrimaryGroupID -eq 521) -or (PrimaryGroupID -eq 516))} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$DCpresents = Get-ADObject -ResultPageSize $resultspagesize -searchbase $OUDCs -filter {(ObjectClass -eq 'Computer') -and ((PrimaryGroupID -eq 521) -or (PrimaryGroupID -eq 516))} -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($DCpresents){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving existing domain controllers in current domain $($error)\" | out-file $logfilename -append ; $error.clear() }\n$countDCpresents = ($DCpresents | measure-object).count\n$criticalobjects += $DCpresents\n# Deleted domain controllers in current domain (tombstoned)\n$DCeffaces = Get-ADObject -searchbase $DeleteBase -filter {(IsDeleted -eq $true) -and (LastKnownParent -eq $OUDCs) -and (ObjectClass -eq 'Computer')} -IncludeDeletedObjects -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$DCeffaces = Get-ADObject -ResultPageSize $resultspagesize -searchbase $DeleteBase -filter {(IsDeleted -eq $true) -and (LastKnownParent -eq $OUDCs) -and (ObjectClass -eq 'Computer')} -IncludeDeletedObjects -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($DCeffaces){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving deleted domain controllers in current domain $($error)\" | out-file $logfilename -append ; $error.clear() }\n$countDCeffaces = ($DCeffaces| measure-object).count\n$criticalobjects +=  $DCeffaces\n# Retrieving existing domain controllers outside current domain and inside the current forest\n$ComputerCategory = \"CN=Computer,\" + $root.SchemaNamingContext\n$search = new-object System.DirectoryServices.DirectorySearcher\n$search.pagesize = 256\n$search.filter = \"(&(ObjectCategory=$($ComputerCategory))(|(PrimaryGroupID=521)(PrimaryGroupID=516)))\"\n$search.searchroot = [ADSI]\"GC://$($gc)\"\n$allDCs =  $search.findall() | Convert-ADSearchResult\n$otherDCs = $allDCs | where-object{$_.DistinguishedName -notlike \"*$($OUDCs)\"}\n$countallDCs = ($allDCs | measure-object).count\n$gcobjects += $otherDCs\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving domain controllers in the current forest via GC $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t\"$(Get-TimeStamp) Total number of existing domain controllers computer objects in the current forest: $($countallDCs)\"  | out-file $logfilename -append\n\t\"$(Get-TimeStamp) Total number of existing domain controllers computer objects in the current domain: $($countDCpresents)\"  | out-file $logfilename -append\n\t\"$(Get-TimeStamp) Total number of deleted domain controllers computer objects in the current domain: $($countDCeffaces)\"  | out-file $logfilename -append\n\t}\n\n\n#Objects with kerberos delegation configured\n$delegkrb = Get-ADObject -filter {(UserAccountControl -BAND 0x0080000) -OR (UserAccountControl -BAND 0x1000000) -OR (msDS-AllowedToDelegateTo -like \"*\") -OR (msDS-AllowedToActOnBehalfOfOtherIdentity -like \"*\")} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$delegkrb = Get-ADObject -ResultPageSize $resultspagesize -filter {(UserAccountControl -BAND 0x0080000) -OR (UserAccountControl -BAND 0x1000000) -OR (msDS-AllowedToDelegateTo -like \"*\") -OR (msDS-AllowedToActOnBehalfOfOtherIdentity -like \"*\")} -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($delegkrb){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$countdelegkrb = ($delegkrb | measure-object).count\n$delegkrbnoconstrained = $delegkrb | where-object{($_.UserAccountControl -BAND 0x0080000)}\n$countdelegkrbnoconstrained  = ($delegkrbnoconstrained | measure-object).count\n$criticalobjects += $delegkrb\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving objects trusted for Kerberos delegation: $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t\"$(Get-TimeStamp) Number of objects kerberos delegation setup: $($countdelegkrb) \"  | out-file $logfilename -append\n\t\"$(Get-TimeStamp) Number of objects with Kerberos unconstrained delegation configured: $($countdelegkrbnoconstrained) - $($countDCpresents) of them are domain controllers\"  | out-file $logfilename -append\n\t}\n\n\n#Directory Service Information object\n$DSInfo = \"CN=Directory Service,CN=Windows NT,CN=Services,\" + $root.configurationNamingContext\n$criticalobjects += Get-ADObject $DSInfo -Server $server -properties *\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving Directory Service Information object information $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t\"$(Get-TimeStamp) Directory Service Information object retrieved in the configuration partition \"  | out-file $logfilename -append\n\t}\n\n\n#Getting all existing and deleted DNS Zones\n$DNSZones = $root.namingcontexts | where-object{$_ -like \"*DnsZones,*\"} | foreach-object{get-adobject -searchbase $_ -Filter {ObjectClass -eq 'DNSZone'} -includedeletedobjects -properties * -server $server}\n$criticalobjects += $DNSZones\n$countDNSZones = ($DNSZones | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving DNS zones $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of existing and deleted DNS zones: $($countDNSZones)\" | out-file $logfilename -append}\n\n\n#Group Policy Objects, trusts, DPAPI secrets, AdminSDHolder, domainPolicy, RIDManager under the System container, GPO WMI Filters\n$sysroot = \"CN=System,\"  + ($root.defaultNamingContext)\n$sysobjects =  get-adobject -searchbase $sysroot -SearchScope SubTree -Filter {(ObjectClass -eq \"groupPolicyContainer\") -or (ObjectClass -eq \"trustedDomain\") -or (ObjectClass -eq \"msWMI-Som\") -or (ObjectClass  -eq \"rIDManager\")  -or (ObjectClass -eq \"secret\")  -or (ObjectClass -eq \"domainPolicy\") -or (Name -eq \"AdminSDHolder\")} -server $server -properties *\n\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$sysobjects = Get-ADObject -ResultPageSize $resultspagesize -searchbase $sysroot -SearchScope SubTree -Filter {(ObjectClass -eq \"groupPolicyContainer\") -or (ObjectClass -eq \"trustedDomain\")  -or (ObjectClass  -eq \"rIDManager\") -or (ObjectClass -eq \"secret\") -or (ObjectClass -eq \"domainPolicy\") -or (Name -eq \"AdminSDHolder\")} -server $server -properties *\n\t\t$i++\n\t\t}\n\tif($sysobjects){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $sysobjects\n$countsysobjects = ($sysobjects | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving objects under the system container $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\n\t$ridmanager = (((($sysobjects | where-object{$_.ObjectClass  -eq \"rIDManager\"}).fsmoRoleOwner).replace($root.configurationNamingContext,\"\")).replace(\"CN=NTDS Settings,\",\"\")).replace(\"CN=Sites,\",\"CN=Sites\")\n\t\"$(Get-TimeStamp) Number of objects of interest under the system container (GPOs, domain trusts, DPAPI secrets, AdminSDHolder, RID Manager, WMI filters and domainPolicy): $($countsysobjects)\" | out-file $logfilename -append\n}\n\n$adminSDHolder = $sysobjects | Where-Object{($_.Name -eq \"AdminSDHolder\") -and ($_.ObjectClass -eq \"Container\")}\nif($adminSDHolder)\n\t{\n\t$accountsACEadminSDHolder = ($adminSDHolder.ntsecuritydescriptor).getaccessrules($true , $true , [System.Security.Principal.SecurityIdentifier]) | Where-Object {$_.IdentityReference -like \"S-1-5-21-*\"} | group-object -property IdentityReference\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while retrieving accounts having an ACE on AdminSDHolder object $($error)\" | out-file $logfilename -append ; $error.clear() }\n\telse\n\t\t{\n\t\t$usrcount = 0\n\t\t$userACE = $null\n\t\tforeach($accountACE in $accountsACEadminSDHolder)\n\t\t\t{\n\t\t\t#If SID is from current domain launch LDAP query, otherwise try GC\n\t\t\tif($accountACE.Name -like \"$domSID*\")\n\t\t\t\t{\n\t\t\t\t$userACE = Get-ADObject -Filter {ObjectSID -eq $accountACE.Name} -Server $server -properties *\n\t\t\t\tif($userACE){$criticalobjects += $userACE}\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t\t\t$search.filter = \"(ObjectSID=$($accountACE.Name))\"\n\t\t\t\t$userACE = $search.findone() | Convert-ADSearchResult\n\t\t\t\tif($userACE){$gcobjects += $userACE}\n\t\t\t\t}\n\t\t\tif($error)\n\t\t\t\t{ \"$(Get-TimeStamp) Error while getting object SID $($accountACE.Name) with error $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\telse\n\t\t\t\t{#Check if objectclass is user\n\t\t\t\tif(($userACE.ObjectClass -eq \"user\") -or ($userACE.ObjectClass -eq \"inetOrgPerson\"))\n\t\t\t\t\t{$usrcount++\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\t\t \"$(Get-TimeStamp) Number of user accounts having an ACE on AdminSDHolder object: $($usrcount)\" | out-file $logfilename -append\n\t}\n\n#Loop through domain trusts and return their state\n$trusts = $sysobjects | where-object{$_.ObjectClass -eq \"trustedDomain\"}\n\nif($trusts)\n    {\n    $counttrusts = ($trusts | measure-object).count\n    \"$(Get-TimeStamp) Number of domain trusts: $($counttrusts)\" | out-file $logfilename -append\n\n    foreach($trust in $trusts)\n\t    {\n\t\t$sidfilt = \"enabled\"\n\t    if(([int32]$trust.trustattributes -band 0x00000004) -eq 0)\n\t\t    {\n\t\t    $sidfilt = \"disabled\"\n\t\t    }\n\t\tif(([int32]$trust.trustattributes -band 0x00000008) -eq 8)\n\t\t    {\n\t\t    $type = \"inter-forest\"\n\t\t    }\n\t\tif(([int32]$trust.trustattributes -band 0x00000032) -eq 32)\n\t\t    {\n\t\t    $type = \"forest internal\"\n\t\t    }\n\t\tif(([int32]$trust.trustattributes -band 0x00000016) -eq 16)\n\t\t    {\n\t\t    $type = \"cross org trust with selective authentication\"\n\t\t    }\n\t\tif(([int32]$trust.trustdirection) -eq 3)\n\t\t    {\n\t\t    $dir = \"both directions\"\n\t\t    }\n\t\tif(([int32]$trust.trustdirection) -eq 2)\n\t\t    {\n\t\t    $dir = \"outgoing\"\n\t\t    }\n\t\tif(([int32]$trust.trustdirection) -eq 1)\n\t\t    {\n\t\t    $dir = \"incoming\"\n\t\t    }\n\t\tif(([int32]$trust.trustdirection) -eq 0)\n\t\t    {\n\t\t    $dir = \"disabled\"\n\t\t    }\n\t\t\"$(Get-TimeStamp) The domain trust with $($trust.name) is $($type) and $($dir) , SID filtering is $($sidfilt)\" | out-file $logfilename -append\n\t    }\n    }\nelse\n    { \"$(Get-TimeStamp) No domain trusts to process\" | out-file $logfilename -append }\n\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving domain trusts $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n# Get all domain trusts of each domain in the forest through global catalog\n$ContSys = \"CN=System,\" + $root.defaultNamingContext\n$TrustCat = \"CN=Trusted-Domain,\" + $root.SchemaNamingContext\n$search = new-object System.DirectoryServices.DirectorySearcher\n$search.searchroot = [ADSI]\"GC://$($gc)\"\n$search.pagesize = 256\n$search.filter = \"(ObjectCategory=$($TrustCat))\"\n$allTrustsquery = $search.findall()\nif($allTrustsquery)\n\t{\n\t$allTrusts  = $allTrustsquery  | Convert-ADSearchResult\n\t$otherTrusts = $allTrusts | where-object{$_.DistinguishedName -notlike \"*$($ContSys)\"}\n\t$countallTrusts = ($allTrusts | group-object -property TrustPartner | measure-object).count\n\t$gcobjects += $otherTrusts\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while retrieving domain trusts of each domain in the forest through GC $($error)\" | out-file $logfilename -append ; $error.clear() }\n\telse {\"$(Get-TimeStamp) Number of trust partners in the forest: $($countallTrusts)\" | out-file $logfilename -append}\n\t}\n\n# Get all domain roots in the forest through global catalog\n$DomainCat = \"CN=Domain-DNS,\" + $root.SchemaNamingContext\n$search = new-object System.DirectoryServices.DirectorySearcher\n$search.searchroot = [ADSI]\"GC://$($gc)\"\n$search.pagesize = 256\n$search.filter = \"(ObjectCategory=$($DomainCat))\"\n$alldomains = $search.findall()  | Convert-ADSearchResult\n$otherdomains = $alldomains | where-object{$_.DistinguishedName -ne $root.DefaultNamingContext}\n$gcobjects += $otherdomains\n$countallDomains = ($alldomains  | measure-object).count\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while retrieving forest domain roots through GC $($error)\" | out-file $logfilename -append ; $error.clear() }\n\telse {\"$(Get-TimeStamp) Number of domain roots located in the forest: $($countallDomains)\" | out-file $logfilename -append}\n\n# Processing SID History accounts\n# Get all accounts with SIDHistory present in the forest, limit properties loaded (DN,SID,SIDHistory) for performance\n$search = new-object System.DirectoryServices.DirectorySearcher\n$search.filter = \"(SIDHistory=*)\"\n$search.pagesize = 256\n$search.searchroot = [ADSI]\"GC://$($gc)\"\n$search.PropertiesToLoad.Addrange(('DistinguishedName','SIDHistory','objectSID'))\n$allSIDHistory  = $search.findall() | Convert-ADSearchResult\n$countSIDHistory = ($allSIDHistory | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving accounts with SID History through GC $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of accounts with SIDHistory in the forest: $($countSIDHistory)\" | out-file $logfilename -append}\n\n#Get accounts in the current domain with a suspicious SIDHistory: Meaning with a SIDHistory of its own domain or a well known SID with high privileges\n$CurrDomainSIDHistory = $allSIDHistory | where-object {($_.objectSID -like \"$domSID*\") -and (($_.SIDHistory -like \"*$domSID*\") -or ($_.SIDHistory -like \"*-500\") -or ($_.SIDHistory -eq \"S-1-5-32-548\") -or ($_.SIDHistory -eq \"S-1-5-32-544\") -or ($_.SIDHistory -eq \"S-1-5-32-551\") -or ($_.SIDHistory -like \"*-512\") -or ($_.SIDHistory -like \"*-516\") -or ($_.SIDHistory -like \"*-519\") -or ($_.SIDHistory -eq \"S-1-5-32-550\") -or ($_.SIDHistory -like \"*-498\") -or ($_.SIDHistory -like \"*-518\")  -or ($_.SIDHistory -eq \"S-1-5-32-549\"))}\nif($CurrDomainSIDHistory)\n\t{\n\t$NbCurrDomainSIDHistory = ($CurrDomainSIDHistory | measure-object).count\n\t \"$(Get-TimeStamp) Number of accounts with a suspicious SIDHistory in the current domain: $($NbCurrDomainSIDHistory)\" | out-file $logfilename -append\n\t foreach($objSIDH in $CurrDomainSIDHistory)\n\t\t{\n\t\t$criticalobjects += get-adobject $objSIDH.DistinguishedName -Server $server -properties *\n\t\tif($error){ \"$(Get-TimeStamp) Error while retrieving accounts with a suspicious SIDHistory in the current domain $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t}\n\t}\n\n# Get accounts in other domains than the current one within the forest which have an SIDHistory belonging to the current domain.\n$OtherDomainSIDHistory = $allSIDHistory | where-object {($_.objectSID -notlike \"$domSID*\") -and ($_.SIDHistory -like \"*$domSID*\")}\nif($OtherDomainSIDHistory)\n\t{\n\t# Get SIDs of accounts protected by SDProp in the current domain (i.e. privileged accounts)\n\t$sensibeSID = ($SDPropObjects | where-object{$_.objectSID -like \"$domSID*\"} | select-object -expandproperty objectSID).value\n\t$DangerOtherDomainSIDHistory = @()\n\t$NbOtherDomainSIDHistory = ($OtherDomainSIDHistory | measure-object).count\n\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\"$(Get-TimeStamp) Number of accounts in other domains within the forest which have an SIDHistory belonging to the current domain $($NbOtherDomainSIDHistory)\" | out-file $logfilename -append\n\t# Foreach account in other domains within the forest which have an SIDHistory belonging to the current domain we compare his SIDHistory with SIDs of accounts protected in the current domain by SDProp. If there is a match that could be suspicious.\n\tforeach($objSIDH in $OtherDomainSIDHistory)\n\t\t\t{\n\t\t\tforeach($SIDH in $objSIDH.SIDHistory)\n\t\t\t\t{\n\n\t\t\t\tif($sensibeSID.contains($SIDH))\n\t\t\t\t\t{\n\t\t\t\t\t$search.filter = \"(DistinguishedName=$($objSIDH.DistinguishedName))\"\n\t\t\t\t\t$DangerOtherDomainSIDHistory += $search.findone() | Convert-ADSearchResult\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tif($error){ \"$(Get-TimeStamp) Error while retrieving accounts in other domains within the forest which have an SIDHistory belonging to the current domain $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\t\t}\n\tif($DangerOtherDomainSIDHistory)\n\t\t{\n\t\t$nbDangerOtherDomainSIDHistory = ($DangerOtherDomainSIDHistory | measure-object).count\n\t\t\"$(Get-TimeStamp) Number of accounts in the forest with a suspicious SIDHistory value matching the current domain: $($nbDangerOtherDomainSIDHistory)\" | out-file $logfilename -append\n\t\t$gcobjects += $DangerOtherDomainSIDHistory\n\t\t}\n\t}\n\n\n\n#Fetch Organizational Units Objects, do not load all poperties for performance issues\n$objOUs = Get-ADObject  -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -Filter {ObjectClass -eq \"organizationalUnit\"}  -Server $server\n\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$objOUs = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -Filter {ObjectClass -eq \"organizationalUnit\"}  -Server $server\n\t\t$i++\n\t\t}\n\tif($objOUs){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\nif($error)\n    \t{ \"$(Get-TimeStamp) Error while retrieving OUs $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t$countobjOUs = ($objOUs | measure-object).count\n\t#If there is more than 1000 OUs we take only the level 1 + level 2 OUs and load all properties\n\tif($countobjOUs -ge 1000)\n\t\t{\n\t\t\"$(Get-TimeStamp) Total number of OUs: $($countobjOUs), only level 1 and 2 OUs will be processed\" | out-file $logfilename -append\n\t\t$OULevel1 = Get-ADObject -SearchBase ($root.defaultNamingContext) -SearchScope OneLevel -Server $server  -filter {ObjectClass -eq \"organizationalUnit\"} -properties *\n\t\tif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t\t\t{\n\t\t\t$i = 1\n\t\t\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t\t\t{\n\t\t\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t\t\t$resultspagesize = 256 - $i * 40\n\t\t\t\t$error.clear()\n\t\t\t\t$OULevel1 = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.defaultNamingContext) -SearchScope OneLevel -Server $server  -filter {ObjectClass -eq \"organizationalUnit\"} -properties *\n\t\t\t\t$i++\n\t\t\t\t}\n\t\t\tif($OULevel1){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\t\t\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t\t\t}\n\t\t$totalOU = ($OULevel1 | measure-object).count\n\t\t$criticalobjects += $OULevel1\n\t\tif($error)\n    \t\t\t{ \"$(Get-TimeStamp) Error while retrieving level 1 OUs $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\tforeach($OU in $OULevel1)\n\t\t\t{\n\t\t\t$OULevel2 = Get-ADObject -SearchBase ($OU.DistinguishedName) -SearchScope OneLevel -Server $server  -filter {ObjectClass -eq \"organizationalUnit\"} -properties *\n\n\t\t\tif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t\t\t\t{\n\t\t\t\t$i = 1\n\t\t\t\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t\t\t\t{\n\t\t\t\t\t$resultspagesize = 256 - $i * 40\n\t\t\t\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t\t\t\t$error.clear()\n\t\t\t\t\t$OULevel2 = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($OU.DistinguishedName) -SearchScope OneLevel -Server $server  -filter {ObjectClass -eq \"organizationalUnit\"} -properties *\n\t\t\t\t\t$i++\n\t\t\t\t\t}\n\t\t\t\tif($OULevel2){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\t\t\t\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t\t\t\t}\n\t\t\t$totalOU = $totalOU + ($OULevel2 | measure-object).count\n\t\t\t$criticalobjects += $OULevel2\n\t\t\tif($error)\n    \t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving level 2 OUs $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t}\n\n\t\t\"$(Get-TimeStamp) Total number of OUs processed: $($totalOU)\" | out-file $logfilename -append\n\t\t}\n\telse\n\t\t{\n\t\t#Less than 1000 OUs we process every OU and load all properties\n\t\t\"$(Get-TimeStamp) Total number of OUs: $($countobjOUs)\" | out-file $logfilename -append\n\t\t$objOUsfull = Get-ADObject  -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -Filter {ObjectClass -eq \"organizationalUnit\"}  -Server $server -Properties *\n\t\tif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t\t\t{\n\t\t\t$i = 1\n\t\t\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t\t\t{\n\t\t\t\t$resultspagesize = 256 - $i * 40\n\t\t\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t\t\t$error.clear()\n\t\t\t\t$objOUsfull = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -Filter {ObjectClass -eq \"organizationalUnit\"}  -Server $server -Properties *\n\t\t\t\t$i++\n\t\t\t\t}\n\t\t\tif($objOUsfull){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\t\t\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t\t\t}\n\t\t$criticalobjects += $objOUsfull\n\t\tif($error)\n    \t\t\t{ \"$(Get-TimeStamp) Error while retrieving OUs $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t}\n\t}\n\n\n#Get AD replication sites, CertificationAuthority, pKIEnrollmentService, msDS-AuthNPolicySilo, msDS-AuthNPolicy and CrossRefs objects in the configuration partition\n$sitesIGC = get-adobject -searchbase $root.configurationNamingContext -SearchScope SubTree -Filter {(ObjectClass -eq \"CertificationAuthority\") -or (ObjectClass -eq \"pKIEnrollmentService\") -or (ObjectClass -eq \"msDS-AuthNPolicySilo\") -or (ObjectClass -eq \"msDS-AuthNPolicy\") -or (ObjectClass -eq \"site\") -or (ObjectClass -eq \"crossRefContainer\") -or (ObjectClass -eq \"crossRef\")} -server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$sitesIGC = Get-ADObject -ResultPageSize $resultspagesize -searchbase $root.configurationNamingContext -SearchScope SubTree -Filter {(ObjectClass -eq \"CertificationAuthority\") -or (ObjectClass -eq \"pKIEnrollmentService\") -or (ObjectClass -eq \"msDS-AuthNPolicySilo\") -or (ObjectClass -eq \"msDS-AuthNPolicy\") -or (ObjectClass -eq \"site\") -or (ObjectClass -eq \"crossRefContainer\") -or (ObjectClass -eq \"crossRef\")} -server $server -properties *\n\t\t$i++\n\t\t}\n\tif($sitesIGC){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects +=  $sitesIGC\n$countADreplsites = ($sitesIGC | where-object{$_.ObjectClass -eq \"site\"} |  measure-object).count\n$countpKIEnrollmentService = ($sitesIGC | where-object{$_.ObjectClass -eq \"pKIEnrollmentService\"} |  measure-object).count\n$countADIGC = ($sitesIGC | where-object{$_.ObjectClass -eq \"CertificationAuthority\"} |  measure-object).count\n$countAuthN = ($sitesIGC | where-object{($_.ObjectClass -eq \"msDS-AuthNPolicySilo\") -or ($_.ObjectClass -eq \"msDS-AuthNPolicy\")} |  measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving AD replication sites, CertificationAuthority, pKIEnrollmentService, msDS-AuthNPolicy and msDS-AuthNPolicysilos objects $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\n\t\"$(Get-TimeStamp) Number of AD replication sites in the configuration partition: $($countADreplsites)\" | out-file $logfilename -append\n\t\"$(Get-TimeStamp) Number of CertificationAuthority objects in the configuration partition: $($countADIGC)\" | out-file $logfilename -append\n\t\"$(Get-TimeStamp) Number of pKIEnrollmentService objects in the configuration partition: $($countpKIEnrollmentService)\" | out-file $logfilename -append\n\t\"$(Get-TimeStamp) Number of AuthNPolicy or silos objects in the configuration partition: $($countAuthN)\" | out-file $logfilename -append\n\t$crossrefcontainer = $sitesIGC | where-object{($_.Name -eq \"Partitions\") -and ($_.ObjectClass -eq \"crossRefContainer\")}\n\t$DomainNamingMaster = (((($crossrefcontainer.fsmoRoleOwner).replace($root.configurationNamingContext,\"\")).replace(\"CN=NTDS Settings,\",\"\")).replace(\"CN=Sis,\",\"\")).replace(\"CN=Sites,\",\"CN=Sites\")\n\t}\n\n\n# Displayin FSMO role holders and FFL + DFL\nif($PDCe)\n\t{ \"$(Get-TimeStamp) PDCe for the domain is: $($PDCe)\" | out-file $logfilename -append}\nif($inframaster)\n\t{ \"$(Get-TimeStamp) Infrastructure master for the domain is: $($inframaster)\" | out-file $logfilename -append}\nif($ridmanager)\n\t{ \"$(Get-TimeStamp) RID Manager for the domain is: $($ridmanager)\" | out-file $logfilename -append}\nif($DomainNamingMaster)\n\t{ \"$(Get-TimeStamp) Domain naming master for the forest is: $($DomainNamingMaster)\" | out-file $logfilename -append}\nif($SchemaMaster)\n\t{ \"$(Get-TimeStamp) Schema master for the forest is: $($SchemaMaster)\" | out-file $logfilename -append}\nif($crossrefcontainer)\n\t{ \"$(Get-TimeStamp) Forest functional level is: $($crossrefcontainer.\"msDS-Behavior-Version\")\" | out-file $logfilename -append}\n$refdomains = $sitesIGC | where-object{($_.Objectclass -eq \"crossRef\") -and ($_.SystemFlags -eq 3)}\nif($refdomains)\n\t{\n\tforeach($refdomain in $refdomains){ \"$(Get-TimeStamp) $($refdomain.dnsRoot) domain functional level is $($refdomain.\"msDS-Behavior-Version\")\" | out-file $logfilename -append}\n\t}\n\n#Find user accounts sensitive to Kerberoast attack (Service Principal Name not null)\n$ObjCategoryusr = \"CN=Person,\" + ($root.schemaNamingContext)\n$kerberoast = Get-ADObject -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -LDAPFilter \"(&(objectCategory=$ObjCategoryusr)(ServicePrincipalName=*))\" -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$kerberoast = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -LDAPFilter \"(&(objectCategory=$ObjCategoryusr)(ServicePrincipalName=*))\" -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($kerberoast){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $kerberoast\n$kerberoastcount = ($kerberoast | where-object{($_.Name -ne \"krbtgt\")} | measure-object).count\n$kerberoastadmcount = ($kerberoast | where-object{($_.Name -ne \"krbtgt\") -and ($_.Admincount -eq 1)} | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving kerberoastable accounts  $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t\t\"$(Get-TimeStamp) Number of kerberoastable accounts: $($kerberoastcount)\" | out-file $logfilename -append\n\t\tif($kerberoastadmcount -ge 1)\n\t\t\t{\"$(Get-TimeStamp) Number of kerberoastable accounts protected by SDProp: $($kerberoastadmcount)\" | out-file $logfilename -append}\n\t}\n\n#Find user accounts sensitive to AS-REP roast attack\n$asreproast = Get-ADObject -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -ldapfilter {(&(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=4194304))} -Server $server -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$resultspagesize = 256 - $i * 40\n\t\t$error.clear()\n\t\t$asreproast = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -ldapfilter {(&(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=4194304))}  -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($asreproast){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects += $asreproast\n$asreproastcount = ($asreproast | measure-object).count\n$asreproastadmcount = ($asreproast | where-object {($_.Admincount -eq 1)} | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving AS-Rep roastables accounts  $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t\t\"$(Get-TimeStamp) Number of AS-Rep roastables accounts: $($asreproastcount)\" | out-file $logfilename -append\n\t\tif($asreproastadmcount -ge 1)\n\t\t\t{\"$(Get-TimeStamp) Number of AS-Rep roastable accounts protected by SDProp: $($asreproastadmcount)\" | out-file $logfilename -append}\n\t}\n\n\n#Get Extended rights defined in the Configuration partition\n$extroot = \"CN=Extended-Rights,\" +  $root.configurationNamingContext\n$extrights = Get-ADObject -SearchBase $extroot -SearchScope OneLevel -Server $server -filter {ObjectClass -eq \"controlAccessRight\"} -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$extrights = Get-ADObject -ResultPageSize $resultspagesize -SearchBase $extroot -SearchScope OneLevel -Server $server -filter * -properties *\n\t\t$i++\n\t\t}\n\tif($extrights){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects +=  $extrights\n$countextrights = ($extrights | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving extended rights $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of extended rights: $($countextrights)\" | out-file $logfilename -append}\n\n\n# Get schema attributes with Searchflags marked as confidential\n$confidattr = Get-ADObject -SearchBase $root.SchemaNamingContext  -SearchScope OneLevel -Server $server -filter {(SearchFlags -BAND 0x00000080) -and (ObjectClass -eq \"attributeSchema\")} -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$confidattr = Get-ADObject -ResultPageSize $resultspagesize -SearchBase $root.SchemaNamingContext  -SearchScope OneLevel -Server $server -filter {(SearchFlags -BAND 0x00000080) -and (ObjectClass -eq \"attributeSchema\")} -properties *\n\t\t$i++\n\t\t}\n\tif($extrights){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects +=  $confidattr\n$countconfidattr = ($confidattr | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving schema attributes marked as confidential $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse\n\t{\n\t\"$(Get-TimeStamp) Number of schema attributes marked as confidential: $($countconfidattr)\" | out-file $logfilename -append\n\t$laps = $confidattr | where-object{$_.Name -eq \"ms-Mcs-AdmPwd\"}\n\tif($laps)\n\t\t{\"$(Get-TimeStamp) LAPS is setup in this forest and ms-Mcs-AdmPwd is marked as confidential\" | out-file $logfilename -append}\n\telse\n\t\t{\"$(Get-TimeStamp) LAPS is not setup in the forest or ms-Mcs-AdmPwd is not marked as confidential\" | out-file $logfilename -append}\n\t$bitlocker = $confidattr | where-object{$_.Name -eq \"ms-FVE-RecoveryPassword\"}\n\tif($bitlocker)\n\t\t{\"$(Get-TimeStamp) Bitlocker recovery key attribute is marked as confidential\" | out-file $logfilename -append}\n\telse\n\t\t{\"$(Get-TimeStamp) Bitlocker recovery key attribute is not marked as confidential\" | out-file $logfilename -append}\n\t}\n\n\n# Get schema attributes with Searchflags marked as never audit\n$neveraudit = Get-ADObject -SearchBase $root.SchemaNamingContext  -SearchScope OneLevel -Server $server -filter {(SearchFlags -BAND 0x00000100) -and (ObjectClass -eq \"attributeSchema\")} -properties *\nif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$neveraudit = Get-ADObject -ResultPageSize $resultspagesize -SearchBase $root.SchemaNamingContext  -SearchScope OneLevel -Server $server -filter {(SearchFlags -BAND 0x00000100) -and (ObjectClass -eq \"attributeSchema\")} -properties *\n\t\t$i++\n\t\t}\n\tif($extrights){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$criticalobjects +=  $neveraudit\n$countneveraudit = ($neveraudit | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving schema attributes marked as never to audit $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\"$(Get-TimeStamp) Number of schema attributes marked as never to audit: $($countneveraudit)\" | out-file $logfilename -append}\n\n\n\n#Check if current domain is root or child domain. if child domain get domain, enterprise, schema admins of root domain\nif($root.rootDomainNamingContext -eq $root.DefaultNamingContext)\n\t{\n\t\"$(Get-TimeStamp) Current domain is the root domain\" | out-file $logfilename -append\n\t}\nElse\n\t{\n\t\"$(Get-TimeStamp) Current domain is a child domain\" | out-file $logfilename -append\n\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t$search.searchroot = [ADSI]\"GC://$($gc)/$($root.rootDomainNamingContext)\"\n\t$search.searchscope = \"Base\"\n\t$search.filter = \"(ObjectSID=*)\"\n\t$rootdom = $search.Findone() | Convert-ADSearchResult\n\t$gcobjects  += $rootdom\n\t$rootdomSID = $rootdom.ObjectSID\n\t$rootDomadmSID = $rootdomSID + \"-512\"\n\t$rootEntadmSID = $rootdomSID + \"-519\"\n\t$rootSchemaSID = $rootdomSID + \"-518\"\n\t#Cannot retrieve privileged accounts via SDProp, because AdminCount is not in partial attribute set, getting by group membership.\n\t#Retrieving the domain admins group which is global: cannot get members via GC\n\t$search.searchscope = \"Subtree\"\n\t$search.filter = \"(ObjectSID=$($rootDomadmSID))\"\n\t$rootda = $search.Findone() | Convert-ADSearchResult\n\t$gcobjects += $rootda\n\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving domain admins group in root domain $($error)\" | out-file $logfilename -append ; $error.clear() }\n\telse\n\t\t\t{\"$(Get-TimeStamp) Domain admins group sucessfully retrieved in root domain\" | out-file $logfilename -append}\n\t#Retrieving the schema and enterprise admins groups which are universal: we can retrieve members via GC\n\t$search.filter = \"(|(ObjectSID=$($rootEntadmSID))(ObjectSID=$($rootSchemaSID)))\"\n\t$rootUadmins = $search.FindAll() | Convert-ADSearchResult\n\t$gcobjects += $rootUadmins\n\t$countrootadminsmembers = 0\n\tforeach($rootadmin in $rootUadmins)\n\t\t{\n\t\t$rootadminsmembers = $null\n\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\tif($rootadmin.Member){$rootadminsmembers = $rootadmin.Member | foreach-object{$search.filter = \"(DistinguishedName=$($_))\"; $search.FindOne() | Convert-ADSearchResult}}\n\t\t$countrootadminsmembers = ($rootadminsmembers | measure-object).count + $countrootadminsmembers\n\t\t$gcobjects += $rootadminsmembers\n\t\t}\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving enterprise and schema admins members located in the root domain $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\telse\n\t\t\t{\"$(Get-TimeStamp) Number of level 1 enterprise and schema admins members located in the root domain: $($countrootadminsmembers)\" | out-file $logfilename -append}\n\t}\n\n\n$IsADFS = $false\n$IsADFSroot = $false\n$IsADFScurrent = $false\n#Processing ADFS\nif($root.rootDomainNamingContext -eq $root.DefaultNamingContext)\n\t{\n\t#If root domain just check ADFS in current domain\n\t$ADFS = \"CN=ADFS,CN=Microsoft,CN=Program Data,\" + ($root.DefaultNamingContext)\n\t$IsADFS = [ADSI]::Exists(\"GC://$($gc)/$($ADFS)\")\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while testing existance of ADFS objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\tif($IsADFS -eq $true)\n\t\t{\n\t\t#Current domain is root domain using LDAP to retrieve ADFS Objects\n\t\t$ADFSObjects = get-ADObject -searchbase $ADFS -filter * -server $server -properties *\n\n\t\tif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t\t\t{\n\t\t\t$i = 1\n\t\t\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t\t\t{\n\t\t\t\t$resultspagesize = 256 - $i * 40\n\t\t\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t\t\t$error.clear()\n\t\t\t\t$ADFSObjects = Get-ADObject -ResultPageSize $resultspagesize -searchbase $ADFS -filter * -server $server -properties *\n\t\t\t\t$i++\n\t\t\t\t}\n\t\t\tif($ADFSObjects){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\t\t\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t\t\t}\n\t\t$criticalobjects +=  $ADFSObjects\n\t\t$ADFSFarms = $ADFSObjects | Where-Object{($_.ObjectClass -eq \"Container\") -and ($_.Name -ne \"ADFS\")}\n\t\t$ADFSrootobj = $ADFSObjects | Where-Object{($_.ObjectClass -eq \"Container\") -and ($_.Name -eq \"ADFS\")}\n\t\t$countADFSFarms = ( $ADFSFarms | measure-object).count\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving ADFS Objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\telse {\"$(Get-TimeStamp) Number of ADFS farms (containers) in the current domain: $($countADFSFarms)\" | out-file $logfilename -append}\n\n\t\t# If ADFS farms are found searching for service accounts running ADFS, ACE is present on objects storing DKM information\n\t\tif($ADFSFarms -and $ADFSrootobj)\n\t\t\t{\n\t\t\t$accountsACEADFSRoot = \t($ADFSrootobj.ntsecuritydescriptor).getaccessrules($true , $true , [System.Security.Principal.SecurityIdentifier]) | Where-Object {$_.IdentityReference -like \"S-1-5-21-*\"} | group-object -property IdentityReference\n\t\t\tforeach($ADFSFarm in $ADFSFarms)\n\t\t\t\t{\n\t\t\t\t#Comparing ACL of ADFS root object and child objects (i.e) farms in order to retrieve ADFS service accounts\n\t\t\t\t$accountsACEADFSFarm = ($ADFSFarm.ntsecuritydescriptor).getaccessrules($true , $true , [System.Security.Principal.SecurityIdentifier]) | Where-Object {$_.IdentityReference -like \"S-1-5-21-*\"} | group-object -property IdentityReference\n\t\t\t\t$compareACEfarmroot = compare-object $accountsACEADFSFarm $accountsACEADFSRoot -Property Name\n\t\t\t\tif($error)\n\t\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving accounts having an ACE on ADFS Farm object $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t$userACE = $null\n\t\t\t\t\tforeach($accountACE in $compareACEfarmroot)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t#If ACE for the given SID is in the current domain, use LDAP\n\t\t\t\t\t\tif($accountACE.Name -like \"$domSID*\")\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sidtomatch = $accountACE.Name\n\t\t\t\t\t\t\t$userACE = Get-ADObject -Filter {ObjectSID -eq $sidtomatch} -Server $server -properties *\n\t\t\t\t\t\t\tif($userACE){$criticalobjects += $userACE}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t#Otherwise try GC\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t\t\t\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t\t\t\t\t\t$sidtomatch = $accountACE.Name\n\t\t\t\t\t\t\t$search.filter = \"(ObjectSID=$($sidtomatch))\"\n\t\t\t\t\t\t\t$userACE = $search.findone() | Convert-ADSearchResult\n\t\t\t\t\t\t\tif($userACE){$gcobjects += $userACE}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tif($error)\n\t\t\t\t\t\t\t{ \"$(Get-TimeStamp) Error while getting object SID $($accountACE.Name) with error $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\n\n\t}\nelse\n\t{\n\t#Domain is child domain. Check if ADFS is in current domain or parent domain.\n\t$ADFSroot = \"CN=ADFS,CN=Microsoft,CN=Program Data,\" + ($root.rootDomainNamingContext)\n\t$IsADFSroot = [ADSI]::Exists(\"GC://$($gc)/$($ADFSroot)\")\n\t$ADFScurrent = \"CN=ADFS,CN=Microsoft,CN=Program Data,\" + ($root.DefaultNamingContext)\n\t$IsADFScurrent = [ADSI]::Exists(\"GC://$($gc)/$($ADFScurrent)\")\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while testing existance of ADFS objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\tif($IsADFSroot -eq $true)\n\t\t{\n\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t$search.searchroot = [ADSI]\"GC://$($gc)/$($ADFSroot)\"\n\t\t$search.pagesize = 256\n\t\t$search.filter = \"(ObjectClass=*)\"\n\t\t$ADFSObjects = $search.FindAll() | Convert-ADSearchResult\n\t\t$gcobjects +=  $ADFSObjects\n\t\t$ADFSFarms = $ADFSObjects | Where-Object{($_.ObjectClass -eq \"Container\") -and ($_.Name -ne \"ADFS\")}\n\t\t$countADFSFarms = ( $ADFSFarms | measure-object).count\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving ADFS Objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\telse {\"$(Get-TimeStamp) Number of ADFS farms (containers) in the root domain: $($countADFSFarms)\" | out-file $logfilename -append}\n\t\t}\n\tif($IsADFScurrent -eq $true)\n\t\t{\n\t\t$ADFSObjects = get-ADObject -searchbase $ADFScurrent -filter * -server $server -properties *\n\t\tif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t\t\t{\n\t\t\t$i = 1\n\t\t\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t\t\t{\n\t\t\t\t$resultspagesize = 256 - $i * 40\n\t\t\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t\t\t$error.clear()\n\t\t\t\t$ADFSObjects = Get-ADObject -ResultPageSize $resultspagesize -searchbase $ADFS -filter * -server $server -properties *\n\t\t\t\t$i++\n\t\t\t\t}\n\t\t\tif($ADFSObjects){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\t\t\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t\t\t}\n\t\t$criticalobjects +=  $ADFSObjects\n\t\t$ADFSFarms = $ADFSObjects | Where-Object{($_.ObjectClass -eq \"Container\") -and ($_.Name -ne \"ADFS\")}\n\t\t$ADFSrootobj = $ADFSObjects | Where-Object{($_.ObjectClass -eq \"Container\") -and ($_.Name -eq \"ADFS\")}\n\t\t$countADFSFarms = ( $ADFSFarms | measure-object).count\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving ADFS Objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\telse {\"$(Get-TimeStamp) Number of ADFS farms (containers) in the current domain: $($countADFSFarms)\" | out-file $logfilename -append}\n\n\t\t# If ADFS farms are found searching for service accounts running ADFS, ACE is present on objects storing DKM information\n\t\tif($ADFSFarms -and $ADFSrootobj)\n\t\t\t{\n\t\t\t$accountsACEADFSRoot = \t($ADFSrootobj.ntsecuritydescriptor).getaccessrules($true , $true , [System.Security.Principal.SecurityIdentifier]) | Where-Object {$_.IdentityReference -like \"S-1-5-21-*\"} | group-object -property IdentityReference\n\t\t\tforeach($ADFSFarm in $ADFSFarms)\n\t\t\t\t{\n\t\t\t\t#Comparing ACL of ADFS root object and child objects (i.e) farms in order to retrieve ADFS service accounts\n\t\t\t\t$accountsACEADFSFarm = ($ADFSFarm.ntsecuritydescriptor).getaccessrules($true , $true , [System.Security.Principal.SecurityIdentifier]) | Where-Object {$_.IdentityReference -like \"S-1-5-21-*\"} | group-object -property IdentityReference\n\t\t\t\t$compareACEfarmroot = compare-object $accountsACEADFSFarm $accountsACEADFSRoot -Property Name\n\t\t\t\tif($error)\n\t\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving accounts having an ACE on ADFS Farm object $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t$userACE = $null\n\t\t\t\t\tforeach($accountACE in $compareACEfarmroot)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t#If ACE for the given SID is in the current domain, use LDAP\n\t\t\t\t\t\tif($accountACE.Name -like \"$domSID*\")\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sidtomatch = $accountACE.Name\n\t\t\t\t\t\t\t$userACE = Get-ADObject -Filter {ObjectSID -eq $sidtomatch} -Server $server -properties *\n\t\t\t\t\t\t\tif($userACE){$criticalobjects += $userACE}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t#Otherwise try GC\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t\t\t\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t\t\t\t\t\t$sidtomatch = $accountACE.Name\n\t\t\t\t\t\t\t$search.filter = \"(ObjectSID=$($sidtomatch))\"\n\t\t\t\t\t\t\t$userACE = $search.findone() | Convert-ADSearchResult\n\t\t\t\t\t\t\tif($userACE){$gcobjects += $userACE}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\tif($error)\n\t\t\t\t\t\t\t{ \"$(Get-TimeStamp) Error while getting object SID $($accountACE.Name) with error $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\n\n#Check if MS Exchange is installed by testing the Exchange Trusted SubSystem (ETS) existance\n$trustedSubSystem = \"CN=Exchange Trusted Subsystem,OU=Microsoft Exchange Security Groups,\" + ($root.rootDomainNamingContext)\n$ISets = [ADSI]::Exists(\"GC://$($gc)/$($trustedSubSystem)\")\n$serviceNC = \"CN=Services,\" + ($root.configurationNamingContext)\n$RBAC = $null\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving Exchange trusted subsystem  object $($error)\" | out-file $logfilename -append ; $error.clear() }\n\nif($ISets -eq $true)\n\t{\n\t$exchschemaverpath = \"CN=ms-Exch-Schema-Version-Pt,\" + ($root.schemaNamingContext)\n\t$exchschemaver = get-adobject $exchschemaverpath -server $server -properties *\n\t$criticalobjects += $exchschemaver\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while retrieving Exchange schema version $($error)\" | out-file $logfilename -append ; $error.clear() }\n\telse {\"$(Get-TimeStamp) Exchange schema version is: $($exchschemaver.rangeUpper)\" | out-file $logfilename -append}\n\n\tif($root.rootDomainNamingContext -eq $root.DefaultNamingContext)\n\t\t{\n\t\t# If current domain is root domain, we do not need GC to retrieve Exchange objects information.\n\t\t$ets = get-adobject $trustedSubSystem -server $server -properties *\n\t\t$criticalobjects += $ets\n\t\t\"$(Get-TimeStamp) Retrieving Exchange Trusted Subsytem, Exchange servers and Exchange Windows Permissions groups\" | out-file $logfilename -append\n\t\t$Winperm = \"CN=Exchange Windows Permissions,OU=Microsoft Exchange Security Groups,\" + ($root.rootDomainNamingContext)\n\t\t$ExcSRV = \"CN=Exchange Servers,OU=Microsoft Exchange Security Groups,\" + ($root.rootDomainNamingContext)\n\t\t$criticalobjects += get-adobject $Winperm -server $server -properties *\n\t\t$criticalobjects += get-adobject $ExcSRV -server $server -properties *\n\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving Exchange Trusted Subsytem or Exchange servers or Exchange Windows Permissions groups $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\tif($isonline -eq $true)\n\t\t\t{\n\t\t\t$trustedsubsysmembers = (Get-ADGroupMember -recursive $ets -server $server  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t\t$criticalobjects += $trustedsubsysmembers\n\t\t\t$nestedgrp = @()\n\t\t\t$level1 = Get-ADGroupMember $ets -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName\n\t\t\tif($level1)\n\t\t\t\t{\n\t\t\t\t$nestedgrp += $level1\n\t\t\t\t$nestedgrp  += $level1 | foreach-object{Get-ADGroupMember $_.DistinguishedName -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName}\n\t\t\t\t$criticalobjects += ($nestedgrp | foreach-object{get-adobject $_.DistinguishedName -server $server -properties *})\n\t\t\t\t}\n\t\t\t\t$counttrustedsubsysmembers = ($trustedsubsysmembers | measure-object).count\n\t\t\t\tif($error)\n\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving ETS members $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\telse\n\t\t\t\t{\"$(Get-TimeStamp) Number of  ETS members: $($counttrustedsubsysmembers)\" | out-file $logfilename -append}\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\t$trustedsubsysmembers = ($ets | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t\t$criticalobjects += $trustedsubsysmembers\n\t\t\t$continue = $trustedsubsysmembers | where-object{$_.ObjectClass -eq \"Group\"}\n\t\t\tif($continue)\n\t\t\t\t{foreach($grp in $continue){$trustedsubsysmembersn2 = $grp | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *};$criticalobjects += $trustedsubsysmembersn2}}\n\t\t\tif($error)\n\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving ETS members $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\telse\n\t\t\t\t{\"$(Get-TimeStamp) ETS members processed, getting nested groups till level 2 \" | out-file $logfilename -append}\n\t\t\t}\n\t\t# Fetching transport rules, accepted domains, remote domains, hybrid relationship, SMTP connectors, and Mailbox databases\n\t\t$countSMTP = 0\n\t\t$SMTP = Get-ADObject -searchbase $root.configurationNamingContext -filter {(ObjectClass -eq \"msExchTransportRule\") -or (ObjectClass -eq \"msExchAcceptedDomain\") -or (ObjectClass -eq \"msExchDomainContentConfig\") -or (ObjectClass -eq \"msExchCoexistenceRelationship\")  -or (ObjectClass -eq \"msExchRoutingSMTPConnector\")  -or (ObjectClass -eq \"msExchSmtpReceiveConnector\") -or (ObjectClass -eq \"msExchAcceptedDomain\") -or (ObjectClass -eq \"msExchMDB\") -or (ObjectClass -eq \"msExchMRSRequest\")} -server $server -Properties *\n\t\tif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t\t\t{\n\t\t\t$i = 1\n\t\t\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t\t\t{\n\t\t\t\t$resultspagesize = 256 - $i * 40\n\t\t\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t\t\t$error.clear()\n\t\t\t\t$SMTP = Get-ADObject -ResultPageSize $resultspagesize -searchbase $root.configurationNamingContext -filter {(ObjectClass -eq \"msExchTransportRule\") -or (ObjectClass -eq \"msExchAcceptedDomain\") -or (ObjectClass -eq \"msExchDomainContentConfig\") -or (ObjectClass -eq \"msExchCoexistenceRelationship\") -or (ObjectClass -eq \"msExchRoutingSMTPConnector\")  -or (ObjectClass -eq \"msExchSmtpReceiveConnector\") -or (ObjectClass -eq \"msExchMDB\") -or (ObjectClass -eq \"msExchMRSRequest\")} -server $server -Properties *\n\t\t\t\t$i++\n\t\t\t\t}\n\t\t\tif($SMTP){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\t\t\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t\t\t}\n\t\t#Might be read rights issues, trying GC\n\t\tif($error -like '*Directory object not found*')\n\t\t\t{\n\t\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t\t$search.pagesize = 256\n\t\t\t$TransportCategory = \"CN=ms-Exch-Transport-Rule,\" + $root.SchemaNamingContext\n\t\t\t$AcceptedCategory = \"CN=ms-Exch-Accepted-Domain,\" + $root.SchemaNamingContext\n\t\t\t$RouteCategory = \"CN=ms-Exch-Routing-SMTP-Connector,\" + $root.SchemaNamingContext\n\t\t\t$ReceiveCategory = \"CN=ms-Exch-Smtp-Receive-Connector,\" + $root.SchemaNamingContext\n\t\t\t$RemoteCategory = \"CN=ms-Exch-Domain-Content-Config,\" + $root.SchemaNamingContext\n\t\t\t$HybridCategory = \"CN=ms-Exch-Coexistence-Relationship,\" + $root.SchemaNamingContext\n\t\t\t$MDBCategory = \"CN=ms-Exch-MDB,\" + $root.SchemaNamingContext\n\t\t\t$MDBprivCategory = \"CN=ms-Exch-Private-MDB,\" + $root.SchemaNamingContext\n\t\t\t$search.filter = \"(|(ObjectCategory=$($MDBprivCategory))(ObjectCategory=$($RouteCategory))(ObjectCategory=$($AcceptedCategory))(ObjectCategory=$($RemoteCategory))(ObjectCategory=$($HybridCategory))(ObjectCategory=$($TransportCategory))(ObjectCategory=$($ReceiveCategory))(ObjectCategory=$($MDBCategory)))\"\n\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t\t$smtpgc =  $search.findall() | Convert-ADSearchResult\n\t\t\tif($smtpgc){\n\t\t\t\t$error.clear()\n\t\t\t\t$countSMTP  = ($smtpgc | measure-object).count\n\t\t\t\t$gcobjects += $smtpgc\n\t\t\t\t}\n\t\t\t}\n\n\t\tif($SMTP){\n\t\t\t$criticalobjects += $SMTP\n\t\t\t$countSMTP = ($SMTP | measure-object).count\n\t\t\t}\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving mail flow and storage related objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\tif($SMTP)\n\t\t\t\t\t\t{\"$(Get-TimeStamp) Number of mail flow and storage related objects retrieved via LDAP: $($countSMTP)\" | out-file $logfilename -append}\n\t\t\t\telseif($smtpgc)\n\t\t\t\t\t\t{\"$(Get-TimeStamp) Number of mail flow and storage related objects retrieved via GC: $($countSMTP)\" | out-file $logfilename -append}\n\t\t\t\telse\n\t\t\t\t\t\t{\"$(Get-TimeStamp) Cannot read mail flow and storage related objects with the account running the script\" | out-file $logfilename -append}\n\t\t\t\t}\n\n\t\t#Getting RBAC rol assignements\n\t\t\"$(Get-TimeStamp) Retrieving RBAC role assignements\" | out-file $logfilename -append\n\t\t$RBAC = Get-ADObject -SearchBase $serviceNC -SearchScope SubTree -filter {ObjectClass -eq \"msExchRoleAssignment\"} -server $server -properties *\n\t\tif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t\t\t{\n\t\t\t$i = 1\n\t\t\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t\t\t{\n\t\t\t\t$resultspagesize = 256 - $i * 40\n\t\t\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t\t\t$error.clear()\n\t\t\t\t$RBAC = Get-ADObject -ResultPageSize $resultspagesize -SearchBase $serviceNC -SearchScope SubTree -filter {ObjectClass -eq \"msExchRoleAssignment\"} -server $server -properties *\n\t\t\t\t$i++\n\t\t\t\t}\n\t\t\tif($RBAC){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\t\t\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t\t\t}\n\t\tif($RBAC)\n\t\t\t{\n\t\t\t$countRBAC = ($RBAC | Measure-object).count\n\t\t\t\"$(Get-TimeStamp) Number of RBAC role assignements: $($countRBAC)\" | out-file $logfilename -append\n\t\t\t$criticalobjects += $RBAC\n\t\t\t# Get accounts with an RBAC role assigned\n\t\t\t$RBACassignements =  $RBAC | Group-Object -Property msExchUserLink | foreach-object{if($_.Name){get-adobject -Filter {DistinguishedName -eq $_.Name} -server $server -Properties *}}\n\n\t\t\t\tif($error)\n\t\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving accounts with an RBAC role assigned $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\t\t#Get direct assignements\n\t\t\t$usrRBACassignements = $RBACassignements | where-object{($_.objectClass -eq \"user\") -or ($_.objectClass -eq \"inetOrgPerson\") -or ($_.objectClass -eq \"Computer\")}\n\t\t\t$criticalobjects += $usrRBACassignements\n\t\t\t\t$countusrRBACassignements = ($usrRBACassignements | Measure-Object).count\n\t\t\t\t\"$(Get-TimeStamp) Number of accounts with RBAC direct assignement: $($countusrRBACassignements)\" | out-file $logfilename -append\n\t\t\tif($error)\n\t\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving RBAC direct assignements $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t#Get assignements by groups, retrieve group membership\n\t\t\t$grpRBACassignements = $RBACassignements | where-object{($_.objectClass -eq \"group\")}\n\t\t\t$countgrpRBACassignements = ( $grpRBACassignements | measure-object).count\n\t\t\t\"$(Get-TimeStamp) Number of accounts with RBAC indirect assignement: $($countgrpRBACassignements)\" | out-file $logfilename -append\n\t\t\t$criticalobjects += $grpRBACassignements\n\t\t\tforeach($grp in $grpRBACassignements)\n\t\t\t\t{\n\t\t\t\t$membersROLE = $null\n\t\t\t\tif($isonline -eq $true)\n\t\t\t\t\t{\n\t\t\t\t\t$membersROLE = Get-ADGroupMember -recursive $grp -server $server\n\t\t\t\t\tif($membersROLE)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t$criticalobjects += ($membersROLE | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t\t\t\t\t$nestedgrp = @()\n\t\t\t\t\t\t$level1 = Get-ADGroupMember $grp -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName\n\t\t\t\t\t\tif($level1)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$nestedgrp += $level1\n\t\t\t\t\t\t\t$nestedgrp  += $level1 | foreach-object{Get-ADGroupMember $_.DistinguishedName -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName}\n\t\t\t\t\t\t\t$criticalobjects += ($nestedgrp | foreach-object{get-adobject $_.DistinguishedName -server $server -properties *})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t$membersROLE = ($grp | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t\t\t\t$criticalobjects += $membersROLE\n\t\t\t\t\t$continue = $membersROLE | where-object{$_.ObjectClass -eq \"Group\"}\n\t\t\t\t\tif($continue)\n\t\t\t\t\t\t{foreach($grprole in $continue){$membersROLEn2 = $grprole | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *};$criticalobjects += $membersROLEn2}}\n\t\t\t\t\tif($error)\n\t\t\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving RBAC indirect assignements $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tif($error)\n\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving RBAC indirect assignements $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\t\"$(Get-TimeStamp) Cannot read RBAC role assignements with the account running the script\" | out-file $logfilename -append\n\t\t\t$OUGrpExch = \"OU=Microsoft Exchange Security Groups,\" + $root.DefaultNamingContext\n\t\t\t$GrpsExch = get-adobject -searchbase $OUGrpExch -Filter {ObjectClass -eq \"Group\"} -server $server -Properties *\n\t\t\t$countGrpsExch = ($GrpsExch | measure-object).count\n\t\t\tif($error)\n\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving groups under MS Exchange Security Groups container $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\telse\n\t\t\t\t{\"$(Get-TimeStamp) Number of groups under MS Exchange Security Groups container: $($countGrpsExch)\" | out-file $logfilename -append}\n\n\t\t\tif($GrpsExch)\n\t\t\t\t{\n\t\t\t\t$criticalobjects += $GrpsExch\n\t\t\t\tif($isonline -eq $true)\n\t\t\t\t\t{\n\t\t\t\t\tforeach($GrpExch in $GrpsExch)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t$criticalobjects += (Get-ADGroupMember -recursive $GrpExch -server $server  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t\t\t\t\t$nestedgrp = @()\n\t\t\t\t\t\t$level1 = Get-ADGroupMember $GrpExch -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName\n\t\t\t\t\t\tif($level1)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$nestedgrp += $level1\n\t\t\t\t\t\t\t$nestedgrp  += $level1 | foreach-object{Get-ADGroupMember $_.DistinguishedName -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName}\n\t\t\t\t\t\t\t$criticalobjects += ($nestedgrp | foreach-object{get-adobject $_.DistinguishedName -server $server -properties *})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\tforeach($GrpExch in $GrpsExch)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$exchgrpc = ($GrpExch | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t\t\t\t\t\t$criticalobjects += $exchgrpc\n\t\t\t\t\t\t\t$continue = $exchgrpc | where-object{$_.ObjectClass -eq \"Group\"}\n\t\t\t\t\t\t\tif($continue)\n\t\t\t\t\t\t\t\t{foreach($grp in $continue){$exchgrpcn2 = $grp | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *};$criticalobjects += $exchgrpcn2}}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\tif($error)\n\t\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving group membership of groups located under MS Exchange Security Groups container $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\telse\n\t\t{\n\t\t# If current domain is child domain, we need GC to retrieve some Exchange objects information.\n\t\t\"$(Get-TimeStamp) Retrieving Exchange Trusted Subsystem on root domain\" | out-file $logfilename -append\n\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t$search.filter = \"(DistinguishedName=$($trustedSubSystem))\"\n\t\t$ets = $search.FindOne() | Convert-ADSearchResult\n\t\t$gcobjects += $ets\n\t\tif($ets.Member)\n\t\t\t{\n\t\t\t$rootobjectsmembers = $ets.Member | foreach-object{$search.filter = \"(DistinguishedName=$($_))\"; $search.FindOne() | Convert-ADSearchResult}\n\t\t\t$counttrustedsubsysmembers = ($rootobjectsmembers | measure-object).count\n\t\t\t$gcobjects += $rootobjectsmembers\n\t\t\t}\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving Exchange Trusted SubSystem members in root domain $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\telse\n\t\t\t{\"$(Get-TimeStamp) Number of level 1 Exchange Trusted SubSystem members $($counttrustedsubsysmembers)\" | out-file $logfilename -append}\n\t\t# Windows Permissions and Exchange Servers is also retieved\n\t\t$Winperm = \"CN=Exchange Windows Permissions,OU=Microsoft Exchange Security Groups,\" + ($root.rootDomainNamingContext)\n\t\t$ExcSRV = \"CN=Exchange Servers,OU=Microsoft Exchange Security Groups,\" + ($root.rootDomainNamingContext)\n\t\t$search.filter = \"(DistinguishedName=$($Winperm))\"\n\t\t$gcobjects += $search.FindOne() | Convert-ADSearchResult\n\t\t$search.filter = \"(DistinguishedName=$($ExcSRV))\"\n\t\t$gcobjects += $search.FindOne() | Convert-ADSearchResult\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving Exchange Windows Permissions or Exchange servers groups $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t# Fetching transport rules, accepted domains, remote domains, hybrid relationship, SMTP connectors, and Mailbox databases\n\t\t$countSMTP = 0\n\t\t$SMTP = Get-ADObject -searchbase $root.configurationNamingContext -filter {(ObjectClass -eq \"msExchTransportRule\") -or (ObjectClass -eq \"msExchAcceptedDomain\") -or (ObjectClass -eq \"msExchDomainContentConfig\") -or (ObjectClass -eq \"msExchCoexistenceRelationship\") -or (ObjectClass -eq \"msExchRoutingSMTPConnector\")  -or (ObjectClass -eq \"msExchSmtpReceiveConnector\") -or (ObjectClass -eq \"msExchMDB\") -or (ObjectClass -eq \"msExchMRSRequest\")} -server $server -Properties *\n\n\t\tif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t\t\t{\n\t\t\t$i = 1\n\t\t\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t\t\t{\n\t\t\t\t$resultspagesize = 256 - $i * 40\n\t\t\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t\t\t$error.clear()\n\t\t\t\t$SMTP = Get-ADObject -ResultPageSize $resultspagesize -searchbase $root.configurationNamingContext -filter {(ObjectClass -eq \"msExchTransportRule\") -or (ObjectClass -eq \"msExchAcceptedDomain\") -or (ObjectClass -eq \"msExchDomainContentConfig\") -or (ObjectClass -eq \"msExchCoexistenceRelationship\") -or (ObjectClass -eq \"msExchRoutingSMTPConnector\")  -or (ObjectClass -eq \"msExchSmtpReceiveConnector\") -or (ObjectClass -eq \"msExchMDB\") -or (ObjectClass -eq \"msExchMRSRequest\")} -server $server -Properties *\n\t\t\t\t$i++\n\t\t\t\t}\n\t\t\tif($SMTP){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\t\t\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t\t\t}\n\n\t\t#Might be read rights issues, trying GC\n\t\tif($error -like '*Directory object not found*')\n\t\t\t{\n\t\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t\t$search.pagesize = 256\n\t\t\t$TransportCategory = \"CN=ms-Exch-Transport-Rule,\" + $root.SchemaNamingContext\n\t\t\t$AcceptedCategory = \"CN=ms-Exch-Accepted-Domain,\" + $root.SchemaNamingContext\n\t\t\t$RemoteCategory = \"CN=ms-Exch-Domain-Content-Config,\" + $root.SchemaNamingContext\n\t\t\t$HybridCategory = \"CN=ms-Exch-Coexistence-Relationship,\" + $root.SchemaNamingContext\n\t\t\t$RouteCategory = \"CN=ms-Exch-Routing-SMTP-Connector,\" + $root.SchemaNamingContext\n\t\t\t$ReceiveCategory = \"CN=ms-Exch-Smtp-Receive-Connector,\" + $root.SchemaNamingContext\n\t\t\t$MDBCategory = \"CN=ms-Exch-MDB,\" + $root.SchemaNamingContext\n\t\t\t$MDBprivCategory = \"CN=ms-Exch-Private-MDB,\" + $root.SchemaNamingContext\n\t\t\t$search.filter = \"(|(ObjectCategory=$($MDBprivCategory))(ObjectCategory=$($RouteCategory))(ObjectCategory=$($AcceptedCategory))(ObjectCategory=$($RemoteCategory))(ObjectCategory=$($HybridCategory))(ObjectCategory=$($TransportCategory))(ObjectCategory=$($ReceiveCategory))(ObjectCategory=$($MDBCategory)))\"\n\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t\t$smtpgc =  $search.findall() | Convert-ADSearchResult\n\t\t\tif($smtpgc){\n\t\t\t\t$error.clear()\n\t\t\t\t$countSMTP  = ($smtpgc | measure-object).count\n\t\t\t\t$gcobjects += $smtpgc\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif($SMTP){\n\t\t\t\t$criticalobjects += $SMTP\n\t\t\t\t$countSMTP = ($SMTP | measure-object).count\n\t\t\t\t}\n\t\t\t\tif($error)\n\t\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving mail flow and storage related objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\tif($SMTP)\n\t\t\t\t\t\t{\"$(Get-TimeStamp) Number of mail flow and storage related objects retrieved via LDAP: $($countSMTP)\" | out-file $logfilename -append}\n\t\t\t\t\telseif($smtpgc)\n\t\t\t\t\t\t{\"$(Get-TimeStamp) Number of mail flow and storage related objects retrieved via GC: $($countSMTP)\" | out-file $logfilename -appe\n\t\t\t\t\telse\n\t\t\t\t\t\t{\"$(Get-TimeStamp) Cannot read mail flow and storage related objects with the account running the script\" | out-file $logfilename -append}\n\t\t\t\t\t}\n\n\t\t#Getting RBAC role assignements\n\t\t$RBAC = Get-ADObject -SearchBase $serviceNC -SearchScope SubTree -filter {ObjectClass -eq \"msExchRoleAssignment\"} -server $server -properties *\n\t\tif(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t\t\t{\n\t\t\t$i = 1\n\t\t\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t\t\t{\n\t\t\t\t$resultspagesize = 256 - $i * 40\n\t\t\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t\t\t$error.clear()\n\t\t\t\t$RBAC = Get-ADObject -ResultPageSize $resultspagesize -SearchBase $serviceNC -SearchScope SubTree -filter {ObjectClass -eq \"msExchRoleAssignment\"} -server $server -properties *\n\t\t\t\t$i++\n\t\t\t\t}\n\t\t\tif($RBAC){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\t\t\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t\t\t}\n\t\tif($RBAC)\n\t\t\t{\n\t\t\t$countRBAC = ($RBAC | Measure-object).count\n\t\t\t\"$(Get-TimeStamp) Number of RBAC role assignements: $($countRBAC)\" | out-file $logfilename -append\n\t\t\t$criticalobjects += $RBAC\n\t\t\t# Get objects assigned to role via GC\n\t\t\t$RBACassignements =  $RBAC | Group-Object -Property msExchUserLink | foreach-object{if($_.Name){$search.filter = \"(DistinguishedName=$($_.Name))\"; $search.FindOne() | Convert-ADSearchResult}}\n\t\t\tif($error)\n\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving accounts with an RBAC role assigned $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\t\t$usrRBACassignements = $RBACassignements | where-object{($_.objectClass -eq \"user\") -or ($_.objectClass -eq \"inetOrgPerson\") -or ($_.objectClass -eq \"Computer\")}\n\t\t\t$gcobjects += $usrRBACassignements\n\t\t\t$countusrRBACassignements = ($usrRBACassignements | Measure-Object).count\n\t\t\t\"$(Get-TimeStamp) Number of accounts with a direct RBAC assignement: $($countusrRBACassignements)\" | out-file $logfilename -append\n\t\t\t$grpRBACassignements = $RBACassignements | where-object{($_.objectClass -eq \"group\")}\n\t\t\t# Get RBAC indirect assignements but not group membership\n\t\t\t$countgrpRBACassignements = ( $grpRBACassignements | measure-object).count\n\t\t\t\"$(Get-TimeStamp) Number of groups with an indirect RBAC assignement:  $($countgrpRBACassignements)\" | out-file $logfilename -append\n\t\t\t$gcobjects += $grpRBACassignements\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\t\"$(Get-TimeStamp) RBAC roles could not be retrieved by current account\" | out-file $logfilename -append\n\t\t\t\"$(Get-TimeStamp) Retrieving groups located in the Microsoft Exchange Security Groups container via GC\" | out-file $logfilename -append\n\t\t\t$OUGrpExch = \"OU=Microsoft Exchange Security Groups,\" + $root.rootDomainNamingContext\n\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)/$($OUGrpExch)\"\n\t\t\t$search.filter = \"(ObjectClass=Group)\"\n\t\t\t$search.pagesize = 256\n\t\t\t$GrpsExch = $search.FindAll() | Convert-ADSearchResult\n\t\t\t$gcobjects += $GrpsExch\n\t\t\t$countGrpsExch = ( $GrpsExch | measure-object).count\n\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t\tforeach($GrpExch in $GrpsExch)\n\t\t\t\t{\n\t\t\t\t$GrpExchmembers = $null\n\t\t\t\tif($GrpExch.Member){$GrpExchmembers = $GrpExch.Member | foreach-object{$search.filter = \"(DistinguishedName=$($_))\"; $search.FindOne() | Convert-ADSearchResult}}\n\t\t\t\t$gcobjects += $GrpExchmembers\n\t\t\t\t}\n\t\t\tif($error)\n\t\t\t\t{ \"$(Get-TimeStamp) Error while retrieving groups plus members located under the Microsoft Exchange Security Groups container in the root domain $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\telse\n\t\t\t\t{\"$(Get-TimeStamp) Number of groups located in Microsoft Exchange Security Groups container in the root domain: $($countGrpsExch)\" | out-file $logfilename -append}\n\n\t\t\t}\n\t\t}\n\n\t}\n}\n\n$error.clear()\n\n#Processing custom group, please fill in table at the begining of the script for processing\nif($groupscustom)\n\t{\n    $cache=@{}\n    \"$(Get-TimeStamp) Custom groups provided by the analyst\" | out-file $logfilename -append\n\tforeach($grpcustom in $groupscustom)\n\t\t{\n        Write-Output \"Searching for group(s) '$grpcustom' ...\"\n\t\ttry {\n  \t\t\tif ($groupslike) {\n\t\t\t\tWrite-Output \"Searching for group(s) '*$($grpcustom)*' ...\"\n\t\t\t\t$grpcs = get-adobject -filter { Name -like \"*$($grpcustom)*\" } -server $server -properties *\n\t\t\t}\n\t\t\telse {\n\t\t\t\tWrite-Output \"Searching for group(s) '$grpcustom' ...\"\n\t\t\t\t$grpcs = get-adobject -filter { Name -eq $grpcustom } -server $server -properties *\n\t\t\t}\n\t\t}\n        catch {\n\t\t\tWrite-Output \"Error while retrieving group(s) '$grpcustom' : $_\"\n\t\t\t{ \"$(Get-TimeStamp) Error while retrieving group(s) '$grpcustom' : $_\" | out-file $logfilename -append ; }\n            continue\n        }\n        if ($grpcs -is [array]) { Write-Output \"Got multiple results for '$grpcustom'\" }\n        else { $grpcs = ($grpcs) }\n\t\tforeach ($grpc in $grpcs)\n\t\t\t{\n            Write-Output \"isonline: $isonline\"\n            Write-Output \"grpc: $grpc\"\n\t\t\t$criticalobjects += $grpc\n\t\t\tif($isonline -eq $true)\n\t\t\t\t{\n            \ttry {\n                \tWrite-Output \"Fetching members of '$grpc' ...\"\n                \t$members = Get-ADGroupMember -recursive $grpc -server $server\n\t\t\t\t\tforeach ($member in $members)\n\t\t\t\t\t{\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif ($cache.ContainsKey(\"$member\")) {\n\t\t\t\t\t\t\t   Write-Output \"skipping member '$member' properties ...\"\n                               continue\n                            }\n                            $cache[\"$member\"]=1\n\t\t\t\t\t\t\tWrite-Output \"fetching member '$member' properties ...\"\n\t\t\t\t\t\t\t$grpc_obj = get-adobject $member -server $server -properties *\n\t\t\t\t\t\t\t$criticalobjects += ($grpc_obj)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\tWrite-Output \"Error during group $grpc traversal: $_\"\n\t\t\t\t\t\t\t{ \"$(Get-TimeStamp) Error during group $grpc traversal: $_\" | out-file $logfilename -append ; }\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n                \t}\n            \t}\n\t\t\t\tcatch {\n\t\t\t\t\tWrite-Output \"Unable to fetch group '$grpc' members: $_\"\n\t\t\t\t\t{ \"$(Get-TimeStamp) Unable to fetch group '$grpc' members: $_\" | out-file $logfilename -append ; }\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t$nestedgrp = @()\n            \t$level1 = @()\n\t\t\t\ttry {\n\t\t\t\t\t$levels1 = Get-ADGroupMember $grpc -server $server | where-object{$_.objectclass -eq \"Group\"}\n\t\t\t\t\tforeach ($l in $levels1) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t$level1 += $l.distinguishedName\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\tWrite-Output \"Unable to get distinghishedname from '$l': $_\"\n\t\t\t\t\t\t\t{ \"$(Get-TimeStamp) Unable to get distinghishedname from '$l': $_\" | out-file $logfilename -append ; }\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcatch {\n\t\t\t\t\tWrite-Output \"Unable to fetch level1 group member for '$grpc' : $_\"\n\t\t\t\t\t{ \"$(Get-TimeStamp) Unable to fetch level1 group member for '$grpc' : $_\" | out-file $logfilename -append ; }\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif($level1.length -gt 0) {\n\t\t\t\t\t$nestedgrp += $level1\n\t\t\t\t\t$level1 | foreach-object {\n\t\t\t\t\t\t$level1_obj = $_\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t$level1_members = Get-ADGroupMember $_.DistinguishedName -server $server | where-object{$_.objectclass -eq \"Group\"} | select-object distinguishedName\n\t\t\t\t\t\t\t$nestedgrp += ($level1_members)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\tWrite-Output \"Error getting level1 '$level1_obj' members: $_\"\n\t\t\t\t\t\t\t{ \"$(Get-TimeStamp) Error getting level1 '$level1_obj' members: $_\" | out-file $logfilename -append ; }\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t$nestedgrp | foreach-object{\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif ($cache.ContainsKey(\"$_.DistinguishedName\")) {\n\t\t\t\t\t\t\t   Write-Output \"skipping adobject $_.DistinguishedName ...\"\n                               continue\n                            }\n                            Write-Output \"fetching adobject $_.DistinguishedName ...\"\n\t\t\t\t\t\t\t$cache[\"$_.DistinguishedName\"]=1\n\t\t\t\t\t\t\t$nestedgrp_obj = get-adobject $_.DistinguishedName -server $server -properties *\n\t\t\t\t\t\t\t$criticalobjects += ($nestedgrp_obj)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcatch {\n\t\t\t\t\t\t\tWrite-Output \"Error getting nested group object: $_\"\n\t\t\t\t\t\t\t{ \"$(Get-TimeStamp) Error getting nested group object: $_\" | out-file $logfilename -append ; }\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\t$customgrpc = ($grpc | select-object -expandproperty member  | foreach-object{get-adobject $_ -server $server -properties *})\n\t\t\t\t$criticalobjects += $customgrpc\n\t\t\t\t$continue = $customgrpc | where-object{$_.ObjectClass -eq \"Group\"}\n\t\t\t\tif($continue)\n\t\t\t\t\t{\n\t\t\t\t\t\tforeach ($grp in $continue) {\n\t\t\t\t\t\t\t$customgrpcn2 = $grp | select-object -expandproperty member  | foreach-object {\n\t\t\t\t\t\t\t\tget-adobject $_ -server $server -properties *\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t$criticalobjects += $customgrpcn2\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n        }\n\n        if($error)\n            { \"$(Get-TimeStamp) Error while retrieving custom groups $($error)\" | out-file $logfilename -append ; $error.clear() }\n        \"$(Get-TimeStamp) Custom groups retrieved\" | out-file $logfilename -append\n\t}\n\n\n\n #Get dynamic objects\n $DynObjects = Get-ADObject  -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -Filter {ObjectClass -eq \"dynamicObject\"}  -Server $server -properties *\n if(($error -like '*timeout*') -or ($error -like '*invalid enumeration context*'))\n\t{\n\t$i = 1\n\twhile((($error -like '*timeout*') -or ($error -like '*invalid enumeration context*')) -and ($i -le 5))\n\t\t{\n\t\t$resultspagesize = 256 - $i * 40\n\t\twrite-output -inputobject \"LDAP time out, trying again with ResultPageSize $($resultspagesize)\"\n\t\t$error.clear()\n\t\t$DynObjects = Get-ADObject -ResultPageSize $resultspagesize -SearchBase ($root.defaultNamingContext) -SearchScope SubTree -Filter {ObjectClass -eq \"dynamicObject\"}  -Server $server -properties *\n\t\t$i++\n\t\t}\n\tif($DynObjects){write-output -inputobject \"LDAP query succeeded with different ResultPageSize\"}\n\telse{write-output -inputobject \"LDAP query failure despite different ResultPageSize, resuming script\"}\n\t}\n$countDynObjects = ($DynObjects | measure-object).count\nif($error)\n    { \"$(Get-TimeStamp) Error while retrieving dynamic objects $($error)\" | out-file $logfilename -append ; $error.clear() }\nelse {\n\t\"$(Get-TimeStamp) Number of dynamic objects: $($countDynObjects)\" | out-file $logfilename -append\n\t}\nif($DynObjects)\n\t{\n\t$ttlcount = 0\n\t#Merging TTL constructed attributes with AD Object\n\tforeach($DynObject in $DynObjects)\n\t\t{\n\t\t$ttl = Get-ADObject $DynObject -Server $server -properties msDS-Entry-Time-To-Die,entryTTL | select-object msDS-Entry-Time-To-Die,entryTTL\n\t\tif($ttl.\"msDS-Entry-Time-To-Die\" -and $ttl.entryTTL)\n\t\t\t{\n\t\t\t$a = $ttl.entryTTL.tostring()\n\t\t\t$b = $ttl.\"msDS-Entry-Time-To-Die\".tostring()\n\t\t\t$DynObject | add-member -MemberType NoteProperty -Name msDS-Entry-Time-To-Die -Value $a -force\n\t\t\t$DynObject |  add-member -MemberType NoteProperty -Name entryTTL -Value $b -force\n\t\t\t$DynObject |  add-member -MemberType NoteProperty -Name IsDynamic -Value $true -force\n\t\t\t$criticalobjects = $criticalobjects | where-object{$_.DistinguishedName -ne $DynObject.DistinguishedName}\n\t\t\t$criticalobjects += $DynObject\n\t\t\t$ttlcount++\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\t$DynObject |  add-member -MemberType NoteProperty -Name IsDynamic -Value $true -force\n\t\t\t$criticalobjects = $criticalobjects | where-object{$_.DistinguishedName -ne $DynObject.DistinguishedName}\n\t\t\t$criticalobjects += $DynObject\n\t\t\t}\n\t\t}\n\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while retrieving TTL for dynamic objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\telse\n\t\t{\"$(Get-TimeStamp) Number of dynamic objects with TTL set: $($ttlcount)\" | out-file $logfilename -append}\n\t}\n\n\nwrite-output -inputobject \"---- AD objects collected ----\"\n\n\n\n#Removing variables\nif($SDPropObjects){Remove-variable SDPropObjects}\nif($deletedusersgpo){Remove-variable deletedusersgpo}\nif($sysobjects){Remove-variable sysobjects}\nif($trusts){Remove-variable trusts}\nif($allSIDHistory){Remove-variable allSIDHistory}\nif($CurrDomainSIDHistory){Remove-variable CurrDomainSIDHistory}\nif($OtherDomainSIDHistory){Remove-variable OtherDomainSIDHistory}\nif($objOUs){Remove-variable objOUs}\nif($kerberoast){Remove-variable kerberoast}\nif($sitesIGC){Remove-variable sitesIGC}\nif($RBAC){Remove-variable RBAC}\nif($RBACassignements){Remove-variable RBACassignements}\nif($usrRBACassignements){Remove-variable usrRBACassignements}\nif($grpRBACassignements){Remove-variable grpRBACassignements}\nif($membersROLE){Remove-variable membersROLE}\nif($trustedsubsysmembers){Remove-variable trustedsubsysmembers}\nif($deleteconf){Remove-variable deleteconf}\nif($GrpsExch){Remove-variable GrpsExch}\nif($GrpExchmembers){Remove-variable GrpExchmembers}\nif($SMTP){Remove-variable SMTP}\nif($dom1){Remove-variable dom1}\nif($dcrepls){Remove-variable dcrepls}\nif($DCpresents){Remove-variable DCpresents}\nif($DCeffaces){Remove-variable DCeffaces}\nif($customgrpc){Remove-variable customgrpc}\nif($exchgrpc){Remove-variable exchgrpc}\nif($otherDCs){Remove-variable otherDCs}\nif($otherdomains){Remove-variable otherdomains}\nif($DangerOtherDomainSIDHistory){Remove-variable DangerOtherDomainSIDHistory}\nif($rootdom){Remove-variable rootdom}\nif($rootda){Remove-variable rootda}\nif($rootUadmins ){Remove-variable rootUadmins}\nif($rootadminsmembers){Remove-variable rootadminsmembers}\nif($deletedgpo){Remove-variable deletedgpo}\nif($deletedusers){Remove-variable deletedusers}\nif($OULevel1){Remove-variable OULevel1}\nif($OULevel2){Remove-variable OULevel2}\nif($asreproast){Remove-variable asreproast}\nif($Classesschema){Remove-variable Classesschema}\nif($dnsadmin){Remove-variable dnsadmin}\nif($dnsadminsmembers){Remove-variable dnsadminsmembers}\nif($delegkrb){Remove-variable delegkrb}\nif($DNSZones){Remove-variable DNSZones}\nif($objOUsfull){Remove-variable objOUsfull}\nif($extrights){Remove-variable extrights}\nif($confidattr){Remove-variable confidattr}\nif($neveraudit){Remove-variable neveraudit}\nif($rootschema){Remove-variable rootschema}\nif($rootconf){Remove-variable rootconf}\nif($DynObjectswithttl){Remove-variable DynObjectswithttl}\nif($DynObjects){Remove-variable DynObjects}\nif($ADFSObjects){Remove-variable ADFSObjects}\nif($ADFSFarms){Remove-variable ADFSFarms}\nif($ADFSrootobj){Remove-variable ADFSrootobj}\nif($scps){Remove-variable scps}\nif($scpsdomain1){Remove-variable scpsdomain1}\nif($scpsdomain2){Remove-variable scpsdomain2}\n\n\n\n\n\n#Launching garbage collector to free up some RAM\n\"$(Get-TimeStamp) Freeing up memory\" | out-file $logfilename -append\nwrite-output -inputobject \"---- Freeing up memory ----\"\n[System.GC]::Collect()\nif($error)\n    { \"$(Get-TimeStamp) Error while freeing up memory $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\n\nwrite-output -inputobject \"---- Exporting objects as XML ----\"\n#Removing objects collected twice or more\n$criticalobjects = $criticalobjects | sort-object -unique -Property DistinguishedName\n\"$(Get-TimeStamp) Removed LDAP objects collected twice or more\" | out-file $logfilename -append\n# Exporting objects, first try\ntry {\n\t$criticalobjects | Export-Clixml $adobjectsfilename -Encoding UTF8\n\t\"$(Get-TimeStamp) All objects retrieved via LDAP exported in ADobjects.xml\" | out-file $logfilename -append\n}\ncatch {\n\t# Exporting objects, second try\n\t\"$(Get-TimeStamp) Error while exporting some objects retrieved via LDAP $($error)\" | out-file $logfilename -append\n\t\"$(Get-TimeStamp) Retrying by filtering out invalid objects ...\" | out-file $logfilename -append\n\t$newcriticalobjects = $criticalobjects | Where-Object { \n\t\ttry {\n\t\t\t[System.Management.Automation.PSSerializer]::Serialize($_) | Out-Null\n\t\t\treturn $true\n\t\t}\n\t\tcatch {\n\t\t\t\"$(Get-TimeStamp) Discarding unserializable object $($_.DistinguishedName)\" | out-file $logfilename -append\n\t\t\treturn $null\n\t\t}\n\t}\n\t$newcriticalobjects | Export-Clixml -Force $adobjectsfilename -Encoding UTF8\n\t\"$(Get-TimeStamp) $($newcriticalobjects.Count)/$($criticalobject.Count) objects retrieved via LDAP exported in ADobjects.xml\" | out-file $logfilename -append\n\tif($error)\n\t\t{ \"$(Get-TimeStamp) Error while exporting objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n}\n\n$nbviaLDAP = $null\n$nbviagc = $null\nif($gcobjects)\n\t{\n\t$gcobjects = $gcobjects | sort-object -unique -Property DistinguishedName\n\t\"$(Get-TimeStamp) Removed GC objects collected twice or more\" | out-file $logfilename -append\n\n\t# Exporting gcobjects, first try\n\ttry {\n\t\t$gcobjects | Export-Clixml $gcADobjectsfilename -Encoding UTF8\n\t\t\"$(Get-TimeStamp) Global Catalog objects exported in gcADobjects.xml\" | out-file $logfilename -append\n\t}\n\tcatch {\n\t\t# Exporting gcobjects, second try\n\t\t\"$(Get-TimeStamp) Error while exporting some Global Catalog objects retrieved via LDAP $($error)\" | out-file $logfilename -append\n\t\t\"$(Get-TimeStamp) Retrying by filtering out invalid Global Catalog objects ...\" | out-file $logfilename -append\n\t\t$newgcobjects = $gcobjects | Where-Object { \n\t\t\ttry {\n\t\t\t\t[System.Management.Automation.PSSerializer]::Serialize($_) | Out-Null\n\t\t\t\treturn $true\n\t\t\t}\n\t\t\tcatch {\n\t\t\t\t\"$(Get-TimeStamp) Discarding unserializable object $($_.distinguishedname)\" | out-file $logfilename -append\n\t\t\t\treturn $null\n\t\t\t}\n\t\t}\n\t\t$newgcobjects | Export-Clixml -Force $gcADobjectsfilename -Encoding UTF8\n\t\t\"$(Get-TimeStamp) $($newgcobjects.Count)/$($gcobjects.Count) Global Catalog objects retrieved via LDAP exported in gcADobjects.xml\" | out-file $logfilename -append\n\t\tif($error)\n\t\t\t{ \"$(Get-TimeStamp) Error while exporting global catalog objects $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t}\n\n\t$nbviaLDAP = ($criticalobjects | measure-object).count\n\t$nbviagc = ($gcobjects | measure-object).count\n\t\"$(Get-TimeStamp) Number of objects retrieved via LDAP $($nbviaLDAP) and via Global Catalog $($nbviagc)\" | out-file $logfilename -append\n\t$criticalobjects += $gcobjects\n\t}\nelse {\n\tremove-item $gcADobjectsfilename -force -confirm:$false\n\t}\n\n\n# Generating TimeLine from replication metadata\nwrite-output -inputobject \"---- Export done ----\"\nwrite-output -inputobject \"---- Generating AD timeline ----\"\n\"$(Get-TimeStamp) Starting to retrieve AD replication metadata\" | out-file $logfilename -append\n$countcrit = ($criticalobjects | measure-object).count\n\"$(Get-TimeStamp) Number of objects to process: $($countcrit)\" | out-file $logfilename -append\nwrite-output -inputobject \"---- $($countcrit) Objects to process ----\"\n\n\n$groupClass = \"CN=Group,\" + $root.SchemaNamingContext\n$personClass = \"CN=Person,\" + $root.SchemaNamingContext\n\n# Initializing AD replication metadata object\n$Replinfo = [System.Collections.ArrayList]@()\n$i = 0\n\nforeach ($criticalobject in $criticalobjects)\n\t{\n\tif($criticalobject.DistinguishedName)\n\t{\n\t#Displaying progress bar\n\twrite-progress -Activity \"AD replication metadata\" -Status \"$i objects processed:\" -percentcomplete ($i/$countcrit*100)\n\t#Parsing de msDS-ReplAttributeMetadata see blog Once Upon a Case https://blogs.technet.microsoft.com/pie/2014/08/25\n\n\tif($nbviagc -and ($i -ge $nbviaLDAP))\n\t\t{\n\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t$search.Tombstone = $true\n\t\t$search.PropertiesToLoad.Addrange(('msDS-ReplAttributeMetadata','Name','DistinguishedName'))\n\t\t$search.filter = \"(DistinguishedName=$($criticalobject.DistinguishedName))\"\n\t\t$search.pagesize = 256\n\t\t$obj = \t$search.FindAll()  | Convert-ADSearchResult\n\n\t\t}\n\telse\n\t\t{$obj = get-adobject $criticalobject.DistinguishedName -Properties msDS-ReplAttributeMetadata -server $server -IncludeDeletedObjects}\n\n\t$metadas = $obj.\"msDS-ReplAttributeMetadata\" | foreach-object{ ([xml] $_.Replace(\"`0\",\"\").Replace(\"&\",\"&amp;\")).DS_REPL_ATTR_META_DATA }\n\n\tif($criticalobject.whencreated)\n\t\t{$whencreatedUTC = get-date (get-date($criticalobject.whencreated)).ToUniversalTime() -format u}\n\telse{$whencreatedUTC = \"N/A\"}\n\n    \tif($error)\n        {\"$(Get-TimeStamp) Error while retrieving AD replication metadata attributes msDS-ReplAttributeMetadata for $($criticalobject.DistinguishedName) $($error)\" | out-file $logfilename -append ; $error.clear() }\n\telse\n        {\n\t    foreach($metada in $metadas)\n\t\t    {\n\n\t\t    # Creating temp object with AD replication metadata attributes plus some object attributes relevant for timeline analysis\n\t\t    $tmpobj = new-object psobject\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name ftimeLastOriginatingChange -Value $metada.ftimeLastOriginatingChange\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name Name -Value $obj.Name\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name pszAttributeName -Value $metada.pszAttributeName\n\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ObjectClass -Value $criticalobject.ObjectClass\n\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name DN -Value $obj.DistinguishedName\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name ObjectCategory -Value $criticalobject.ObjectCategory\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name SamAccountName -Value $criticalobject.SamAccountName\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name dwVersion -Value $metada.dwVersion\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name WhenCreated -Value $whencreatedUTC\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name Member -Value \"\"\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name ftimeCreated -Value \"\"\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name ftimeDeleted -Value \"\"\n\t\t    add-member -InputObject $tmpobj -MemberType NoteProperty -Name SID -Value $criticalobject.objectSid\n\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name pszLastOriginatingDsaDN -Value $metada.pszLastOriginatingDsaDN\n\t    \tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name uuidLastOriginatingDsaInvocationID -Value $metada.uuidLastOriginatingDsaInvocationID\n\t    \tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name usnOriginatingChange -Value $metada.usnOriginatingChange\n\t    \tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name usnLocalChange -Value $metada.usnLocalChange\n\n\t    \t    # Append temp object to global AD replication metadata object\n\t    \t    [void]$Replinfo.add($tmpobj)\n\t\t    if($error){ \"$(Get-TimeStamp) Error while editing global AD replication metadata object $($error) for $($criticalobject.DistinguishedName)\" | out-file $logfilename -append ; $error.clear() }\n\t\t    }\n        }\n\n\tif($criticalobject.ObjectCategory -eq $groupClass)\n\t\t{\n\t\t#For groups we retrieve also the msDS-ReplValueMetadata attribute\n\t\t$isgcanduniversalorindom = $true\n\t\tif($nbviagc -and ($i -ge $nbviaLDAP))\n\t\t\t{\n\t\t\t# Only universal groups are processed\n\t\t\tif($criticalobject.GroupType -eq \"-2147483640\")\n\t\t\t\t\t{\n\t\t\t\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t\t\t\t$search.Tombstone = $true\n\t\t\t\t\t$search.PropertiesToLoad.Addrange(('msDS-ReplValueMetadata','Name','DistinguishedName'))\n\t\t\t\t\t$search.filter = \"(DistinguishedName=$($criticalobject.DistinguishedName))\"\n\t\t\t\t\t$search.pagesize = 256\n\t\t\t\t\t$objgrp = \t$search.FindAll() | Convert-ADSearchResult\n\t\t\t\t\t}\n\t\t\telse\n\t\t\t\t{$isgcanduniversalorindom = $false}\n\t\t\t}\n\n\t\telse\n\t\t\t{$objgrp = get-adobject $criticalobject.DistinguishedName -Properties msDS-ReplValueMetadata -server $server -IncludeDeletedObjects}\n\n\t\t\tif($error)\n        \t\t\t{ \"$(Get-TimeStamp) Error while retrieving AD replication metadata attributes msDS-ReplValueMetadata for $($criticalobject.DistinguishedName) $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\t\t\t\tif($isgcanduniversalorindom -and $objgrp.\"msDS-ReplValueMetadata\")\n\t\t\t\t\t\t{\n\t\t\t\t\t\t$metadasgrp = $objgrp.\"msDS-ReplValueMetadata\" | foreach-object{ ([xml] $_.Replace(\"`0\",\"\")).DS_REPL_VALUE_META_DATA}\n\t\t\t\t\tif($error)\n        \t\t\t\t{ \"$(Get-TimeStamp) Error while parsing AD replication metadata attributes msDS-ReplValueMetadata for $($criticalobject.DistinguishedName) $($error)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t$metadasgrpmbr = $metadasgrp | where-object{$_.pszAttributeName -eq \"member\"}\n\t\t\t\tif($metadasgrpmbr)\n\t\t\t\t\t{\n\t\t\t\t\tforeach($metada in $metadasgrpmbr)\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t$tmpobj = new-object psobject\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ftimeLastOriginatingChange -Value $metada.ftimeLastOriginatingChange\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name Name -Value $obj.Name\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name pszAttributeName -Value $metada.pszAttributeName\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ObjectClass -Value $criticalobject.ObjectClass\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name DN -Value $obj.DistinguishedName\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ObjectCategory -Value $criticalobject.ObjectCategory\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name SamAccountName -Value $criticalobject.SamAccountName\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name dwVersion -Value $metada.dwVersion\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name WhenCreated -Value $whencreatedUTC\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name Member -Value $metada.pszObjectDn\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ftimeCreated -Value $metada.ftimeCreated\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ftimeDeleted -Value $metada.ftimeDeleted\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name SID -Value $criticalobject.objectSid\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name pszLastOriginatingDsaDN -Value $metada.pszLastOriginatingDsaDN\n\t   \t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name uuidLastOriginatingDsaInvocationID -Value $metada.uuidLastOriginatingDsaInvocationID\n\t    \t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name usnOriginatingChange -Value $metada.usnOriginatingChange\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name usnLocalChange -Value $metada.usnLocalChange\n\n\t    \t\t\t\t[void]$Replinfo.add($tmpobj)\n\t\t\t\t\t\tif($error){ \"$(Get-TimeStamp) Error while editing global AD replication metadata object $($error) for $($criticalobject.DistinguishedName)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\t\t\t}\n\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t    }    \n            else {$metadasgrp  = $null}\n\t\t}\n\t\n\t\tif(($criticalobject.ObjectCategory -eq $personClass) -and ($null -ne $criticalobject.altRecipient))\n\t\t{\n\t\t#For persons with altRecipients attribute we retrieve also the msDS-ReplValueMetadata attribute\n\t\t$isgcanduniversalorindom = $true\n\t\tif($nbviagc -and ($i -ge $nbviaLDAP))\n\t\t\t{\n\t\t\t\t\t$search = new-object System.DirectoryServices.DirectorySearcher\n\t\t\t\t\t$search.searchroot = [ADSI]\"GC://$($gc)\"\n\t\t\t\t\t$search.Tombstone = $true\n\t\t\t\t\t$search.PropertiesToLoad.Addrange(('msDS-ReplValueMetadata','Name','DistinguishedName'))\n\t\t\t\t\t$search.filter = \"(DistinguishedName=$($criticalobject.DistinguishedName))\"\n\t\t\t\t\t$search.pagesize = 256\n\t\t\t\t\t$objpers = \t$search.FindAll() | Convert-ADSearchResult\n\t\t\t}\n\n\t\telse\n\t\t\t{$objpers = get-adobject $criticalobject.DistinguishedName -Properties msDS-ReplValueMetadata -server $server -IncludeDeletedObjects}\n\n            if($error)\n            { \"$(Get-TimeStamp) Error while retrieving AD replication metadata attributes msDS-ReplValueMetadata for $($criticalobject.DistinguishedName) $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\tif($objpers.\"msDS-ReplValueMetadata\")\n            {$metadaspers = $objpers.\"msDS-ReplValueMetadata\" | foreach-object{ ([xml] $_.Replace(\"`0\",\"\")).DS_REPL_VALUE_META_DATA}\n\n\t\t\tif($error)\n        \t\t\t{ \"$(Get-TimeStamp) Error while parsing AD replication metadata attributes msDS-ReplValueMetadata for $($criticalobject.DistinguishedName) $($error)\" | out-file $logfilename -append ; $error.clear() }\n\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t$metadaspersrec = $metadaspers | where-object{$_.pszAttributeName -eq \"altRecipient\"}\n\t\t\t\tif($metadaspersrec)\n\t\t\t\t\t{\n\t\t\t\t\tforeach($metada in $metadaspersrec)\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t$tmpobj = new-object psobject\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ftimeLastOriginatingChange -Value $metada.ftimeLastOriginatingChange\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name Name -Value $obj.Name\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name pszAttributeName -Value $metada.pszAttributeName\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ObjectClass -Value $criticalobject.ObjectClass\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name DN -Value $obj.DistinguishedName\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ObjectCategory -Value $criticalobject.ObjectCategory\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name SamAccountName -Value $criticalobject.SamAccountName\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name dwVersion -Value $metada.dwVersion\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name WhenCreated -Value $whencreatedUTC\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name Member -Value $metada.pszObjectDn\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ftimeCreated -Value $metada.ftimeCreated\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name ftimeDeleted -Value $metada.ftimeDeleted\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name SID -Value $criticalobject.objectSid\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name pszLastOriginatingDsaDN -Value $metada.pszLastOriginatingDsaDN\n\t   \t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name uuidLastOriginatingDsaInvocationID -Value $metada.uuidLastOriginatingDsaInvocationID\n\t    \t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name usnOriginatingChange -Value $metada.usnOriginatingChange\n\t\t\t\t\t\tadd-member -InputObject $tmpobj -MemberType NoteProperty -Name usnLocalChange -Value $metada.usnLocalChange\n\n\t    \t\t\t\t[void]$Replinfo.add($tmpobj)\n\t\t\t\t\t\tif($error){ \"$(Get-TimeStamp) Error while editing global AD replication metadata object $($error) for $($criticalobject.DistinguishedName)\" | out-file $logfilename -append ; $error.clear() }\n\t\t\t\t\t\t}\n\n\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\n            }\n            else {$metadaspers  = $null}       \n        \n        }\n\n\t}\n\t$i++\n\t}\n\n\"$(Get-TimeStamp) AD replication metadata retrieved\" | out-file $logfilename -append\n\n\n# Sort by ftimeLastOriginatingChange to generate timeline and export as csv\n\"$(Get-TimeStamp) Sorting AD replication metadata to generate timeline \" | out-file $logfilename -append\n\n$Replinfo | Sort-Object -Property ftimeLastOriginatingChange | export-csv $timelinefilename -delimiter \";\" -NoTypeInformation -Encoding UTF8\n    if($error)\n        { \"$(Get-TimeStamp) Error while sortig timeline $($error)\" | out-file $logfilename -append ; $error.clear() }\n    else\n        { \"$(Get-TimeStamp) Timeline created\" | out-file $logfilename -append }\n\nwrite-output -inputobject \"---- Timeline created ----\"\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "![ADTimeline](./logo.png)\n---\n# Table of contents:\n1. [The ADTimeline PowerShell script](#thescript)\n    1. [Description](#description)\n    2. [Prerequisites](#prerequisites)\n    3. [Usage](#usage)\n    4. [Files generated](#files)\n    5. [Custom groups](#groups)\n2. [The ADTimeline App for Splunk](#theapp)\n    1. [Description](#descriptionsplk)\n    2. [Sourcetypes](#sourcetype)\n    3. [AD General information dashboards](#infradashboards)\n    4. [AD threat hunting dashboards](#threathuntdashboards)\n    5. [Enhance your traditional event logs threat hunting with ADTimeline](#threathuntevtx)\n\n# The ADTimeline PowerShell script:  <a name=\"thescript\"></a>\n\n## Description: <a name=\"description\"></a>\n\nThe ADTimeline script generates a timeline based on Active Directory replication metadata for objects considered of interest.  \nReplication metadata gives you the time at which each replicated attribute for a given object was last changed. As a result the timeline of modifications is partial. For each modification of a replicated attribute a version number is incremented.  \nADTimeline was first presented at the [CoRI&IN 2019](https://www.cecyf.fr/coriin/coriin-2019/) (Conférence sur la réponse aux incidents et l’investigation numérique). Slides of the presentation, in french language,  are available [here](https://cyber.gouv.fr/publications/investigation-numerique-sur-lannuaire-active-directory-avec-les-metadonnees-de). It was also presented at the [Amsterdam 2019 FIRST Technical Colloquium](https://www.first.org/events/colloquia/amsterdam2019/program#pActive-Directory-forensics-with-replication-metadata-ADTimeline-tool), slides in english are available [here](https://cyber.gouv.fr/en/actualites/adtimeline-active-directory-forensics-replication-metadata-first-technical-colloquium).\n\nObjects considered of interest retrieved by the script include:\n\n- Schema and configuration partition root objects.\n- Domain root and objects located directly under the root.\n- Objects having an ACE on the domain root.\n- Domain roots located in the AD forest.\n- Domain trusts.\n- Deleted users (i.e. tombstoned).\n- Objects protected by the SDProp process (i.e. AdminCount equals 1).\n- The Guest account.\n- The AdminSDHolder object.\n- Objects having an ACE on the AdminSDHolder object.\n- Class Schema objects.\n- Existing and deleted Group Policy objects.\n- DPAPI secrets.\n- Domain controllers (Computer objects, ntdsdsa and server objects).\n- DNS zones.\n- WMI filters.\n- Accounts with suspicious SIDHistory (scope is forest wide).\n- Sites.\n- Organizational Units.\n- Objects with Kerberos delegation enabled.\n- Extended rights.\n- Schema attributes with particular SearchFlags (Do not audit or confidential).\n- Kerberoastable user accounts (SPN value).\n- AS-REP roastable accounts (UserAccountControl value).\n- Authentication policy silos.\n- CertificationAuthority and pKIEnrollmentService objects.\n- Cross Reference containers.\n- Exchange RBAC roles and accounts assigned to a role.\n- Exchange mail flow configuration objects.\n- Exchange mailbox databases objects.\n- Exchange Mailbox Replication Service objects\n- Deleted objects under the configuration partition.\n- Dynamic objects.\n- The directory service and RID manager objects.\n- The Pre Windows 2000 compatible access, Cert publishers, GPO creator owners and DNS Admins groups.\n- ADFS DKM containers.\n- Service connection point objects considered of interest.\n- Custom groups which have to be manually defined.\n- User objects with mail forwarder enabled (msExchGenericForwardingAddress and altRecipient attributes).\n\n## Prerequisites: <a name=\"prerequisites\"></a>\n\n- The account launching the script should be able to read objects in the tombstone (Deleted Objects Container) and some parts of the Exchange settings located in the configuration partition (View-Only Organization management). Delegation can be tricky to setup (especially for reading the tombstone). That is why we advise you to run the script with a domain admin account. If you launch the script as a standard user, it will process the timeline without the objects mentioned.\n- Computer should run Windows NT 6.1 or later with PowerShell 2.0 or later and have the Active Directory Powershell module installed (part of RSAT-AD-Tools).\n- If you enabled PowerShell Constrained Language Mode the script might fail (calling $error.clear()). Consider whitelisting the script via your device guard policy.\n- If you are using offline mode install the ADLDS role on a Windows Server edition in order to use dsamain.exe and mount the NTDS database.\n\n    The version of the Windows Server you install the role on should be the same as the version of the Windows Server which the ntds.dit came from. If you do not know that version and you have the SOFTWARE hive available, you can look at the CurrentVersion key.\n    \n    If you can not mount the ntds.dit file with dsamain.exe, this might be because the NTDS dump is corrupted. In that case, you can follow [advice from cert-cwatch](https://github.com/ANSSI-FR/ADTimeline/issues/17#issuecomment-1984049537).\n\n## Usage: <a name=\"usage\"></a>\n\nIn online mode no argument is mandatory and the closest global catalog is used for processing. If no global catalog is found run the script with the server argument :\n```DOS\nPS> .\\ADTimeline.ps1 -server <GLOBAL CATALOG FQDN>\n```\nIn offline mode: Replay if necessary transaction logs of the NTDS database, mount it on your analysis machine (ADLDS + RSAT-AD-Tools installed) and use 3266 as LDAP port.\n```DOS\nC:\\Windows\\System32> dsamain.exe -dbpath <NTDS.DIT path> -ldapport 3266 -allownonadminaccess\n```\nIf necessary use the allowupgrade switch.\n\nLaunch the script targetting localhost on port 3266:\n```DOS\nPS> .\\ADTimeline.ps1 -server \"127.0.0.1:3266\"\n```\n\nIf you encounter performance issues when running against a large MSExchange organization with forwarders massively used, use the nofwdSMTP parameter:\n```DOS\nPS>.\\ADTimeline -nofwdSMTPaltRecipient\n```\n## Files generated <a name=\"files\"></a>\n\nOutput files are generated in the current directory:\n\n- timeline_%DOMAINFQDN%.csv: The timeline generated with the AD replication metadata of objects retrieved.\n- logfile_%DOMAINFQDN%.log: Script log file. You will also find various information on the domain.\n- ADobjects_%DOMAINFQDN%.xml: Objects of interest retrieved via LDAP.\n- gcADobjects_%DOMAINFQDN%.xml: Objects of interest retrieved via the Global Catalog.\n\n\nTo import files for analysis with powershell. \n```powershell\nPS> import-csv timeline_%DOMAINFQDN%.csv -delimiter \";\"\nPS> import-clixml ADobjects_%DOMAINFQDN%.xml\nPS> import-clixml gcADobjects_%DOMAINFQDN%.xml\n```\nThe analysis with the ADTimeline for Splunk is a better solution.\n\n## Custom groups <a name=\"groups\"></a>\n\nIf you want to include custom AD groups in the timeline (for example virtualization admin groups, network admins, VIP groups...) use the *Customgroups* parameter.\n\n*Customgroups* parameter can be a string with multiple group comma separated (no space):\n```powershell\nPS>./ADTimeline -customgroups \"VIP-group1,ESX-Admins,Tier1-admins\"\n```\n*Customgroups* parameter can also be an array, in case you import the list from a file (one group per line):\n```powershell\nPS>$customgroups = get-content customgroups.txt\nPS>./ADTimeline -customgroups $customgroups\n```\nIf you do not want to use a parameter you can also uncomment and edit the following array at the  begining of the script:\n```powershell\n$groupscustom = (\"VIP-group1\",\"ESX-Admis\",\"Tier1-admins\")\n```\n\n# The ADTimeline App for Splunk: <a name=\"theapp\"></a>\n\n## Description: <a name=\"descriptionsplk\"></a>\n\nThe ADTimeline application for Splunk processes and analyses the Active Directory data collected by the ADTimeline PowerShell script. The app was presented at the 32nd annual FIRST Conference, a recording of the presentation is available [here](https://www.first.org/conference/2020/recordings).\n\nThe app's \"Getting started\" page will give you the instructions for the import process.\n\nOnce indexed the dashboards provided by the app will help the DFIR analyst to spot some Acitve Directory persistence mechanisms, misconfigurations, security audit logging bypass, mail exfiltration, brute force attacks ...\n\nThe app is also packaged and available on [Splunkbase](https://splunkbase.splunk.com/app/4897/). It has no prerequisite and will work with a [free Splunk](https://docs.splunk.com/Documentation/Splunk/latest/Admin/MoreaboutSplunkFree) license.\n\n![Splunkapp](./SA-ADTimeline.png)\n\n## Sourcetypes: <a name=\"sourcetype\"></a>\n\nAfter processing the ADTimeline script you should have two or three files to import in Splunk (%DOMAINFQDN% is the Active Directory fully qualified domain name):\n\n- timeline_%DOMAINFQDN%.csv: The timeline generated with the AD replication metadata of objects retrieved. The corresponding source type is *adtimeline*.\n- ADobjects_%DOMAINFQDN%.xml: Objects of interest retrieved via LDAP. The corresponding sourcetype is *adobjects*.\n- gcADobjects_%DOMAINFQDN%.xml: If any, objects of interest retrieved via the Global Catalog. The corresponding source type is *gcobjects*.\n\n### The adtimeline sourcetype:\n\n The *adtimeline* sourcetype is the data from the timeline_%DOMAINFQDN%.csv file, which is the Active Directory timeline built with replication metadata for objects considered of interest.\n\nThe timestamp value is the ftimeLastOriginatingChange value of the replication metadata, which is the time the attribute was last changed, time is UTC.\n\nThe extracted fields are:\n\n- Name: LDAP object name.\n- pszAttributeName: The attribute name.\n- dwVersion: Counter incremented every time the attribute is changed.\n- DN: LDAP object DistinguishedName.\n- WhenCreated: LDAP object creation time.\n- ObjectClass and ObjectCategory: LDAP object type (user, computer, group...)\n- SamAccountName and SID: Account Name and security identifier, only applies to users, computers and groups.\n- usnOriginatingChange: USN on the originating server at which the last change to this attribute was made.\n- pszLastOriginatingDsaDN: DC on which the last change was made to this attribute.\n- uuidLastOriginatingDsaInvocationID: ID corresponding to the pszLastOriginatingDsaDN.\n- usnLocalChange: USN on the destination server (the server your LDAP bind is made) at which the last change to this attribute was applied.\n- Member: Only applies to the group ObjectClass and when the attribute name is member. Contains the value of the group member DistinguishedName.\n- ftimeCreated: Only applies to group ObjectClass and when the attribute name is member. Contains the time the member was added in the group.\n- ftimeDeleted: Only applies to group ObjectClass and when the attribute name is member. Contains the time the member was removed from the group.\n\n### The adobjects sourcetype:\n\nThe *adobjects* sourcetype is the data from the ADobjects_%DOMAINFQDN%.xml file, which is an export of the Active Directory objects considered of interested and retrieved via the LDAP protocol.\n\nThe timestamp value is the createTimeStamp attribute value, time zone is specified in the attribute value.\n\nThe extracted fields are:\n\n- Name: LDAP object name.\n- DN: LDAP object DistinguishedName.\n- DisplayName: LDAP object displayname.\n- WhenCreated: LDAP object creation time.\n- ObjectClass and ObjectCategory: LDAP object type (user, computer, group...)\n- SamAccountName and SID: Account Name and security identifier, only applies to users, computers and groups.\n- Members and MemberOf: Members of a group ObjectClass can be users, computers or groups and its linked attribute MemberOf which applies to groups, users and computers.\n- Owner, AccessToString and SDDL: Are values computed from the nTSecurityDescriptor attribute\n- adminCount: Privileged accounts protected by the SDProp process.\n- userAccountControl: Attribute which contains a range of flags which define some important basic properties of a computer or user object.\n- lastLogonTimestamp: This attribute is not updated with all logon types or at every logon but is replicated and gives you an idea of wether a user or computer account has recently logged on to the domain.\n- dNSHostName: DNS hostname attribute of a computer account.\n- SPNs: List of Service Principal Names of a computer or user account.\n\n### The gcobjects sourcetype:\n\nThe *gcobjects* sourcetype is the data from the gcADobjects_%DOMAINFQDN%.xml file, which is an export of the Active Directory objects within the forest but outside the current domain and considered of interested, those objects are retrieved via the Global Catalog protocol.\n\nThe timestamp value is the WhenCreated attribute value, time zone is UTC.\n\nThe extracted fields are:\n\n- Name: LDAP object name.\n- DN: LDAP object DistinguishedName.\n- DisplayName: LDAP object displayname.\n- WhenCreated: LDAP object creation time.\n- ObjectClass and ObjectCategory: LDAP object type (user, computer, group...)\n- SamAccountName and SID: Account Name and security identifier, only applies to users, computers and groups.\n- userAccountControl: Attribute which contains a range of flags which define some important basic properties of a computer or user object.\n- lastLogonTimestamp: This attribute is not updated with all logon types or at every logon but is replicated and gives you an idea if a user or computer account has recently logged onto the domain.\n- dNSHostName: DNS hostname attribute of a computer account.\n- SPNs: List of Service Principal Names of a computer or user account.\n\n## AD General information dashboards: <a name=\"infradashboards\"></a>\n\n### The Active Directory Infrastructure dashboard:\n\nThis dashboard analyses Adtimeline data in order to create some panels giving you information on the Windows domain infrastructure.\n\nThe different panels are:\n\n- General information: Information about the Schema version and functional levels. Depending on the result some AD security features may or may not be available. The Domain Controllers are also listed in this panel\n- Microsoft infrastructure products: Tells you if some important Microsoft Infrastructure components such as Exchange on premises, Active Directory Federation Services or Active Directory Certificate Services are installed. Please consider monitoring events related to those services (MSExchange CmdletLogs, ADFS auditing...)\n- Domain Trusts: List domain trusts by type and direction. Run ADTimeline on all your trusted domains, but most importantly make sure they are audited, monitored and secured as rigorously as the domain you are analyzing.\n- ADDS security features: Tells you if some security features are enabled or not. First feature is the AD Recycle bin which gives the administrator the ability to easily recover deleted objects, it will also change the time after an object is removed from the AD database after deletion. Second feature tells you if the schema extension for the Local Admin Password Solution was performed, if yes sysadmins can enable password randomization for local administrators accounts in order to mitigate lateral movement. Another feature is authentication silos which can help to restrict privileged user account logons in order to mitigate privilege escalation by implementing a tiered administrative model. The last feature is the Protected Users group, with a DFL 2012R2 or more the members of this group receive some additional hardening\n- Service Connection Points: Inventory of serviceConnectionPoint (SCP) object class. SCP make it easy for a service to publish service-specific data in the directory Clients of the service use the data in an SCP to locate an instance of the service. Infrastructure assets such as RDS Gateway, SCCM, VMWare Vcenter, some Backup solutions publish an SCP in the directory.\n- Active Directory infrastructure timeline: Displays a timeline of the infrastructure changes listed above. This timeline tells you the story of the evolution of your infrastructure.\n\n### The sensitive accounts dashboard:\n\nThis dashboard provides an inventory of the privileged accounts in the domain and accounts prone to common attack scenarios due to their configuration.\n\n The different panels are:\n\n- Admin Accounts: This panel lists the accounts where the Admincount attribute value equals 1. Those accounts have their ACL protected by the SDProp process and it means the account has or had at some point high privileges in Active Directory. The first table lists them and provides some information about the accounts, the second table displays a timeline of modifications for some attributes of these accounts.\n- Accounts sensitive to Kerberoast attacks: Kerberoasting is an attack method that allows an attacker to crack the passwords of service accounts in Active Directory offline. The chart is a ratio of accounts prone to this attack and whether or not they are privileged accounts. The table lists them and provides some information about the accounts. Use least privilege principle for those accounts and consider using Group Managed Service Accounts.\n- Accounts sensitive to AS-REP Roast attacks: AS-REP Roast is an attack method that allows an attacker to crack the passwords of accounts in Active Directory offline. The chart is a ratio of accounts prone to this attack and whether or not they are privileged accounts. The table lists them and provides some information about the accounts. Use least privilege principle for those accounts.\n- Sensitive default accounts: Some general information about the default administrator, guest and krbtgt accounts. Administrator can be disabled or renamed as a measure against account lockout. Guest account must be disabled and krbtgt password should be changed on a regular schedule.\n- Accounts trusted for delegation: Kerberos Delegation is a feature that allows an application to reuse the end-user credentials to access resources hosted on a different server. An account trusted for unconstrained delegation is allowed to impersonate almost any user to any service within the network, whereas an account trusted for constrained delegation is allowed to impersonate almost any user for a given service within the network. The chart is a ratio of accounts trusted for constrained/unconstrained delegation. The tables list those accounts, the service name is given for accounts trusted for constrained delegation. A table listing objects with resource based constrained delegation configured is also displayed\n\n## AD threat hunting dashboards: <a name=\"threathuntdashboards\"></a>\n\n### The investigate timeframe dashboard:\n\nUse this dashboard to investigate a particular timeframe.\n\n The different panels are:\n\n- AD Timeline: A table displaying the timeline for the given timeframe.\n- Global stats: Global statistics on modifications occurring during the given timeframe, including modifications by ObjectClass, by pszAttributeName, by Originating DC, by time (i.e. day of the week or hour of the day) and finally stats on deletions by ObjectClass.\n- Items created and deleted within timeframe: A table displaying the creations and deletions of the same object within the given timeframe. A first chart gives you stats about object lifetimes in hours and a second one figures by ObjectClass.\n- Objects added or removed from groups or ACL modifications within timeframe: This table focuses on the Member and nTSecurityDescriptor attributes, which can help detect an elevation of privilege for a specific account or a backdoor setup by the attacker, the DistinguishedName value of the member and the time the member was added or removed from the group is given in that table. Which makes it more detailed than the above AD Timeline panel. A chart displaying nTSecurityDescriptor modifications by ObjectClass and another displaying the number of times an object was added or removed from a group are given\n- GPOs modifications within timeframe: A GPO can used by an attacker in various ways, for example to inject malicious code in logon/startup scripts, deploy malware at scale with an immediate scheduled task, setup a backdoor by modifying the nTSecurityDescriptor... For each attribute modification this table gives you the current client side extensions of the GPO and where the object is linked (OU, site or domain root).\n\n### The track suspicious activity dashboard\n\nThis dashboard analyses the Active Directory timeline and highlights some modifications which can be a sign of a suspicious activity, the modifications spoted can also be legitimate and need a triage analysis.\n\n The different panels are:\n\n- ACL modifications: This panel does not replace a thorough analysis of the Active Directory permissions with tools such as AD Control Paths. The panel contains a graph displaying a weekly timeline of ACL modifications per ObjectClass which occured one year back, some tables are focusing on the domain root and AdminSDHolder objects where permissions can be used as backdoor by an attacker. Finally, some statistics by ObjectClass and by least frequent owners are displayed.\n- Accounts: This panel show account modifications which can a be sign of suspicious activity such as users added and removed from groups, some charts provide stats by number of times the account was added or removed, membership time in days, Organizational unit where accounts are located (an account from the \"non_privileged_users\" OU added and removed from a privileged group can be a sign of suspicious activity). There are some graphs, the first graph shows a timeline of accounts lockouts in order to highlight brute force attacks, the second graph shows SID history editions which can be suspicious outside a domain migration period, the next graph analyses all the different attributes modified on an account during a password change (supplementalCredentials, lmPwdHistory, unicodePwd...) and checks they are modified at the same time. A table displays resource based constrained delegation setup on privileged account or domain controller computer objects, which can be a backdoor setup by an attacker. Finally a chart displays domain controller computer objects password change frequency, an attacker could modify the DC registry to disable computer password change and use this password as a backdoor.\n- GPOs: A table of GPOs modifications having an audit client side extension is displayed, an attacker could change the audit settings on the domain to perform malicious actions with stealth. Finally modifications which could result in a GPO processing malfunctioning are displayed, this includes gPCFunctionalityVersion, gPCFileSysPath or versionNumber attribute modification.\n- DCshadow detection: The DCshadow is an attack which allows an attacker to push modifications in Active Directory and bypass traditional alerting by installing a fake DC. It was first presented by Vincent Le Toux and Benjamin Delpy at the BlueHat IL 2018 conference. The first graph will try to detect the installation of the fake DC by analyzing server and nTDSDSA ObjectClass. The two following tables will try to detect replication metadata tampering by analyzing usnOriginatingChange and usnLocalChange values which should increment through the time.\n- Schema and configuration partition suspicious modifications: The first graph displays Active Directory attribute modifications related to the configuration and schema partitions which can lower the security of the domain, used as backdoor by an attacker or hide information to the security team. The second graph is relevant if you have Exchange on premises and track modifications in the configuration partition which can be a sign of mail exfiltration.\n\n### The track suspicious Exchange activity dashboard\n\nThis dashboard analyses your Exchange onprem Active Directory objects and highlights some modifications which can be a sign of a suspicious activity, the modifications spotted can also be legitimate and need a triage analysis.\n\n The different panels are:\n\n- Microsoft Exchange infrastructure: Exchange version and servers.\n- Possible mail exfiltration: Mail forwarders setup on mailboxes, transport rules, remote domains, maibox export requests, content searches...\n- Persistence: RBAC roles and ACL modifications on Exchange objects.\n- MsExchangeSecurityGroups: Timeline and group membership of builtin Exchange security groups.\n- Phishing:Modifications on transport rules related to SCL and disclaimer.\n\n## Enhance your traditional event logs threat hunting with ADTimeline: <a name=\"threathuntevtx\"></a>\n\nThe *adobjects* sourcetype is a set of data which can be used to uncover suspicious activity by performing Active Directory educated queries on the Windows event logs. We assume the sourcetype used for event logs is called *winevent* and its *EventData* part has the correct field extraction applied, for example *EventID 4624* has among other fields *TargetUserName* and *TargetUserSid* extracted:\n\n![EVtx](./SA-ADTimeline/appserver/static/images/tuto10.png)\n\nYou can perfrom similar queries with the [Splunk App for Windows Infrastructure](https://docs.splunk.com/Documentation/MSApp/2.0.0/Reference/Aboutthismanual) and the [Splunk Supporting Add-on for Active Directory](https://docs.splunk.com/Documentation/SA-LdapSearch/3.0.0/User/AbouttheSplunkSupportingAdd-onforActiveDirectory). Here are some queries using ADTimeline data and Windows event logs which can help with your threat hunt.\n\n- Statistics on privileged accounts logons:\n\n```vb\nindex=\"*\" sourcetype=\"winevent\" EventID=\"4624\" Channel=\"Security\" \n[ search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | rename SID as TargetUserSid | fields TargetUserSid ] \n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName | stats values(TargetFullName) as TargetFullName , values(LogonType) as logonTypes, values(IpAddress) as IpAdresses, values(Computer) as Computers, dc(Computer) as CountComputers, dc(IpAddress) as CountIpAdresses by TargetUserSid\n```\n- Get processes running under a privileged account, [detailed process auditing](https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing) should be enabled:\n\n```vb\nindex=\"*\" sourcetype=\"winevent\" EventID=\"4688\" Channel=\"Security\" \n[search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | rename SamAccountName as TargetUserName | fields TargetUserName] \nOR [search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | rename SID as SubjectUserSid | fields SubjectUserSid] \n|  stats values(CommandLine) by Computer, TargetUserName,SubjectUserName\n```\n- Get all privileged accounts PowerShell activity eventlogs:\n\n```vb\nindex=\"*\" sourcetype=\"winevent\" Channel=\"*PowerShell*\"  \n[search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | dedup SamAccountName | return 1000 $SamAccountName]\n```\n- Detect Kerberoasting possible activity:\n\n```vb\nindex=\"*\" sourcetype=\"winevent\" Channel=\"Security\" EventID=\"4769\" \n[search index=\"*\" sourcetype=adobjects (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND (SPNs=* AND NOT Name=krbtgt) earliest = 1 latest = now() | rename SID as ServiceSid | fields ServiceSid] \n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName  \n|  eval time=strftime(_time,\"%Y-%m-%d %H:%M:%S\") \n|  stats list(ServiceName) as Services, dc(ServiceName) as nbServices, list(time) as time by IpAddress, TicketEncryptionType \n| sort -nbServices\n```\n\n- Detect abnormal processes running under Kerberoastable accounts, [detailed process auditing](https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing) should be enabled:\n\n```vb\nindex=\"*\" sourcetype=\"winevent\" Channel=\"Security\" EventID=\"4688\" \n[search index=\"*\" sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND (SPNs=* AND NOT Name=krbtgt)  earliest = 1 latest = now()   | rename SamAccountName as TargetUserName | fields TargetUserName ] \nOR  [search index=\"*\" sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND (SPNs=* AND NOT Name=krbtgt)  earliest = 1 latest = now()   | rename SID as SubjectUserSid | fields SubjectUserSid ] \n|  stats values(CommandLine) as cmdlines, values(TargetUserName) as TargetSubjectNames, values(SubjectUserName) as SubjectUserNames by Computer\n```\n- Detect abnormal Kerberoastable user account logons:\n\n```vb\nindex=\"*\" sourcetype=\"winevent\" Channel=\"Security\" EventID=\"4624\" \n[search index=\"*\" sourcetype=adobjects   (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND (SPNs=* AND NOT Name=krbtgt)  earliest = 1 latest = now() | rename SID as TargetUserSid  | fields TargetUserSid] \n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName | stats values(TargetFullName) as TargetFullNames, values(IpAddress) as IpAddresses by LogonType, Computer\n```\n\n- Detect abnormal AS-REP roastable user account logons:\n\n```vb\nindex=\"*\" sourcetype=\"winevent\" Channel=\"Security\" EventID=\"4624\" \n[search index=\"*\" sourcetype=adobjects (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") earliest = 1 latest = now() |  eval eval_asrep_bit = floor(userAccountControl / pow(2, 22)) %2 | search eval_asrep_bit = 1 |  rename SID as TargetUserSid  | fields TargetUserSid]  \n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName | stats values(TargetFullName) as TargetFullNames, values(IpAddress) as IpAddresses by LogonType, Computer\n```\n- Privileged accounts with flag \"cannot be delegated\" not set authenticating against computer configured for unconstrained delegation:\n\n```vb\nindex=\"*\" sourcetype=\"winevent\" EventID=\"4624\" Channel=\"Security\" \n[search index=\"*\" sourcetype=adobjects ObjectClass = \"Computer\" earliest = 1 latest = now() | eval eval_deleg_bit = floor(userAccountControl / pow(2, 19)) %2  | search  eval_deleg_bit = 1 | eval eval_dc_bit = floor(userAccountControl / pow(2, 13)) %2 |  eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 | search eval_dc_bit = 0 AND eval_rodc_bit = 0 |   rename dNSHostName as Computer | fields Computer] \n|  search *   [search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | eval canbedelagated = round(((userAccountControl / pow(2, 20)) %2), 0) | search canbedelagated = 0 | rename SID as TargetUserSid  | fields TargetUserSid ] \n|  strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName \n| table  _time, Computer, TargetFullName, IpAddress, LogonType, LogonProcessName\n```\n\n- Detect possible [printer bug](https://posts.specterops.io/not-a-security-boundary-breaking-forest-trusts-cd125829518d) triggering:\n\n```vb\nindex=\"*\" sourcetype=\"winevent\" EventID=\"4624\" Channel=\"Security\" TargetUserName = \"*$\" NOT TargetUserSid=\"S-1-5-18\"\n[search index=\"*\" sourcetype=adobjects ObjectClass = \"Computer\"  earliest = 1 latest = now() |  eval eval_deleg_bit = floor(userAccountControl / pow(2, 19)) %2  | search  eval_deleg_bit = 1 | eval eval_dc_bit = floor(userAccountControl / pow(2, 13)) %2 |  eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 | search eval_dc_bit = 0 AND eval_rodc_bit = 0  |  rename dNSHostName as Computer | fields Computer]\n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName | stats values(LogonType), values(IpAddress), values(LogonProcessName) count by Computer, TargetFullName\n```\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "SA-ADTimeline/README",
    "content": "Contact information: adtimeline@ssi.gouv.fr\r\nThere is no package requirements to install the app.\r\nThis is an open source project, no support provided, public repository available at https://github.com/ANSSI-FR/ADTimeline/\r\nPlease have a look at the \"Getting started\" tab for detailed instructions."
  },
  {
    "path": "SA-ADTimeline/default/app.conf",
    "content": "#\r\n# Splunk app configuration file\r\n#\r\n[package]\r\nid = SA-ADTimeline\r\ncheck_for_updates = true\r\n\r\n[install]\r\nis_configured = 0\r\n\r\n[ui]\r\nis_visible = 1\r\nlabel = ADTimeline\r\n\r\n[launcher]\r\nauthor = Leonard SAVINA (@ldap389) - Nicolas LE CHAPELAIN\r\ndescription = ADTimeline app for Splunk is an open source project, code is available at https://github.com/ANSSI-FR/ADTimeline\r\nversion = 1.2.5\r\n\r\n[id]\r\nname = SA-ADTimeline\r\nversion = 1.2.5\r\n"
  },
  {
    "path": "SA-ADTimeline/default/data/ui/nav/default.xml",
    "content": "<nav search_view=\"search\" color=\"#2B2BA1\">\r\n  <view name=\"search\" default='true' />\r\n  <view name=\"getting_started\" />\r\n  <collection label=\"AD General information\">\r\n  <view name=\"ad_infra\" />\r\n  <view name=\"sensitive_accounts\" />\r\n  </collection>\r\n  <collection label=\"AD Threat hunting\">\r\n  <view name=\"investigate_timeframe\" />\r\n  <view name=\"suspicious_activity\" />\r\n  <view name=\"suspicious_exchange_activity\" />\r\n  </collection>\r\n  <view name=\"datasets\" />\r\n  <view name=\"reports\" />\r\n  <a href=\"https://github.com/ANSSI-FR/ADTimeline\">ADTimeline on github</a>\r\n</nav>\r\n"
  },
  {
    "path": "SA-ADTimeline/default/data/ui/views/ad_infra.xml",
    "content": "<form version=\"1.1\">\r\n  <label>Active Directory infrastructure</label>\r\n  <fieldset submitButton=\"false\"></fieldset>\r\n  <row>\r\n    <panel>\r\n      <input type=\"dropdown\" token=\"ad_index\" searchWhenChanged=\"true\">\r\n        <label>Choose index to process:</label>\r\n        <search>\r\n          <query>| tstats latest(_time) where index=*  by index</query>\r\n        </search>\r\n        <selectFirstChoice>true</selectFirstChoice>\r\n        <fieldForLabel>index</fieldForLabel>\r\n        <fieldForValue>index</fieldForValue>\r\n      </input>\r\n      <input type=\"dropdown\" token=\"domain_host\" searchWhenChanged=\"true\">\r\n        <label>Choose AD Domain to process:</label>\r\n        <search>\r\n          <query>| tstats latest(_time) where index=$ad_index$ (sourcetype=adobjects OR sourcetype=gcobjects OR sourcetype=adtimeline)  by host</query>\r\n        </search>\r\n        <selectFirstChoice>true</selectFirstChoice>\r\n        <fieldForLabel>host</fieldForLabel>\r\n        <fieldForValue>host</fieldForValue>\r\n      </input>\r\n    </panel>\r\n    <panel>\r\n      <html>\r\n      <p style=\"text-align:center;\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/logo.png\"/>\r\n        </p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>General information:</title>\r\n      <html>\r\n        <style>\r\n          #SchemaVersion .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n\r\n        </style>\r\n     </html>\r\n      <single id=\"SchemaVersion\">\r\n        <title>AD schema version, ObjectVersion attribute of dMD ObjectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects ObjectClass=dMD | rex field=_raw \"objectVersion\\\"&gt;(?&lt;ObjectVersion&gt;.+?)&lt;/I32&gt;\"  |  lookup Schema_lookup ObjectVersion AS ObjectVersion OUTPUTNEW SchemaVersion AS SchemaV | eval range = case ( ObjectVersion &lt; 48, \"severe\", ObjectVersion &lt; 69, \"elevated\" , ObjectVersion &lt; 1000 , \"low\" )</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"field\">SchemaV</option>\r\n        <option name=\"rangeColors\">[\"0x53a051\",\"0x0877a6\",\"0xf8be34\",\"0xf1813f\",\"0xdc4e41\"]</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=adobjects%20OR%20sourcetype=adtimeline)%20ObjectClass=dMD&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n      <html tokens=\"true\" encoded=\"true\">\r\n        <![CDATA[\r\n          <br/>\r\n          ]]>\r\n      </html>\r\n      <chart>\r\n        <title>AD forest and domain functional level, msDS-Behavior-Version atribute:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects  ObjectClass = \"crossref\" OR ObjectClass = \"crossrefcontainer\" | rex field=_raw \"systemFlags\\\"&gt;(?&lt;systemFlags&gt;.+?)&lt;/I32&gt;\" | search systemFlags = \"3\" OR ObjectClass = \"crossrefcontainer\" | rex field=_raw \"msDS-Behavior-Version\\\"&gt;(?&lt;msDSBehaviorVersion&gt;.+?)&lt;/I32&gt;\" | eval Name=case(Name == \"Partitions\", \"FOREST FUNCTIONAL LEVEL\", 1=1 , Name ) | stats count by msDSBehaviorVersion, Name</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"charting.axisTitleX.visibility\">collapsed</option>\r\n        <option name=\"charting.axisTitleY.visibility\">collapsed</option>\r\n        <option name=\"charting.axisTitleY2.visibility\">collapsed</option>\r\n        <option name=\"charting.chart\">fillerGauge</option>\r\n        <option name=\"charting.chart.rangeValues\">[0,4,4.1,7]</option>\r\n        <option name=\"charting.chart.style\">shiny</option>\r\n        <option name=\"charting.gaugeColors\">[\"0xdc4e41\",\"0xf8be34\",\"0x53a051\"]</option>\r\n        <option name=\"charting.legend.placement\">none</option>\r\n        <option name=\"height\">236</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <option name=\"trellis.enabled\">1</option>\r\n        <option name=\"trellis.size\">small</option>\r\n        <option name=\"trellis.splitBy\">Name</option>\r\n      </chart>\r\n      <html>\r\n       <p style=\"text-align:center;\">Windows 2000=0 | Windows 2003 Interim=1 | Windows 2003=2 | Windows 2008=3 | Windows 2008R2=4 <br/> Windows 2012=5 | Windows 2012 R2=6 | Windows 2016=7 | Windows 2019=7</p>\r\n      </html>\r\n      <table>\r\n        <title>DCs in the current domain, computer ObjectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects OR sourcetype=gcobjects ObjectClass= \"Computer\" DN = \"*,OU=Domain Controllers,*\" |   eval eval_dc_bit = floor(userAccountControl / pow(2, 13)) %2 |  eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 | search eval_dc_bit = 1 OR eval_rodc_bit = 1 | rex field=_raw \"operatingSystem\\\"&gt;(?&lt;operatingSystem&gt;.+?)&lt;/S&gt;\" | stats count by Name, operatingSystem, whenCreated  | rename Name as \"DC name\", operatingSystem  as \"DC operating system\", whenCreated as \"DC creation time\" |  table \"DC name\", \"DC operating system\", \"DC creation time\"</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"DC operating system\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline%20ObjectClass=%20%22Computer%22%20DN%20=%20%22*,OU=Domain%20Controllers,*%22&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <table>\r\n        <title>FSMO roles, fSMORoleOwner attribute:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects (ObjectClass= \"DomainDNS\" OR ObjectClass= \"dMD\" OR ObjectClass= \"rIDManager\" OR ObjectClass= \"crossRefContainer\" OR ObjectClass= \"infrastructureUpdate\") | rex field=_raw \"&lt;S N=\\\"fSMORoleOwner\\\"&gt;CN=NTDS Settings,(?&lt;fsmoroleowner&gt;.+?)&lt;/S&gt;\" |  lookup fsmo_lookup ObjectClass AS ObjectClass OUTPUTNEW FSMORole AS FSMORole | table FSMORole, fsmoroleowner, ObjectClass</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=adobjects%20OR%20sourcetype=adtimeline)%20(ObjectClass=%20%22DomainDNS%22%20OR%20ObjectClass=%20%22dMD%22%20OR%20ObjectClass=%20%22rIDManager%22%20OR%20ObjectClass=%20%22crossRefContainer%22%20OR%20ObjectClass=%20%22infrastructureUpdate%22)%20OR%20%5Bsearch%20index%20=%20%22ad%22%20sourcetype=adobjects%20(ObjectClass=%20%22DomainDNS%22%20OR%20ObjectClass=%20%22dMD%22%20OR%20ObjectClass=%20%22rIDManager%22%20OR%20ObjectClass=%20%22crossRefContainer%22%20OR%20ObjectClass=%20%22infrastructureUpdate%22)%20%7C%20rex%20field=_raw%20%22%3CS%20N=%5C%22fSMORoleOwner%5C%22%3ECN=NTDS%20Settings,(%3F%3Cfsmoroleowner%3E.%2B%3F)%3C/S%3E%22%20%7C%20%20%20stats%20count%20by%20fsmoroleowner%20%7C%20eval%20DN%20=%20fsmoroleowner%20%7C%20table%20DN%5D&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </table>\r\n    </panel>\r\n    <panel>\r\n      <title>Microsoft infrastructure products:</title>\r\n      <html>\r\n        <style>         \r\n\t\t #Exchangecheck .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n          #Exchangever .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n          #ADFSCheck .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n          #ADCSCheck .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n        </style>\r\n     </html>\r\n      <single id=\"Exchangecheck\">\r\n        <title>Microsoft Exchange schema information, rangeUpper attribute of ms-Exch-Schema-Version-Pt object:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects (ObjectClass=attributeSchema AND Name=ms-Exch-Schema-Version-Pt)  | table Name | appendpipe [stats count | eval \"Name\"=\"Void\" | where count=0 | table \"Name\"] | eval checkExch =case(Name == \"ms-Exch-Schema-Version-Pt\", \"Exchange installed in the AD forest\", 1=1 , \"Exchange not installed in the AD forest\") | fields checkExch</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline)%20((Name%20=%20%22Exchange%20Trusted%20Subsystem%22%20AND%20ObjectCategory=%20%22CN=Group,CN=Schema,CN=Configuration*%22)%20OR%20ObjectClass=%20%22msExchExchangeServer%22%20OR%20(ObjectClass=attributeSchema%20AND%20Name=ms-Exch-Schema-Version-Pt)%20)&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n      <html tokens=\"true\" encoded=\"true\">\r\n        <![CDATA[\r\n          <br/>\r\n          ]]>\r\n      </html>\r\n      <single id=\"Exchangever\">\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects (ObjectClass=attributeSchema AND Name=ms-Exch-Schema-Version-Pt)  | rex field=_raw \"rangeUpper\\\"&gt;(?&lt;rangeUpper&gt;.+?)&lt;/I32&gt;\" |  lookup ExchangeSchema_lookup rangeUpper AS rangeUpper OUTPUTNEW Exchange AS ExchangeV | stats count by ExchangeV, rangeUpper | rangemap field=rangeUpper low=15331-1000000 elevated=15312-15331 default=severe</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">none</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n      </single>\r\n      <table rejects=\"$show_html_msExch$\">\r\n        <title>Microsoft Exchange servers, msExchExchangeServer ObjectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects ObjectClass=msExchExchangeServer  | rex field=_raw \"&lt;S&gt;Version (?&lt;ExchVersion&gt;.+?)&lt;/S&gt;\" | stats count by Name, ExchVersion, whenCreated  | rename Name as \"Exchange server name\", ExchVersion as \"Exchange server version\", whenCreated as \"Exchange server creation time\" |  table \"Exchange server name\", \"Exchange server version\", \"Exchange server creation time\"</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_msExch\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_msExch\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"Exchange server version\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline)%20ObjectClass=msExchExchangeServer&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_msExch$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Microsoft Exchange servers, msExchExchangeServer ObjectClass: No results</p>\r\n      </html>\r\n      <html tokens=\"true\" encoded=\"true\">\r\n        <![CDATA[\r\n          <br/>\r\n          ]]>\r\n      </html>\r\n      <single id=\"ADFSCheck\">\r\n        <title>Microsoft ADFS Information, ADFS container:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects OR sourcetype=gcobjects (DN =\"CN=ADFS,CN=Microsoft,CN=Program Data*\")   | table Name | appendpipe [stats count | eval \"Name\"=\"Void\" | where count=0 | table \"Name\"] | eval checkADFS =case(Name == \"ADFS\", \"ADFS installed in the AD Forest\", 1=1 , \"ADFS not installed in the AD forest\") | fields checkADFS</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline%20(DN%20=%22*CN=ADFS,CN=Microsoft,CN=Program%20Data*%22)&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n      <html tokens=\"true\" encoded=\"true\">\r\n        <![CDATA[\r\n          <br/>\r\n          ]]>\r\n      </html>\r\n      <table id=\"ADCSCheck\">\r\n        <title>Microsoft ADCS information, certificationAuthority ObjectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects ObjectClass=certificationAuthority (DN =\"*,CN=Certification Authorities,CN=Public Key Services,CN=Services,*\" OR DN =\"*CN=NTAuthCertificates,CN=Public Key Services,CN=Services,CN=Configuration,*\")   |  table ObjectClass, DN, Name | appendpipe [stats count | eval \"ObjectClass\"=\"Void\", \"DN\"=\"Void\", \"Name\"=\"Void\"  | where count=0 | table \"ObjectClass\"] | eval CAName = \"\\\"\" + Name + \"\\\" entreprise CA configured\" | eval checkEntCA =case(ObjectClass == \"certificationAuthority\" AND DN LIKE \"%CN=Certification Authorities%\", CAName,  ObjectClass == \"certificationAuthority\" AND DN LIKE \"%CN=NTAuthCertificates,%\" , \" NTAuthCertificates for smartcard logon configured\" , 1=1 , \"No CA configured\")   | stats values(checkEntCA) as checkEntCA | mvexpand checkEntCA | rename checkEntCA as \"Cert Authorities configured\"</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline%20ObjectClass=certificationAuthority&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <table rejects=\"$show_html_adcs1$\">\r\n        <title>ADCS Enrollment servers, pKIEnrollmentService ObjectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects ObjectClass=pKIEnrollmentService  | rex field=_raw \"cACertificateDN\\\"&gt;(?&lt;cACertificateDN&gt;.+?)&lt;/S&gt;\"  | stats count by dNSHostName, cACertificateDN, whenCreated  | rename dNSHostName as \"ADCS server name\", cACertificateDN as \"CA Name\", whenCreated as \"ADCS server installation time\" |  table \"ADCS server name\", \"CA Name\" , \"ADCS server installation time\"</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_adcs1\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_adcs1\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"dataOverlayMode\">none</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline)%20ObjectClass=pKIEnrollmentService&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_adcs1$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">ADCS Enrollment servers, pKIEnrollmentService ObjectClass: No results</p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>Domain Trusts:</title>\r\n      <chart rejects=\"$show_html_trust1$\">\r\n        <title>Trusts types, trustedDomain objectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects ObjectClass=trustedDomain | rex field=_raw \"trustAttributes\\\"&gt;(?&lt;trustAttributes&gt;.+?)&lt;/I32&gt;\" | rex field=_raw \"trustDirection\\\"&gt;(?&lt;trustDirection&gt;.+?)&lt;/I32&gt;\" | eval trust=case( floor(trustAttributes / pow(2, 5)) %2 == 1 , \"Forest internal\", (trustAttributes / pow(2, 2)) %2 == 1 , \"Quarantined domain - SID filtering enabled\",  (trustAttributes / pow(2, 6)) %2 == 1 , \"Treat as external trust - SID history enabled\" , 1=1 , \"Other type of trust\") | eval direction = case(trustDirection == 0, \"disabled\", trustDirection == 1, \"inbound\", trustDirection == 2, \"outbound\", 1=1, \"bidirectional\") | eval trusttype = trust + \"-\" + direction |  stats count  as \"Trust types\"  by trusttype</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_trust1\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_trust1\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.axisTitleX.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY2.visibility\">visible</option>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.sliceCollapsingThreshold\">0.01</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"charting.legend.placement\">right</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <option name=\"trellis.enabled\">0</option>\r\n        <option name=\"trellis.splitBy\">_aggregation</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20ObjectClass=trustedDomain%20%7C%20rex%20field=_raw%20%22trustAttributes%5C%22%3E(%3F%3CtrustAttributes%3E.%2B%3F)%3C/I32%3E%22%20%7C%20rex%20field=_raw%20%22trustDirection%5C%22%3E(%3F%3CtrustDirection%3E.%2B%3F)%3C/I32%3E%22%20%7C%20eval%20trust=case(%20floor(trustAttributes%20/%20pow(2,%205))%20%252%20==%201%20,%20%22Forest%20internal%22,%20(trustAttributes%20/%20pow(2,%202))%20%252%20==%201%20,%20%22Quarantined%20domain%20-%20SID%20filtering%20enabled%22,%20%20(trustAttributes%20/%20pow(2,%206))%20%252%20==%201%20,%20%22Treat%20as%20external%20trust%20-%20SID%20history%20enabled%22%20,%201=1%20,%20%22Other%20type%20of%20trust%22)%20%7C%20eval%20direction%20=%20case(trustDirection%20==%200,%20%22disabled%22,%20trustDirection%20==%201,%20%22inbound%22,%20trustDirection%20==%202,%20%22outbound%22,%201=1,%20%22bidirectional%22)%20%7C%20eval%20trusttype%20=%20trust%20%2B%20%22-%22%20%2B%20direction%20%0A%7C%20%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_trust1$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Trusts types, trustedDomain objectClass: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_trust2$\">\r\n        <title>Trusts list, trustedDomain objectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects ObjectClass=trustedDomain | rex field=_raw \"trustAttributes\\\"&gt;(?&lt;trustAttributes&gt;.+?)&lt;/I32&gt;\" | rex field=_raw \"trustDirection\\\"&gt;(?&lt;trustDirection&gt;.+?)&lt;/I32&gt;\"  | rex field=_raw \"AccountDomainSid\\\"&gt;(?&lt;AccountDomainSid&gt;.+?)&lt;/S&gt;\" | eval trust = mvappend ( if ( floor(trustAttributes / pow(2, 0)) %2 == 1 , \"Non transitive\" , null() ), if ( floor(trustAttributes / pow(2, 1)) %2 == 1 , \"Uplevel only\" , null() ) , if ( floor(trustAttributes / pow(2, 2)) %2 == 1 , \"Quarantined domain - SID filtering enabled\" , null() ) , if ( floor(trustAttributes / pow(2, 3)) %2 == 1 , \"Forest Transitive\" , null() ) , if ( floor(trustAttributes / pow(2, 4)) %2 == 1 , \"Cross org trust\" , null() ) , if ( floor(trustAttributes / pow(2, 5)) %2 == 1 , \"Forest internal\" , null() ), if ( floor(trustAttributes / pow(2, 6)) %2 == 1 , \"Treat as external trust - SID history enabled\" , null() ), if ( floor(trustAttributes / pow(2, 7)) %2 == 1 , \"Uses RC4 encryption\" , null() ) , if ( floor(trustAttributes / pow(2, 8)) %2 == 1 , \"Uses AES encryption\" , null() ) , if ( floor(trustAttributes / pow(2, 9)) %2 == 1 , \"Cross org trust with no TGT delegation\" , null() )  , if ( floor(trustAttributes / pow(2, 10)) %2 == 1 , \"Treat as external trust with Privileged Identity Management\" , null() ))    | eval direction = case(trustDirection == 0, \"disabled\", trustDirection == 1, \"inbound\", trustDirection == 2, \"outbound\", 1=1, \"bidirectional\") | rename Name as \"Trust partner\", AccountDomainSid as \"Trust partner SID\", trust as \"trust type\", whenCreated as \"trust creation time\", direction as \"trust direction\" | table \"Trust partner\", trustAttributes, \"trust direction\", \"trust type\", \"trust creation time\", \"Trust partner SID\"</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_trust2\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_trust2\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"dataOverlayMode\">none</option>\r\n        <format type=\"color\" field=\"trust direction\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"trust type\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline)%20ObjectClass=TrustedDomain&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_trust2$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Trusts list, trustedDomain objectClass: No results</p>\r\n      </html>\r\n    </panel>\r\n    <panel>\r\n      <title>ADDS security features:</title>\r\n      <html>\r\n        <style>         \r\n\t\t #RecycleCheck .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n          #LAPSCheck .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n          #SiloCheck .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n          #ProtectedGroups .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n        </style>\r\n     </html>\r\n      <single id=\"RecycleCheck\">\r\n        <title>Recycle bin, crossRefContainer objectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$   host=$domain_host$  ObjectClass = \"crossRefContainer\" sourcetype=adobjects DN = \"CN=Partitions,CN=Configuration,*\"    | rex field=_raw \"&lt;S&gt;(?&lt;optionalfeature&gt;.+?)&lt;/S&gt;\" | eval Recycle =case(optionalfeature like \"%Recycle Bin Feature%\", \"Recycle Bin feature is enabled\"), Recyclevalue =case(optionalfeature like \"%Recycle Bin Feature%\", 1) | fillnull Recycle value=\"Recycle Bin feature is disabled\"| fillnull Recyclevalue value=0 | table Recycle, Recyclevalue | stats count by Recycle, Recyclevalue | rangemap field=Recyclevalue low=1-2 default=severe</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline)%20ObjectClass=crossRefContainer&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n      <html tokens=\"true\" encoded=\"true\">\r\n        <![CDATA[\r\n          <br/>\r\n          ]]>\r\n      </html>\r\n      <single id=\"LAPSCheck\">\r\n        <title>LAPS, attributeSchema objectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$  host=$domain_host$  sourcetype=adobjects ObjectClass=attributeSchema Name=ms-Mcs-AdmPwd   | table Name | appendpipe [stats count | eval \"Name\"=\"Void\" | where count=0 | table \"Name\"] | eval LAPS =case(Name == \"ms-Mcs-AdmPwd\", \"LAPS schema extension done\", 1=1, \"Schema not setup for LAPS\"), LAPSValue = case(Name == \"ms-Mcs-AdmPwd\", 1, 1=1 ,0) | stats count by LAPS, LAPSValue | rangemap field=LAPSValue low=1-2 default=elevated</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline)%20ObjectClass=attributeSchema%20Name=ms-Mcs-AdmPwd&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n      <html tokens=\"true\" encoded=\"true\">\r\n        <![CDATA[\r\n          <br/>\r\n          ]]>\r\n      </html>\r\n      <single id=\"SiloCheck\">\r\n        <title>Authentication silos, msDS-AuthNPolicySilo and msDS-AuthNPolicy objectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$  host=$domain_host$  sourcetype=adobjects (ObjectClass=msDS-AuthNPolicySilo OR ObjectClass=msDS-AuthNPolicy)  | table ObjectClass | appendpipe [stats count | eval \"ObjectClass\"=\"Void\" | where count=0 | table \"ObjectClass\"] | eval Silo =case(ObjectClass == \"msDS-AuthNPolicy\" OR ObjectClass == \"msDS-AuthNPolicySilo\" , \"Authentication silos configured, check also if DFL is greater or equal 6\", 1=1, \"No authentication silos configured\"), SiloValue = case(ObjectClass == \"msDS-AuthNPolicy\" OR ObjectClass == \"msDS-AuthNPolicySilo\", 1, 1=1 ,0) | stats count by Silo, SiloValue | rangemap field=SiloValue low=1-2 default=elevated</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=adobjects%20OR%20sourcetype=gcobjects%20OR%20sourcetype=adtimeline)%20(ObjectClass=msDS-AuthNPolicySilo%20OR%20ObjectClass=msDS-AuthNPolicy)&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n      <html tokens=\"true\" encoded=\"true\">\r\n        <![CDATA[\r\n          <br/>\r\n          ]]>\r\n      </html>\r\n      <single id=\"ProtectedGroups\">\r\n        <title>Protected Users group, memberOf attribute:</title>\r\n        <search>\r\n          <query>index=$ad_index$  host=$domain_host$  sourcetype=adobjects MemberOf = \"*CN=Protected Users,CN=Users*\" | stats count | eval Protected= if(count &gt; 0,\"Protected users group has members, check also DFL\",\"Protected users group has no members\"), ProtectedValue= if(count &gt; 0,1,0) | stats count by Protected, ProtectedValue | rangemap field=ProtectedValue low=1-2 default=elevated</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"rangeColors\">[\"0x53a051\",\"0x0877a6\",\"0xf8be34\",\"0xf1813f\",\"0xdc4e41\"]</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20%20host=$domain_host$%20%20sourcetype=adobjects%20MemberOf%20=%20%22*CN=Protected%20Users,CN=Users*%22&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>Service Connection Points:</title>\r\n      <table rejects=\"$show_html_scpconf$\">\r\n        <title>SCPs in the configuration partition:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_scpconf\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_scpconf\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ (sourcetype=\"adobjects\" OR sourcetype=\"gcobjects\") DN = \"*,CN=Services,CN=Configuration,*\" ObjectCategory = \"CN=Service-Connection-Point,CN=Schema,CN=Configuration,*\" \r\n|  eval keyword = replace(keywords, \"(&lt;(.|)S&gt;|[\\\\n\\\\r])\" , \"\") |  eval serviceBindingInformations = replace(serviceBindingInformation, \"(&lt;(.|)S&gt;|[\\\\n\\\\r])\" , \"\") \r\n|  rename keyword as keywords, serviceBindingInformations as serviceBindingInformation |  table DN, keywords, serviceBindingInformation</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"dataOverlayMode\">none</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <option name=\"rowNumbers\">false</option>\r\n        <option name=\"wrap\">true</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20(sourcetype=%22adobjects%22%20OR%20sourcetype=%22gcobjects%22)%20DN%20=%20%22*,CN=Services,CN=Configuration,*%22%20ObjectCategory%20=%20%22CN=Service-Connection-Point,CN=Schema,CN=Configuration,*%22&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_scpconf$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">SCPs in the configuration partition: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_scpdom$\">\r\n        <title>SCPs in the domain partition:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_scpdom\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_scpdom\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=\"adobjects\" ObjectClass=\"serviceConnectionPoint\" OR ObjectClass=\"mSSMSManagementPoint\" OR ObjectClass=\"intellimirrorSCP\" OR ObjectClass=\"serviceAdministrationPoint\" NOT DN = \"*,CN=Services,CN=Configuration,*\" |  eval keyword = replace(keywords, \"(&lt;(.|)S&gt;|[\\\\n\\\\r])\" , \"\") |  eval serviceBindingInformations = replace(serviceBindingInformation, \"(&lt;(.|)S&gt;|[\\\\n\\\\r])\" , \"\")  \r\n|  rename keyword as keywords, serviceBindingInformations as serviceBindingInformation | eval keywords_length = len(keywords) \r\n|   fillnull keywords_length value=160 |  sort keywords_length, -serviceClassName \r\n|  table DN, serviceClassName, ObjectClass, keywords, serviceBindingInformation</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"count\">5</option>\r\n        <option name=\"dataOverlayMode\">none</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <option name=\"rowNumbers\">false</option>\r\n        <option name=\"wrap\">true</option>\r\n        <format type=\"color\" field=\"serviceClassName\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"serviceClassName\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"ObjectClass\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"serviceBindingInformation\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=%22adobjects%22%20ObjectClass=%22serviceConnectionPoint%22%20OR%20ObjectClass=%22mSSMSManagementPoint%22%20OR%20ObjectClass=%22intellimirrorSCP%22%20OR%20ObjectClass=%22serviceAdministrationPoint%22%20NOT%20DN%20=%20%22*,CN=Services,CN=Configuration,*%22%20%7C%20%20eval%20keyword%20=%20replace(keywords,%20%22(%3C(.%7C)S%3E%7C%5B%5C%5Cn%5C%5Cr%5D)%22%20,%20%22%22)%20%7C%20%20eval%20serviceBindingInformations%20=%20replace(serviceBindingInformation,%20%22(%3C(.%7C)S%3E%7C%5B%5C%5Cn%5C%5Cr%5D)%22%20,%20%22%22)%20%20%7C%20rename%20keyword%20as%20keywords,%20serviceBindingInformations%20as%20serviceBindingInformation%20%0A%20%20%20%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_scpdom$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">SCPs in the domain partition: No results</p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>Active Directory infrastructure timeline:</title>\r\n      <table>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline ((ObjectClass=DomainDNS OR (ObjectClass=container AND Name=\"AdminSDHolder\")) AND (pszAttributeName = \"whencreated\" OR pszAttributeName = \"ntsecuritydescriptor\" OR pszAttributeName = \"fsmoRoleOwner\")) OR (ObjectClass=crossref AND pszAttributeName=\"msDS-Behavior-Version\") OR (Name = \"Exchange Trusted Subsystem\" AND ObjectCategory=\"CN=Group,CN=Schema,CN=Configuration*\" AND (pszAttributeName = \"whencreated\" OR pszAttributeName = \"msExchGroupMemberCount\")) OR (ObjectClass= \"dMD\" AND (pszAttributeName= \"objectVersion\" OR pszAttributeName= \"fsmoRoleOwner\")) OR (((ObjectClass= \"infrastructureUpdate\" AND Name= \"infrastructure\") OR ObjectClass= \"rIDManager\" OR (ObjectClass= \"crossRefContainer\" AND Name= \"Partitions\")) AND (pszAttributeName = \"fsmoRoleOwner\" OR pszAttributeName = \"optionalfeature\")) OR (ObjectClass= \"trustedDomain\" AND pszAttributeName = \"whencreated\") OR (ObjectClass = \"container\" AND DN = \"CN=ADFS,CN=Microsoft,CN=Program Data*\" AND pszAttributeName = \"whencreated\") OR ( ObjectClass = \"msExchSystemObjectsContainer\" AND Name = \"Microsoft Exchange System Objects\" AND  pszAttributeName = \"ObjectVersion\") OR (ObjectClass = \"attributeSchema\" AND  Name=ms-Mcs-AdmPwd AND pszAttributeName = \"whencreated\") OR ((ObjectClass = \"msDS-AuthNPolicySilo\" OR  ObjectClass = \"msDS-AuthNPolicy\") AND pszAttributeName = \"whencreated\") OR (ObjectClass = \"certificationAuthority\" AND ((DN =\"*,CN=Certification Authorities,CN=Public Key Services,CN=Services,*\"  AND pszAttributeName = \"whencreated\") OR (DN =\"*CN=NTAuthCertificates,CN=Public Key Services,CN=Services,CN=Configuration,*\" AND pszAttributeName = \"cACertificate\"))) OR (ObjectClass = \"attributeSchema\" AND Name = \"ms-Exch-Schema-Version-Pt\" AND pszAttributeName = \"rangeUpper\") OR ((ObjectCategory = \"CN=Service-Connection-Point,CN=Schema,CN=Configuration,*\"  OR ObjectClass=\"mSSMSManagementPoint\" OR ObjectClass=\"intellimirrorSCP\" OR ObjectClass=\"serviceAdministrationPoint\") AND pszAttributeName = \"WhenCreated\") |  makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | table _time, DN, ObjectClass, pszAttributeName, dwVersion, OriginatingDC  | sort -_time</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">40</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"pszAttributeName\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"OriginatingDC\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"ObjectClass\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20((ObjectClass=DomainDNS%20OR%20(ObjectClass=container%20AND%20Name=%22AdminSDHolder%22)%20OR%20ObjectClass=%22crossref%22%20OR%20(Name%20=%20%22Exchange%20Trusted%20Subsystem%22%20AND%20ObjectCategory=%22CN=Group,CN=Schema,CN=Configuration*%22)%20OR%20ObjectClass=%20%22dMD%22%20OR%20(ObjectClass=%20%22infrastructureUpdate%22%20AND%20Name=%20%22infrastructure%22)%20OR%20ObjectClass=%20%22trustedDomain%22%20OR%20(ObjectClass%20=%20%22container%22%20AND%20DN%20=%20%22CN=ADFS,CN=Microsoft,CN=Program%20Data*%22)%20OR%20(%20ObjectClass%20=%20%22msExchSystemObjectsContainer%22%20AND%20Name%20=%20%22Microsoft%20Exchange%20System%20Objects%22)%20OR%20(ObjectClass%20=%20%22attributeSchema%22%20AND%20%20Name=ms-Mcs-AdmPwd)%20OR%20ObjectClass%20=%20%22msDS-AuthNPolicySilo%22%20OR%20%20ObjectClass%20=%20%22msDS-AuthNPolicy%22%20OR%20ObjectClass%20=%20%22certificationAuthority%22%20%20OR%20(ObjectClass%20=%20%22attributeSchema%22%20AND%20Name%20=%20%22ms-Exch-Schema-Version-Pt%22%20)))%20OR%20((ObjectCategory%20=%20%22CN=Service-Connection-Point,CN=Schema,CN=Configuration,*%22%20%20OR%20ObjectClass=%22mSSMSManagementPoint%22%20OR%20ObjectClass=%22intellimirrorSCP%22%20OR%20ObjectClass=%22serviceAdministrationPoint%22)%20AND%20pszAttributeName%20=%20%22WhenCreated%22)%20%7C%20%20%20%20%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%20%0A%7C%20%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n    </panel>\r\n  </row>\r\n</form>"
  },
  {
    "path": "SA-ADTimeline/default/data/ui/views/getting_started.xml",
    "content": "<dashboard version=\"1.1\">\r\n  <label>Getting started</label>\r\n  <row>\r\n    <panel>\r\n      <html>\r\n<style>\r\n.images {\r\n  display: block;\r\n  margin-left: auto;\r\n  margin-right: auto;\r\n  width: 40%;\r\n}\r\n</style>\r\n\r\n<h1>Index</h1>\r\n<ol>\r\n<li><a href=\"#importdata\">Importing ADTimeline data in Splunk</a></li>  \r\n<li><a href=\"#scrtype\">Source types and extracted fields</a>  \r\n<ul>\r\n<li><a href=\"#srcadt\">The adtimeline source type</a></li>   \r\n<li><a href=\"#srcado\">The adobjects source type</a></li>\r\n<li><a href=\"#srcgco\">The gcobjects source type</a></li>\r\n</ul>\r\n</li>\r\n<li><a href=\"#adginfo\">AD General information dashboards</a>\r\n<ul>\r\n<li><a href=\"#adinfra\">Active Directory Infrastructure dashboard</a></li>   \r\n<li><a href=\"#saccounts\">Sensitive accounts dashboard</a></li>\r\n</ul>\r\n</li> \r\n<li><a href=\"#adth\">AD threat hunting dashboards</a>\r\n<ul>\r\n<li><a href=\"#intf\">Investigate timeframe dashboard</a></li>   \r\n<li><a href=\"#tsad\">Track suspicious activity dashboard</a></li>\r\n<li><a href=\"#tsexch\">Track suspicious Exchange activity dashboard</a></li>\r\n</ul>\r\n</li> \r\n<li><a href=\"#etth\">Enhance your traditional event logs threat hunting with ADTimeline</a></li> \r\n</ol>\r\n\r\n\r\n<h1 id=\"importdata\">Importing ADTimeline data in Splunk</h1>\r\n<p>The ADTimeline script generates a timeline based on Active Directory replication metadata for objects considered of interest. Replication metadata gives you the time at which each replicated attribute for a given object was last changed. As a result, the timeline of modifications is partial. In order to be able to process this data with Splunk run the ADTimeline PowerShell script against your Active Directory domain as described on the <a href=\"https://github.com/ANSSI-FR/ADTimeline/blob/master/README.md\">project homepage</a>.</p>\r\n<p>After processing the ADTimeline script you should have two or three files to import in Splunk (<i>%DOMAINFQDN%</i> is the Active Directory fully qualified domain name):\r\n<ul>\r\n<li><i>timeline_%DOMAINFQDN%.csv</i>: The timeline generated with the AD replication metadata of objects retrieved. The corresponding source type is <i>adtimeline</i></li>\r\n<li><i>ADobjects_%DOMAINFQDN%.xml</i>: Objects of interest retrieved via LDAP. The corresponding sourcetype is <i>adobjects</i></li>\r\n<li><i>gcADobjects_%DOMAINFQDN%.xml</i>: If any, objects of interest retrieved via the Global Catalog. The corresponding source type is <i>gcobjects</i></li>\r\n</ul>\r\n</p>\r\n<p>\r\nYou can import the data in an existing index with other source types (e.g. Windows event logs) or create a dedicated one. Navigate to the <i>\"add data\"</i> page and select <i>\"upload files from my computer\"</i>:\r\n</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto1.png\"/>\r\n</div>\r\n\r\n<p>\r\nSelect the file you wish to upload: <i>timeline_%DOMAINFQDN%.csv</i>, <i>ADobjects_%DOMAINFQDN%.xml</i> or <i>gcADobjects_%DOMAINFQDN%.xml</i>:\r\n</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto2.png\"/>\r\n</div>\r\n<p>\r\nSelect the appropriate source type: \r\n<ul>\r\n<li><i>Adtimeline</i> source type for the file <i>timeline_%DOMAINFQDN%.csv</i></li>\r\n<li><i>Adobjects</i> source type for the file <i>ADobjects_%DOMAINFQDN%.xml</i></li>\r\n<li><i>Gcobjects</i> source type for the file <i>gcADobjects_%DOMAINFQDN%.xml</i> if the file exists</li>\r\n</ul>\r\n</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto3.png\"/>\r\n</div>\r\n<p>\r\nThe host field value should be the same for each file and match the Active Directory fully qualified domain name (<i>%DOMAINFQDN%</i>), after select the desired index:\r\n</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto4.png\"/>\r\n</div>\r\n<p>\r\nReview your settings before import and repeat the above steps for each file generated by the ADTimeline script. If you ran the script against many Active Directory domains, repeat also the same steps, just change the host field value accordingly. \r\n</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto5.png\"/>\r\n</div>\r\n\r\n<h1 id=\"scrtype\">Source types and extracted fields</h1>\r\n<u><h2 id=\"srcadt\">The adtimeline source type</h2></u>\r\n<p>\r\nThe <i>adtimeline</i> source type is the data from the <i>timeline_%DOMAINFQDN%.csv</i> file, which is the Active Directory timeline built with replication metadata for objects considered of interest.\r\n</p>\r\n<p>\r\nThe timestamp value is the <i>ftimeLastOriginatingChange</i> value of the replication metadata, which is the time the attribute was last changed, time is UTC.\r\n</p>\r\n<p>\r\nThe extracted fields are:\r\n<ul>\r\n<li><i>Name</i>: LDAP object name.</li>\r\n<li><i>pszAttributeName</i>: The attribute name.</li>\r\n<li><i>dwVersion</i>: Counter incremented every time the attribute is changed.</li>\r\n<li><i>DN</i>: LDAP object DistinguishedName.</li>\r\n<li><i>WhenCreated</i>: LDAP object creation time.</li>\r\n<li><i>ObjectClass</i> and <i>ObjectCategory</i>: LDAP object type (user, computer, group...)</li>\r\n<li><i>SamAccountName</i> and <i>SID</i>: Account Name and security identifier, only applies to users, computers and groups.</li>\r\n<li><i>usnOriginatingChange</i>: USN on the originating server at which the last change to this attribute was made.</li>\r\n<li><i>pszLastOriginatingDsaDN</i>: DC on which the last change was made to this attribute.</li> \r\n<li><i>uuidLastOriginatingDsaInvocationID</i>: ID corresponding to the <i>pszLastOriginatingDsaDN</i>.</li>\r\n<li><i>usnLocalChange</i>: USN on the destination server (the server your LDAP bind is made) at which the last change to this attribute was applied.</li>\r\n<li><i>Member</i>: Only applies to the group <i>ObjectClass</i> and when the attribute name is member. Contains the value of the group member DistinguishedName.</li>\r\n<li><i>ftimeCreated</i>: Only applies to group <i>ObjectClass</i> and when the attribute name is member. Contains the time the member was added in the group.</li>\r\n<li><i>ftimeDeleted</i>: Only applies to group <i>ObjectClass</i> and when the attribute name is member. Contains the time the member was removed from the group.</li>\r\n</ul>\r\n</p>\r\n\r\n<u><h2 id=\"srcado\">The adobjects source type</h2></u>\r\n<p>\r\nThe <i>adobjects</i> source type is the data from the <i>ADobjects_%DOMAINFQDN%.xml</i> file, which is an export of the Active Directory objects considered of interested and retrieved via the LDAP protocol.\r\n</p>\r\n<p>\r\nThe timestamp value is the <i>createTimeStamp</i> attribute value, time zone is specified in the attribute value.\r\n</p>\r\n<p>\r\nThe extracted fields are:\r\n<ul>\r\n<li><i>Name</i>: LDAP object name.</li>\r\n<li><i>DN</i>: LDAP object DistinguishedName.</li>\r\n<li><i>DisplayName</i>: LDAP object displayname.</li>\r\n<li><i>WhenCreated</i>: LDAP object creation time.</li>\r\n<li><i>ObjectClass</i> and <i>ObjectCategory</i>: LDAP object type (user, computer, group...)</li>\r\n<li><i>SamAccountName</i> and <i>SID</i>: Account Name and security identifier, only applies to users, computers and groups.</li>\r\n<li><i>Members</i> and <i>MemberOf</i>: Members of a group <i>ObjectClass</i> can be users, computers or groups and its linked attribute MemberOf which applies to groups, users and computers.</li>\r\n<li><i>Owner</i>, <i>AccessToString</i> and <i>SDDL</i>: Are values computed from the <i>nTSecurityDescriptor</i> attribute</li>\r\n<li><i>adminCount</i>: Privileged accounts protected by the SDProp process.</li>\r\n<li><i>userAccountControl</i>:  Attribute which contains a range of flags which define some important basic properties of a computer or user object.</li>\r\n<li><i>lastLogonTimestamp</i>: This attribute is not updated with all logon types or at every logon but is replicated and gives you an idea of wether a user or computer account has recently logged on to the domain.</li>\r\n<li><i>dNSHostName</i>: DNS hostname attribute of a computer account.</li>\r\n<li><i>SPNs</i>: List of Service Principal Names of a computer or user account.</li>\r\n</ul>\r\n</p>\r\n\r\n<u><h2 id=\"srcgco\">The gcobjects source type</h2></u>\r\n<p>\r\nThe <i>gcobjects</i> source type is the data from the <i>gcADobjects_%DOMAINFQDN%.xml</i> file, which is an export of the Active Directory objects within the forest but outside the current domain and considered of interested, those objects are retrieved via the Global Catalog protocol.\r\n</p>\r\n<p>\r\nThe timestamp value is the <i>WhenCreated</i> attribute value, time zone is UTC.\r\n</p>\r\n<p>\r\nThe extracted fields are:\r\n<ul>\r\n<li><i>Name</i>: LDAP object name.</li>\r\n<li><i>DN</i>: LDAP object DistinguishedName.</li>\r\n<li><i>DisplayName</i>: LDAP object displayname.</li>\r\n<li><i>WhenCreated</i>: LDAP object creation time.</li>\r\n<li><i>ObjectClass</i> and <i>ObjectCategory</i>: LDAP object type (user, computer, group...)</li>\r\n<li><i>SamAccountName</i> and <i>SID</i>: Account Name and security identifier, only applies to users, computers and groups.</li>\r\n<li><i>userAccountControl</i>:  Attribute which contains a range of flags which define some important basic properties of a computer or user object.</li>\r\n<li><i>lastLogonTimestamp</i>: This attribute is not updated with all logon types or at every logon but is replicated and gives you an idea if a user or computer account has recently logged onto the domain.</li>\r\n<li><i>dNSHostName</i>: DNS hostname attribute of a computer account.</li>\r\n<li><i>SPNs</i>: List of Service Principal Names of a computer or user account.</li>\r\n</ul>\r\n</p>\r\n\r\n<h1 id=\"adginfo\">AD General information dashboards</h1>\r\n<u><h2 id=\"adinfra\">Active Directory Infrastructure dashboard</h2></u>\r\n<p>This dashboard analyses Adtimeline data in order to create some panels giving you information on the Windows domain infrastructure. Select the appropriate Index and Active Directory domain you wish to analyze:</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto6.png\"/>\r\n</div>\r\n<p>\r\nThe different panels are:\r\n<ul>\r\n<li><i>General information</i>: Information about the Schema version and functional levels. Depending on the result some AD security features may or may not be available. The Domain Controllers are also listed in this panel</li>\r\n<li><i>Microsoft infrastructure products</i>: Tells you if some important Microsoft Infrastructure components such as Exchange on premises, Active Directory Federation Services or Active Directory Certificate Services are installed. Please consider monitoring events related to those services (<i>MSExchange CmdletLogs</i>, <i>ADFS auditing</i>...) </li>\r\n<li><i>Domain Trusts</i>: List domain trusts by type and direction. Run ADTimeline on all your trusted domains, but most importantly make sure they are audited, monitored and secured as rigorously as the domain you are analyzing.</li>\r\n<li><i>ADDS security features</i>: Tells you if some security features are enabled or not. First feature is the AD Recycle bin which gives the administrator the ability to easily recover deleted objects, it will also change the time after an object is removed from the AD database after deletion. Second feature tells you if the schema extension for the Local Admin Password Solution was performed, if yes sysadmins can enable password randomization for local administrators accounts in order to mitigate lateral movement. Another feature is authentication silos which can help to restrict privileged user account logons in order to mitigate privilege escalation by implementing a tiered administrative model. The last feature is the <i>Protected Users</i> group, with a DFL 2012R2 or more the members of this group receive some additional hardening </li>\r\n<li><i>Service Connection Points</i>: Inventory of serviceConnectionPoint (SCP) object class. SCP make it easy for a service to publish service-specific data in the directory. Clients of the service use the data in an SCP to locate an instance of the service. Infrastructure assets such as RDS Gateway, SCCM, VMWare Vcenter, some Backup solutions publish an SCP in the directory. </li>\r\n<li><i>Active Directory infrastructure timeline</i>: Displays a timeline of the infrastructure changes listed above. This timeline tells you the story of the evolution of your infrastructure.</li>\r\n</ul>\r\n</p>\r\n<u><h2 id=\"saccounts\">Sensitive accounts dashboard</h2></u>\r\n<p>This dashboard provides an inventory of the privileged accounts in the domain and accounts prone to common attack scenarios due to their configuration. Select the appropriate index and the Active Directory domain you wish to analyze:</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto7.png\"/>\r\n</div>\r\n<p>\r\nThe different panels are:\r\n<ul>\r\n<li><i>Admin Accounts</i>: This panel lists the accounts where the <i>Admincount</i> attribute value equals 1. Those accounts have their ACL protected by the <i>SDProp</i> process and it means the account has or had at some point high privileges in Active Directory. The first table lists them and provides some information about the accounts, the second table displays a timeline of modifications for some attributes of these accounts.</li>\r\n<li><i>Accounts sensitive to Kerberoast attacks</i>: <i>Kerberoasting</i> is an attack method that allows an attacker to crack the passwords of service accounts in Active Directory offline. The chart is a ratio of accounts prone to this attack and whether or not they are privileged accounts. The table lists them and provides some information about the accounts. Use least privilege principle for those accounts and consider using <i>Group Managed Service Accounts.</i></li>\r\n<li><i>Accounts sensitive to AS-REP Roast attacks</i>: <i>AS-REP Roast</i> is an attack method that allows an attacker to crack the passwords of accounts in Active Directory offline. The chart is a ratio of accounts prone to this attack and whether or not they are privileged accounts. The table lists them and provides some information about the accounts. Use least privilege principle for those accounts.</li>\r\n<li><i>Sensitive default accounts</i>: Some general information about the default <i>administrator</i>, <i>guest</i> and <i>krbtgt</i> accounts. <i>Administrator</i> can be disabled or renamed as a measure against account lockout. <i>Guest</i> account must be disabled and <i>krbtgt</i> password should be changed on a regular schedule.</li>\r\n<li><i>Accounts trusted for delegation</i>: Kerberos Delegation is a feature that allows an application to reuse the end-user credentials to access resources hosted on a different server. An account trusted for unconstrained delegation is allowed to impersonate almost any user to any service within the network, whereas an account trusted for constrained delegation is allowed to impersonate almost any user for a given service within the network. The chart is a ratio of accounts trusted for constrained/unconstrained delegation. The tables list those accounts, the service name is given for accounts trusted for constrained delegation. A table listing objects with resource based constrained delegation configured is also displayed</li> \r\n</ul>\r\n</p>\r\n\r\n<h1 id=\"adth\">AD threat hunting dashboards</h1>\r\n<u><h2 id=\"intf\">Investigate timeframe dashboard</h2></u>\r\n<p>Use this dashboard to investigate a particular timeframe. Select the appropriate index, the Active Directory domain you wish to analyze and finally the timeframe you wish to investigate:</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto8.png\"/>\r\n</div>\r\n<p>\r\nThe different panels are:\r\n<ul>\r\n<li><i>AD Timeline</i>: A table displaying the timeline for the given timeframe.</li>\r\n<li><i>Global stats</i>: Global statistics on modifications occurring during the given timeframe, including modifications by <i>ObjectClass</i>, by <i>pszAttributeName</i>, by Originating DC, by time (i.e. day of the week or hour of the day) and finally stats on deletions by <i>ObjectClass</i>.</li>\r\n<li><i>Items created and deleted within timeframe</i>: A table displaying the creations and deletions of the same object within the given timeframe. A first chart gives you stats about object lifetimes in hours and a second one figures by <i>ObjectClass</i>.</li>\r\n<li><i>Objects added or removed from groups or ACL modifications within timeframe</i>: This table focuses on the <i>Member</i> and <i>nTSecurityDescriptor</i> attributes, which can help detect an elevation of privilege for a specific account or a backdoor setup by the attacker, the <i>DistinguishedName</i> value of the member and the time the member was added or removed from the group is given in that table. Which makes it more detailed than the above AD Timeline panel. A chart displaying <i>nTSecurityDescriptor</i> modifications by <i>ObjectClass</i> and another displaying the number of times an object was added or removed from a group are given</li>\r\n<li><i>GPOs modifications within timeframe</i>: A GPO can used by an attacker in various ways, for example to inject malicious code in logon/startup scripts, deploy malware at scale with an immediate scheduled task, setup a backdoor by modifying the <i>nTSecurityDescriptor</i>... For each attribute modification this table gives you the current <i>client side extensions</i> of the GPO and where the object is linked (OU, site or domain root).</li>\r\n</ul>\r\n</p>\r\n<u><h2 id=\"tsad\">Track suspicious activity dashboard</h2></u>\r\n<p>This dashboard analyses the Active Directory timeline and highlights some modifications which can be a sign of a suspicious activity, the modifications spotted can also be legitimate and need a triage analysis. Select the appropriate index and the Active Directory domain you wish to analyze:</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto9.png\"/>\r\n</div>\r\n<p>\r\nThe different panels are:\r\n<ul>\r\n<li><i>ACL modifications</i>: This panel does not replace a thorough analysis of the Active Directory permissions with tools such as <i><a href=\"https://github.com/ANSSI-FR/AD-control-paths\">AD Control Paths</a></i>. The panel contains a graph displaying a weekly timeline of ACL modifications per <i>ObjectClass</i> which occured one year back, some tables are focusing on the <i>domain root</i> and <i>AdminSDHolder</i> objects where permissions can be used as backdoor by an attacker. Finally, some statistics by <i>ObjectClass</i> and by least frequent owners are displayed.</li>\r\n<li><i>Accounts</i>: This panel show account modifications which can a be sign of suspicious activity such as users added and removed from groups, some charts provide stats by number of times the account was added or removed, membership time in days, Organizational unit where accounts are located (an account from the \"non_privileged_users\" OU added and removed from a privileged group can be a sign of suspicious activity). There are some graphs, the first graph shows a timeline of accounts lockouts in order to highlight brute force attacks, the second graph shows SID history editions which can be suspicious outside a domain migration period, the next graph analyses all the different attributes modified on an account during a password change (<i>supplementalCredentials</i>, <i>lmPwdHistory</i>, <i>unicodePwd</i>...) and checks they are modified at the same time. A table displays resource based constrained delegation setup on privileged account or domain controller computer objects, which can be a backdoor setup by an attacker. Finally a chart displays domain controller computer objects password change frequency, an attacker could modify the DC registry to disable computer password change and use this password as a backdoor.</li>\r\n<li><i>GPOs</i>: A table of GPOs modifications having an audit client side extension is displayed, an attacker could change the audit settings on the domain to perform malicious actions with stealth. Finally modifications which could result in a GPO processing malfunctioning are displayed, this includes <i>gPCFunctionalityVersion</i>, <i>gPCFileSysPath</i> or <i>versionNumber</i> attribute modification.</li>\r\n<li><i>DCshadow detection</i>: The <i>DCshadow</i> is an attack which allows an attacker to push modifications in Active Directory and bypass traditional alerting by installing a fake DC. It was first presented by Vincent Le Toux and Benjamin Delpy at the BlueHat IL 2018 conference. The first graph will try to detect the installation of the fake DC by analyzing <i>server</i> and <i>nTDSDSA ObjectClass</i>. The two following tables will try to detect replication metadata tampering by analyzing <i>usnOriginatingChange</i> and <i>usnLocalChange</i> values which should increment through the time.</li>\r\n<li><i>Schema and configuration partition suspicious modifications</i>: The first graph displays Active Directory attribute modifications related to the configuration and schema partitions which can lower the security of the domain, used as backdoor by an attacker or hide information to the security team. The second graph is relevant if you have Exchange on premises and track modifications in the configuration partition which can be a sign of mail exfiltration.</li>\r\n</ul>\r\n</p>\r\n<u><h2 id=\"tsexch\">Track suspicious Exchange activity dashboard</h2></u>\r\n<p>This dashboard analyses your Exchange onprem Active Directory objects and highlights some modifications which can be a sign of a suspicious activity, the modifications spotted can also be legitimate and need a triage analysis.</p>\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto11.png\"/>\r\n</div>\r\n<p>\r\nThe different panels are:\r\n<ul>\r\n<li><i>Microsoft Exchange infrastructure:</i>: Exchange version and servers.</li>\r\n<li><i>Possible mail exfiltration</i>: Mail forwarders setup on mailboxes, transport rules, remote domains, maibox export requests, content searches...</li>\r\n<li><i>Persistence</i>: RBAC roles and ACL modifications on Exchange objects.</li>\r\n<li><i>MsExchangeSecurityGroups:</i>: Timeline and group membership of builtin Exchange security groups.</li>\r\n<li><i>Phishing:</i>:Modifications on transport rules related to SCL and disclaimer.</li>\r\n</ul>\r\n</p>\r\n<h1 id=\"etth\">Enhance your traditional event logs threat hunting with ADTimeline</h1>\r\n<p>The <i>adobjects</i> sourcetype is a set of data which can be used to uncover suspicious activity by performing Active Directory educated queries on the Windows event logs. We assume the sourcetype used for event logs is called <i>winevent</i> and its <i>EventData</i> part has the correct field extraction applied (ex EventID 4624 has among other fields <i>TargetUserName</i> and <i>TargetUserSid</i> extracted):\r\n<div class=\"images\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/tuto10.png\"/>\r\n</div>\r\n\r\n</p>\r\n<p>\r\nYou can perfrom similar queries with the <i><a href=\"https://docs.splunk.com/Documentation/MSApp/2.0.0/Reference/Aboutthismanual\">Splunk App for Windows Infrastructure</a></i> and the <i><a href=\"https://docs.splunk.com/Documentation/SA-LdapSearch/3.0.0/User/AbouttheSplunkSupportingAdd-onforActiveDirectory\">Splunk Supporting Add-on for Active Directory</a></i>. Here are some queries using ADTimeline data and Windows event logs which can help with your threat hunt.\r\n</p>\r\n<p>\r\nStatistics on privileged accounts logons: \r\n<pre><code>index=\"*\" sourcetype=\"winevent\" EventID=\"4624\" Channel=\"Security\" \r\n[search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | rename SID as TargetUserSid | fields TargetUserSid] \r\n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName | stats values(TargetFullName) as TargetFullName , values(LogonType) as logonTypes, values(IpAddress) as IpAdresses, values(Computer) as Computers, dc(Computer) as CountComputers, dc(IpAddress) as CountIpAdresses by TargetUserSid</code></pre>\r\n</p>\r\nGet processes running under a privileged account:\r\n<pre><code>index=\"*\" sourcetype=\"winevent\" EventID=\"4688\" Channel=\"Security\" \r\n[search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | rename SamAccountName as TargetUserName | fields TargetUserName] \r\nOR [search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | rename SID as SubjectUserSid | fields SubjectUserSid] \r\n|  stats values(CommandLine) by Computer, TargetUserName,SubjectUserName</code></pre>\r\nGet all privileged accounts PowerShell activity eventlogs:\r\n<pre><code>index=\"*\" sourcetype=\"winevent\" Channel=\"*PowerShell*\"  \r\n[search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | dedup SamAccountName | return 1000 $SamAccountName]</code></pre>\r\nDetect Kerberoasting possible activity:\r\n<pre><code>index=\"*\" sourcetype=\"winevent\" Channel=\"Security\" EventID=\"4769\" \r\n[search index=\"*\" sourcetype=adobjects (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND (SPNs=* AND NOT Name=krbtgt) earliest = 1 latest = now() | rename SID as ServiceSid | fields ServiceSid] \r\n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName  \r\n|  eval time=strftime(_time,\"%Y-%m-%d %H:%M:%S\") \r\n|  stats list(ServiceName) as Services, distinct_count(ServiceName) as nbServices, list(time) as time by IpAddress, TicketEncryptionType \r\n| sort -nbServices</code></pre>\r\nDetect abnormal processes running under Kerberoastable accounts:\r\n<pre><code>index=\"*\" sourcetype=\"winevent\" Channel=\"Security\" EventID=\"4688\" \r\n[search index=\"*\" sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND (SPNs=* AND NOT Name=krbtgt)  earliest = 1 latest = now()   | rename SamAccountName as TargetUserName | fields TargetUserName ] \r\nOR  [search index=\"*\" sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND (SPNs=* AND NOT Name=krbtgt)  earliest = 1 latest = now()   | rename SID as SubjectUserSid | fields SubjectUserSid ] \r\n|  stats values(CommandLine) as cmdlines, values(TargetUserName) as TargetSubjectNames, values(SubjectUserName) as SubjectUserNames by Computer</code></pre>\r\nDetect abnormal Kerberoastable user account logons:\r\n<pre><code>index=\"*\" sourcetype=\"winevent\" Channel=\"Security\" EventID=\"4624\" \r\n[search index=\"*\" sourcetype=adobjects   (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND (SPNs=* AND NOT Name=krbtgt)  earliest = 1 latest = now() | rename SID as TargetUserSid  | fields TargetUserSid] \r\n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName | stats values(TargetFullName) as TargetFullNames, values(IpAddress) as IpAddresses by LogonType, Computer</code></pre>\r\nDetect abnormal AS-REP roastable user account logons:\r\n<pre><code>index=\"*\" sourcetype=\"winevent\" Channel=\"Security\" EventID=\"4624\" \r\n[search index=\"*\" sourcetype=adobjects (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") earliest = 1 latest = now() |  eval eval_asrep_bit = floor(userAccountControl / pow(2, 22)) %2 | search eval_asrep_bit = 1 |  rename SID as TargetUserSid  | fields TargetUserSid]  \r\n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName | stats values(TargetFullName) as TargetFullNames, values(IpAddress) as IpAddresses by LogonType, Computer</code></pre>\r\nPrivileged accounts with flag \"cannot be delegated\" not set authenticating against computer configured for unconstrained delegation:\r\n<pre><code>index=\"*\" sourcetype=\"winevent\" EventID=\"4624\" Channel=\"Security\" \r\n[search index=\"*\" sourcetype=adobjects ObjectClass = \"Computer\" earliest = 1 latest = now() | eval eval_deleg_bit = floor(userAccountControl / pow(2, 19)) %2  | search  eval_deleg_bit = 1 | eval eval_dc_bit = floor(userAccountControl / pow(2, 13)) %2 |  eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 | search eval_dc_bit = 0 AND eval_rodc_bit = 0 |   rename dNSHostName as Computer | fields Computer] \r\n|  search *   [search index=\"*\" sourcetype=adobjects  ((ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND adminCount=1) earliest = 1 latest = now() | eval canbedelagated = round(((userAccountControl / pow(2, 20)) %2), 0) | search canbedelagated = 0 | rename SID as TargetUserSid  | fields TargetUserSid ] \r\n|  strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName \r\n| table  _time, Computer, TargetFullName, IpAddress, LogonType, LogonProcessName</code></pre>\r\nDetect possible printer bug triggering:\r\n<pre><code>index=\"*\" sourcetype=\"winevent\" EventID=\"4624\" Channel=\"Security\" TargetUserName = \"*$\" NOT TargetUserSid=\"S-1-5-18\"\r\n[search index=\"*\" sourcetype=adobjects ObjectClass = \"Computer\"  earliest = 1 latest = now() |  eval eval_deleg_bit = floor(userAccountControl / pow(2, 19)) %2  | search  eval_deleg_bit = 1 | eval eval_dc_bit = floor(userAccountControl / pow(2, 13)) %2 |  eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 | search eval_dc_bit = 0 AND eval_rodc_bit = 0  |  rename dNSHostName as Computer | fields Computer]\r\n| strcat TargetDomainName \"\\\\\" TargetUserName TargetFullName | stats values(LogonType), values(IpAddress), values(LogonProcessName) count by Computer, TargetFullName</code></pre>\r\n\r\n      </html>\r\n    </panel>\r\n  </row>\r\n</dashboard>"
  },
  {
    "path": "SA-ADTimeline/default/data/ui/views/investigate_timeframe.xml",
    "content": "<form version=\"1.1\" theme=\"light\">\r\n  <label>Investigate timeframe</label>\r\n  <fieldset submitButton=\"false\"></fieldset>\r\n  <row>\r\n    <panel>\r\n      <input type=\"dropdown\" token=\"ad_index\" searchWhenChanged=\"true\">\r\n        <label>Choose index to process:</label>\r\n        <search>\r\n          <query>| tstats latest(_time) where index=*  by index</query>\r\n        </search>\r\n        <selectFirstChoice>true</selectFirstChoice>\r\n        <fieldForLabel>index</fieldForLabel>\r\n        <fieldForValue>index</fieldForValue>\r\n      </input>\r\n      <input type=\"dropdown\" token=\"domain_host\" searchWhenChanged=\"true\">\r\n        <label>Choose AD Domain to process:</label>\r\n        <search>\r\n          <query>| tstats latest(_time) where index=$ad_index$ (sourcetype=adobjects OR sourcetype=gcobjects OR sourcetype=adtimeline)  by host</query>\r\n        </search>\r\n        <selectFirstChoice>true</selectFirstChoice>\r\n        <fieldForLabel>host</fieldForLabel>\r\n        <fieldForValue>host</fieldForValue>\r\n      </input>\r\n      <input type=\"time\" token=\"time_token\" searchWhenChanged=\"true\">\r\n        <label>Select timeframe:</label>\r\n        <default>\r\n          <earliest>-7d@h</earliest>\r\n          <latest>now</latest>\r\n        </default>\r\n      </input>\r\n    </panel>\r\n    <panel>\r\n      <html>\r\n      <p style=\"text-align:center;\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/logo.png\"/>\r\n        </p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>AD Timeline:</title>\r\n      <table>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline NOT (pszAttributeName=\"Member\" AND dwVersion = 0) | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | table _time, DN, ObjectClass, pszAttributeName, dwVersion, OriginatingDC | sort -_time</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"pszAttributeName\">\r\n          <colorPalette type=\"map\">{\"whenCreated\":#B6C75A,\"isDeleted\":#AF575A,\"nTSecurityDescriptor\":#F1813F,\"member\":#F1813F}</colorPalette>\r\n        </format>\r\n        <format type=\"color\" field=\"DN\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"OriginatingDC\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </table>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>Global stats (1/2):</title>\r\n      <chart>\r\n        <title>Modifications by ObjectClass</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline NOT ObjectClass=\"System.DirectoryServices.ResultPropertyValueCollection\" | stats count by ObjectClass</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"charting.axisTitleX.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY2.visibility\">visible</option>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.rangeValues\">[0,4,4.1,7]</option>\r\n        <option name=\"charting.chart.sliceCollapsingThreshold\">0</option>\r\n        <option name=\"charting.chart.stackMode\">stacked</option>\r\n        <option name=\"charting.chart.style\">shiny</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"charting.gaugeColors\">[\"0xdc4e41\",\"0xf8be34\",\"0x53a051\"]</option>\r\n        <option name=\"charting.legend.placement\">right</option>\r\n        <option name=\"height\">236</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <option name=\"trellis.enabled\">0</option>\r\n        <option name=\"trellis.size\">medium</option>\r\n        <option name=\"trellis.splitBy\">Name</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20NOT%20ObjectClass=%22System.DirectoryServices.ResultPropertyValueCollection%22%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <chart>\r\n        <title>Modifications by pszAttributeName:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline  | stats count by pszAttributeName</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.sliceCollapsingThreshold\">0</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <chart rejects=\"$show_html_deletebyclass$\">\r\n        <title>Deletions by ObjectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline pszAttributeName=\"isDeleted\"  NOT ObjectClass=\"System.DirectoryServices.ResultPropertyValueCollection\" | stats count by ObjectClass</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_deletebyclass\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_deletebyclass\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.sliceCollapsingThreshold\">0</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20pszAttributeName=%22isDeleted%22%20%20NOT%20ObjectClass=%22System.DirectoryServices.ResultPropertyValueCollection%22%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_deletebyclass$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Deletions by ObjectClass: No results</p>\r\n      </html>\r\n    </panel>\r\n    <panel>\r\n      <title>Global stats (2/2):</title>\r\n      <chart>\r\n        <title>ObjectClass modifications by day of the week:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline NOT ObjectClass=\"System.DirectoryServices.ResultPropertyValueCollection\" | chart count over date_wday by ObjectClass</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"charting.chart\">column</option>\r\n        <option name=\"charting.chart.showDataLabels\">none</option>\r\n        <option name=\"charting.chart.stackMode\">stacked</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20NOT%20ObjectClass=%22System.DirectoryServices.ResultPropertyValueCollection%22%20%7C%20search%20$click.name$%20=%20%22$click.value$%22%20AND%20ObjectClass%20=%20%22$click.name2$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <chart>\r\n        <title>ObjectClass modifications by hour:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline NOT ObjectClass=\"System.DirectoryServices.ResultPropertyValueCollection\" | chart count over date_hour by ObjectClass</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"charting.chart\">column</option>\r\n        <option name=\"charting.chart.stackMode\">stacked</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20NOT%20ObjectClass=%22System.DirectoryServices.ResultPropertyValueCollection%22%20%7C%20search%20$click.name$%20=%20%22$click.value$%22%20AND%20ObjectClass%20=%20%22$click.name2$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <chart>\r\n        <title>Modifications by Originating DC:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | stats count by OriginatingDC</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.sliceCollapsingThreshold\">0</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>Items created and deleted within timeframe:</title>\r\n\t                          <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1136/\" target=\"_blank\">T1136</a>, <a href=\"https://attack.mitre.org/techniques/T1531/\" target=\"_blank\">T1531</a>\r\n        </p>\r\n      </html>\r\n      <table rejects=\"$show_html_createanddel$\">\r\n        <title>Timeline:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_createanddel\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_createanddel\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (pszAttributeName=\"isDeleted\" OR pszAttributeName=\"WhenCreated\")| makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | stats count, values(ObjectClass) as ObjectClass, list(ftimeLastOriginatingChange) as Whencreated_deleted, list(OriginatingDC) as OriginatingDCs by DN | where count &gt; 1 | table DN, ObjectClass, Whencreated_deleted, OriginatingDCs</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <format type=\"color\" field=\"ObjectClass\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"OriginatingDCs\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(pszAttributeName=%22isDeleted%22%20OR%20pszAttributeName=%22WhenCreated%22)%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20stats%20count,%20values(ObjectClass)%20as%20ObjectClass,%20list(ftimeLastOriginatingChange)%20as%20Whencreated_deleted,%20list(OriginatingDC)%20as%20OriginatingDCs%20by%20DN%20%7C%20where%20count%20%3E%201%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_createanddel$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Items created and deleted within timeframe: No results</p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <chart rejects=\"$show_html_lifetimehours$\">\r\n        <title>Object lifetime in hours:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_lifetimehours\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_lifetimehours\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (pszAttributeName=\"isDeleted\" OR pszAttributeName=\"WhenCreated\")| makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | stats count, list(ftimeLastOriginatingChange) as temps, list(OriginatingDC) as OriginatingDCs by DN | where count &gt; 1 | eval deltime = strptime(mvindex(temps,0),\"%Y-%m-%dT%H:%M:%S%Z\") | eval createtime = strptime(mvindex(temps,1),\"%Y-%m-%dT%H:%M:%S%Z\") | eval Lifetime_hours=abs(floor((deltime-createtime)/3600)) | stats count by  Lifetime_hours</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.sliceCollapsingThreshold\">0</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(pszAttributeName%3D%22isDeleted%22%20OR%20pszAttributeName%3D%22WhenCreated%22)%7C%20makemv%20pszLastOriginatingDsaDN%20delim%3D%22%2CCN%3D%22%20%7C%20eval%20OriginatingDC%20%3D%20mvindex(pszLastOriginatingDsaDN%2C%201%2C%201)%20%7C%20stats%20count%2C%20list(ftimeLastOriginatingChange)%20as%20temps%2C%20list(OriginatingDC)%20as%20OriginatingDCs%2C%20values(ObjectClass)%20as%20ObjectClass%20by%20DN%20%7C%20where%20count%20%3E%201%20%7C%20eval%20deltime%20%3D%20strptime(mvindex(temps%2C0)%2C%22%2525Y-%2525m-%2525dT%2525H%3A%2525M%3A%2525S%2525Z%22)%20%7C%20eval%20createtime%20%3D%20strptime(mvindex(temps%2C1)%2C%22%2525Y-%2525m-%2525dT%2525H%3A%2525M%3A%2525S%2525Z%22)%20%7C%20eval%20Lifetime_hours%3Dabs(floor((deltime-createtime)%2F3600))%20%7C%20search%20Lifetime_hours%20%3D%20%22$click.value$%22%20%0A%7C%20table%20DN%2CObjectClass%2Ctemps%2CLifetime_hours%2C%20OriginatingDCs&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_lifetimehours$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Object lifetime in hours: No results</p>\r\n      </html>\r\n    </panel>\r\n    <panel>\r\n      <chart rejects=\"$show_html_createdelbyobjclass$\">\r\n        <title>Items created and deleted within timeframe by ObjectClass:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_createdelbyobjclass\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_createdelbyobjclass\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (pszAttributeName=\"isDeleted\" OR pszAttributeName=\"WhenCreated\") NOT ObjectClass=\"System.DirectoryServices.ResultPropertyValueCollection\" | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | stats count, list(ftimeLastOriginatingChange) as temps, values(ObjectClass) as ObjectClass list(OriginatingDC) as OriginatingDCs by DN | where count &gt; 1 | stats count by ObjectClass</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.sliceCollapsingThreshold\">0</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(pszAttributeName=%22isDeleted%22%20OR%20pszAttributeName=%22WhenCreated%22)%20NOT%20ObjectClass=%22System.DirectoryServices.ResultPropertyValueCollection%22%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20stats%20count,%20list(ftimeLastOriginatingChange)%20as%20temps,%20values(ObjectClass)%20as%20ObjectClass%20list(OriginatingDC)%20as%20OriginatingDCs%20by%20DN%20%7C%20where%20count%20%3E%201%20%7C%20%20search%20$click.name$%20=%20%22$click.value$%22%20%0A%7C%20table%20DN,ObjectClass,temps,%20OriginatingDCs&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_createdelbyobjclass$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Items created and deleted within timeframe by ObjectClass: No results</p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>Objects added or removed from groups or ACL modifications within timeframe:</title>\r\n\t                    <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1098/\" target=\"_blank\">T1098</a>, <a href=\"https://attack.mitre.org/techniques/T1531/\" target=\"_blank\">T1531</a>\r\n        </p>\r\n      </html> \r\n      <table rejects=\"$show_html_memberoracl$\">\r\n        <title>Timeline:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_memberoracl\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_memberoracl\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (pszAttributeName=\"Member\" AND dwVersion != 0) OR (pszAttributeName=\"nTSecurityDescriptor\"  AND dwVersion &gt;= 2) | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | table _time, DN, pszAttributeName, Member, dwVersion, OriginatingDC,ftimeCreated , ftimeDeleted  | sort -_time</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"Member\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"pszAttributeName\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"DN\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"OriginatingDC\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(pszAttributeName=%22Member%22%20AND%20dwVersion%20!=%200)%20OR%20(pszAttributeName=%22nTSecurityDescriptor%22%20%20AND%20dwVersion%20%3E=%202)%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_memberoracl$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Timeline: No results</p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <chart rejects=\"$show_html_aclobjclassstat$\">\r\n        <title>ACL modifications by ObjectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline  (pszAttributeName=\"nTSecurityDescriptor\"  AND dwVersion &gt;= 2) NOT ObjectClass=\"System.DirectoryServices.ResultPropertyValueCollection\" | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | stats count by ObjectClass</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_aclobjclassstat\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_aclobjclassstat\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.sliceCollapsingThreshold\">0</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20%20(pszAttributeName=%22nTSecurityDescriptor%22%20%20AND%20dwVersion%20%3E=%202)%20NOT%20ObjectClass=%22System.DirectoryServices.ResultPropertyValueCollection%22%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_aclobjclassstat$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">ACL modifications by ObjectClass: No results</p>\r\n      </html>\r\n    </panel>\r\n    <panel>\r\n      <chart rejects=\"$show_html_memberbyversion$\">\r\n        <title>Group membership modification by dwVersion:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_memberbyversion\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_memberbyversion\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (pszAttributeName=\"Member\" AND dwVersion != 0)  | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | stats count by dwVersion</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.sliceCollapsingThreshold\">0</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(pszAttributeName=%22Member%22%20AND%20dwVersion%20!=%200)%20%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_memberbyversion$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Group membership modification by dwVersion: No results</p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>GPOs modifications within timeframe:</title>\r\n\t                    <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1484/\" target=\"_blank\">T1484</a>\r\n        </p>\r\n      </html> \r\n      <table rejects=\"$show_html_gpomod$\">\r\n        <title>Timeline:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline ObjectClass=groupPolicyContainer | join DN [search index=$ad_index$ host=$domain_host$ sourcetype=\"adobjects\" ObjectClass=groupPolicyContainer earliest = 1 latest = now()  | rex field=_raw \"gPCMachineExtensionNames\\\"&gt;(?&lt;gPCMachineExtensionNames&gt;.+?)&lt;/S&gt;\" \r\n| rex field=_raw \"gPCUserExtensionNames\\\"&gt;(?&lt;gPCUserExtensionNames&gt;.+?)&lt;/S&gt;\" \r\n| rex field=gPCMachineExtensionNames \"\\[(?&lt;MachineCSEs&gt;\\{.+?\\})\\]?\" max_match=0 | rex field=gPCUserExtensionNames \"\\[(?&lt;UserCSEs&gt;\\{.+?\\})\\]?\" max_match=0 \r\n| eval AllCSEs=coalesce(MachineCSEs,UserCSEs) \r\n|  dedup AllCSEs \r\n|  lookup CSE_lookup GUID AS AllCSEs OUTPUTNEW CSE as ClientSideExtensions | fields DN, DisplayName, ClientSideExtensions] \r\n|  join Name \r\n    [search index=$ad_index$ host=$domain_host$ sourcetype=\"adobjects\" (ObjectClass = \"domainDNS\" OR ObjectClass = \"site\" OR ObjectClass = \"organizationalUnit\") earliest = 1 latest = now() | rex field=_raw \"gPLink\\\"&gt;(?&lt;gPLink&gt;.+?)&lt;/S&gt;\" \r\n |  search  gPLink = \"*\" \r\n|  rex field=gPLink \"(CN|cn)\\=(?&lt;Name&gt;\\{.+?\\}),\" max_match=0 \r\n| mvexpand Name\r\n|  stats values(DN) as gPLinks by Name \r\n|  fields Name, gPLinks ] | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) |  table _time, DisplayName, pszAttributeName, dwVersion, ClientSideExtensions, gPLinks, Name, OriginatingDC \r\n|  sort -_time</query>\r\n          <earliest>$time_token.earliest$</earliest>\r\n          <latest>$time_token.latest$</latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_gpomod\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_gpomod\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"pszAttributeName\">\r\n          <colorPalette type=\"map\">{\"isDeleted\":#AF575A,\"whenCreated\":#B6C75A}</colorPalette>\r\n        </format>\r\n        <format type=\"color\" field=\"DisplayName\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"OriginatingDC\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20ObjectClass=groupPolicyContainer%20%7C%20join%20DN%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=%22adobjects%22%20ObjectClass=groupPolicyContainer%20earliest%20=%201%20latest%20=%20now()%20%20%7C%20rex%20field=_raw%20%22gPCMachineExtensionNames%5C%22%3E(%3F%3CgPCMachineExtensionNames%3E.%2B%3F)%3C/S%3E%22%20%0A%7C%20rex%20field=_raw%20%22gPCUserExtensionNames%5C%22%3E(%3F%3CgPCUserExtensionNames%3E.%2B%3F)%3C/S%3E%22%20%0A%7C%20rex%20field=gPCMachineExtensionNames%20%22%5C%5B(%3F%3CMachineCSEs%3E%5C%7B.%2B%3F%5C%7D)%5C%5D%3F%22%20max_match=0%20%7C%20rex%20field=gPCUserExtensionNames%20%22%5C%5B(%3F%3CUserCSEs%3E%5C%7B.%2B%3F%5C%7D)%5C%5D%3F%22%20max_match=0%20%0A%7C%20eval%20AllCSEs=coalesce(MachineCSEs,UserCSEs)%20%0A%7C%20%20dedup%20AllCSEs%20%0A%7C%20%20lookup%20CSE_lookup%20GUID%20AS%20AllCSEs%20OUTPUTNEW%20CSE%20as%20ClientSideExtensions%20%7C%20fields%20DN,%20DisplayName,%20ClientSideExtensions%5D%20%0A%7C%20%20join%20Name%20%0A%20%20%20%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=%22adobjects%22%20(ObjectClass%20=%20%22domainDNS%22%20OR%20ObjectClass%20=%20%22site%22%20OR%20ObjectClass%20=%20%22organizationalUnit%22)%20earliest%20=%201%20latest%20=%20now()%20%7C%20rex%20field=_raw%20%22gPLink%5C%22%3E(%3F%3CgPLink%3E.%2B%3F)%3C/S%3E%22%20%0A%20%7C%20%20search%20%20gPLink%20=%20%22*%22%20%0A%7C%20%20rex%20field=gPLink%20%22(CN%7Ccn)%5C=(%3F%3CName%3E%5C%7B.%2B%3F%5C%7D),%22%20max_match=0%20%0A%7C%20mvexpand%20Name%0A%7C%20%20stats%20values(DN)%20as%20gPLinks%20by%20Name%20%0A%7C%20%20fields%20Name,%20gPLinks%20%5D%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=$time_token.earliest$&amp;latest=$time_token.latest$</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_gpomod$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Timeline: No results</p>\r\n      </html>\r\n\t             <html>\r\n            <p style=\"vertical-align:bottom;text-align:right;font-style:italic;font-size:x-small\">\r\n          © 2020 The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation.\r\n        </p>\r\n        </html> \r\n    </panel>\r\n  </row>\r\n</form>"
  },
  {
    "path": "SA-ADTimeline/default/data/ui/views/sensitive_accounts.xml",
    "content": "<form version=\"1.1\">\r\n  <label>Sensitive accounts</label>\r\n  <fieldset submitButton=\"false\"></fieldset>\r\n  <row>\r\n    <panel>\r\n      <input type=\"dropdown\" token=\"ad_index\" searchWhenChanged=\"true\">\r\n        <label>Choose index to process:</label>\r\n        <search>\r\n          <query>| tstats latest(_time) where index=*  by index</query>\r\n        </search>\r\n        <selectFirstChoice>true</selectFirstChoice>\r\n        <fieldForLabel>index</fieldForLabel>\r\n        <fieldForValue>index</fieldForValue>\r\n      </input>\r\n      <input type=\"dropdown\" token=\"domain_host\" searchWhenChanged=\"true\">\r\n        <label>Choose AD Domain to process:</label>\r\n        <search>\r\n          <query>| tstats latest(_time) where index=$ad_index$ (sourcetype=adobjects OR sourcetype=gcobjects OR sourcetype=adtimeline)  by host</query>\r\n        </search>\r\n        <selectFirstChoice>true</selectFirstChoice>\r\n        <fieldForLabel>host</fieldForLabel>\r\n        <fieldForValue>host</fieldForValue>\r\n      </input>\r\n    </panel>\r\n    <panel>\r\n      <html>\r\n      <p style=\"text-align:center;\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/logo.png\"/>\r\n        </p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>Admin accounts:</title>\r\n      <table>\r\n        <title>Inventory, adminCount attribute:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\" OR ObjectClass = \"Computer\") AND (adminCount=1 NOT Name=\"krbtgt\") |  eval Status = if((userAccountControl%4)&gt;=2,\"disabled\",\"enabled\")  | eval SmartCard = if(round (((userAccountControl / pow(2, 18)) %2), 0) == 1,\"required\",\"not required\")  | eval be_delegated = if(round(((userAccountControl / pow(2, 20)) %2), 0) == 1,\"cannot\",\"can\") | eval lastlogon_timestamp = strftime(lastLogonTimestamp/10000000 - 11644473600, \"%Y-%m-%dT%H:%M:%S\") | table DN, Status, be_delegated, SmartCard,  lastlogon_timestamp, whenCreated | sort -lastlogon_timestamp</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"be_delegated\">\r\n          <colorPalette type=\"map\">{\"can\":#D98491,\"cannot\":#A1D379}</colorPalette>\r\n        </format>\r\n        <format type=\"color\" field=\"SmartCard\">\r\n          <colorPalette type=\"map\">{\"not required\":#D98491,\"required\":#A1D379}</colorPalette>\r\n        </format>\r\n        <format type=\"color\" field=\"Status\">\r\n          <colorPalette type=\"map\">{\"enabled\":#A1D379,\"disabled\":#F8BE34}</colorPalette>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22%20OR%20ObjectClass%20=%20%22Computer%22)%20AND%20(adminCount=1%20NOT%20Name=%22krbtgt%22)%20%7C%20%20eval%20Status%20=%20if((userAccountControl%254)%3E=2,%22disabled%22,%22enabled%22)%20%20%7C%20eval%20SmartCard%20=%20if(round%20(((userAccountControl%20/%20pow(2,%2018))%20%252),%200)%20==%201,%22required%22,%22not%20required%22)%20%20%7C%20eval%20be_delegated%20=%20if(round(((userAccountControl%20/%20pow(2,%2020))%20%252),%200)%20==%201,%22cannot%22,%22can%22)%20%7C%20eval%20lastlogon_timestamp%20=%20strftime(lastLogonTimestamp/10000000%20-%2011644473600,%20%22%25Y-%25m-%25dT%25H:%25M:%25S%22)%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <table>\r\n        <title>Timeline, adminCount attribute:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline  (pszAttributeName = adminCount OR pszAttributeName = isDeleted OR (pszAttributeName = member AND dwVersion != 0) OR pszAttributeName = userAccountControl OR pszAttributeName = whenCreated) [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\" OR ObjectClass = \"group\") AND adminCount=1 | table DN] | table _time, DN, pszAttributeName, Member, dwVersion, ftimeCreated, ftimeDeleted | sort -_time</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"pszAttributeName\">\r\n          <colorPalette type=\"map\">{\"whenCreated\":#53A051,\"isDeleted\":#DC4E41,\"member\":#006D9C,\"adminCount\":#EC9960,\"userAccountControl\":#62B3B2}</colorPalette>\r\n        </format>\r\n        <format type=\"color\" field=\"DN\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"Member\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22%20OR%20ObjectClass%20=%20%22group%22)%20AND%20adminCount=1%20%7C%20table%20DN%5D%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>Accounts sensitive to Kerberoast attacks:</title>\r\n      <chart rejects=\"$show_html_kerberoast1$\">\r\n        <title>Ratio of kerberoastable accounts being privileged in the domain, SPN and adminCount attributes:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects   (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\")  AND  ( SPNs = \"*\" AND NOT Name=krbtgt) | eval SPN = replace(SPNs, \"(&lt;(.|)S&gt;|[\\\\n\\r])\" , \"\")  | fillnull value=\"notset\" adminCount | stats count as \"Admincount ratio for users with SPN\" by adminCount</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_kerberoast1\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_kerberoast1\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.axisTitleX.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY2.visibility\">visible</option>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.rangeValues\">[0,4,4.1,7]</option>\r\n        <option name=\"charting.chart.style\">shiny</option>\r\n        <option name=\"charting.fieldColors\">{\"1\":0xFF0000}</option>\r\n        <option name=\"charting.gaugeColors\">[\"0xdc4e41\",\"0xf8be34\",\"0x53a051\"]</option>\r\n        <option name=\"charting.legend.placement\">right</option>\r\n        <option name=\"height\">236</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <option name=\"trellis.enabled\">0</option>\r\n        <option name=\"trellis.size\">medium</option>\r\n        <option name=\"trellis.splitBy\">Name</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22)%20%20AND%20%20(%20SPNs%20=%20%22*%22%20AND%20NOT%20Name=krbtgt)%20%7C%20eval%20SPN%20=%20replace(SPNs,%20%22(%3C(.%7C)S%3E%7C%5B%5C%5Cn%5C%5Cr%5D)%22%20,%20%22%22)%20%20%7C%20fillnull%20value=%22notset%22%20adminCount%20%7C%20%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_kerberoast1$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Ratio of kerberoastable accounts being privileged in the domain, SPN and adminCount attributes: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_kerberoast2$\">\r\n        <title>Kerberoastable accounts inventory:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_kerberoast2\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_kerberoast2\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\") AND (SPNs = \"*\" AND NOT Name= \"krbtgt\") | eval SPN = replace(SPNs, \"(&lt;(.|)S&gt;|[\\\\n\\r])\" , \"\") | fillnull value=\"notset\" adminCount | eval Status = if((userAccountControl%4)&gt;=2,\"disabled\",\"enabled\")  | eval lastlogon_timestamp = strftime(lastLogonTimestamp/10000000 - 11644473600, \"%Y-%m-%dT%H:%M:%S\") | table DN, SPN, Status, adminCount, SID, lastlogon_timestamp, whenCreated | sort -lastlogon_timestamp</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"adminCount\">\r\n          <colorPalette type=\"map\">{\"0\":#A1D379,\"1\":#D98491,\"notset\":#A1D379}</colorPalette>\r\n        </format>\r\n        <format type=\"color\" field=\"Status\">\r\n          <colorPalette type=\"map\">{\"enabled\":#A1D379,\"disabled\":#F8BE34}</colorPalette>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22)%20AND%20(SPNs%20=%20%22*%22%20AND%20NOT%20Name=%20%22krbtgt%22)%20%7C%20eval%20SPN%20=%20replace(SPNs,%20%22(%3C(.%7C)S%3E%7C%5B%5C%5Cn%5C%5Cr%5D)%22%20,%20%22%22)%20%7C%20fillnull%20value=%22notset%22%20adminCount%20%7C%20eval%20Status%20=%20if((userAccountControl%254)%3E=2,%22disabled%22,%22enabled%22)%20%20%7C%20eval%20lastlogon_timestamp%20=%20strftime(lastLogonTimestamp/10000000%20-%2011644473600,%20%22%25Y-%25m-%25dT%25H:%25M:%25S%22)%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_kerberoast2$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Kerberoastable accounts inventory: No results</p>\r\n      </html>\r\n    </panel>\r\n    <panel>\r\n      <title>Sensitive default accounts:</title>\r\n      <html>\r\n        <style>         \r\n\t\t      #Krbtgt .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n          #LocalAdmin .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n          #LocalAdmin2 .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n          #guest .single-value .single-result {\r\n          font-size:25px !important;\r\n          }\r\n        </style>\r\n     </html>\r\n      <single id=\"LocalAdmin\">\r\n        <title>Administrator account (RID 500):</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects  ObjectClass = \"DomainDNS\" | strcat SID \"-500\" SID | table SID]  | eval Status = if((userAccountControl%4)&gt;=2,\"Administrator account is disabled\",\"Administrator account is enabled\") | table Status</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20%20(sourcetype=adobjects%20%20OR%20sourcetype=adtimeline)%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20ObjectClass%20=%20%22DomainDNS%22%20%7C%20strcat%20SID%20%22-500%22%20SID%20%7C%20table%20SID%5D&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n      <html tokens=\"true\" encoded=\"true\">\r\n        <![CDATA[\r\n          <br/>\r\n          ]]>\r\n      </html>\r\n      <single id=\"LocalAdmin2\">\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline pszAttributeName=SamAccountName [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects  ObjectClass = \"DomainDNS\" | strcat SID \"-500\" SID | table SID] | eval checkRenameAdmin =case(dwVersion &gt;= 2, \"Administrator account was renamed\", 1=1 , \"Administrator account was not renamed\") | table checkRenameAdmin</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">none</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n      </single>\r\n      <table>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (pszAttributeName=pwdLastSet OR pszAttributeName=SamAccountName OR pszAttributeName=userAccountControl OR pszAttributeName=lockoutTime OR pszAttributeName=LastlogonTimestamp)  [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects  ObjectClass = \"DomainDNS\" | strcat SID \"-500\" SID | table SID] |  makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | table _time, Name, pszAttributeName, dwVersion, OriginatingDC | sort -_time</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"OriginatingDC\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(pszAttributeName=pwdLastSet%20OR%20pszAttributeName=SamAccountName%20OR%20pszAttributeName=userAccountControl%20OR%20pszAttributeName=lockoutTime%20OR%20pszAttributeName=LastlogonTimestamp)%20%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20ObjectClass%20=%20%22DomainDNS%22%20%7C%20strcat%20SID%20%22-500%22%20SID%20%7C%20table%20SID%5D%20%7C%20%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <single id=\"guest\">\r\n        <title>Guest account (RID 501):</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects  ObjectClass = \"DomainDNS\" | strcat SID \"-501\" SID | table SID]  | eval UACmodulo4 = (userAccountControl%4) | eval Status = if( UACmodulo4 &gt;=2,\"Guest account is disabled\",\"Guest account is enabled\") | stats by Status, UACmodulo4 |  rangemap field=UACmodulo4 severe=0-1 default=low</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20%20(sourcetype=adobjects%20OR%20sourcetype=adtimeline)%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20ObjectClass%20=%20%22DomainDNS%22%20%7C%20strcat%20SID%20%22-501%22%20SID%20%7C%20table%20SID%5D&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n      <table>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (pszAttributeName=pwdLastSet OR pszAttributeName=SamAccountName OR pszAttributeName=userAccountControl OR pszAttributeName=LastlogonTimestamp)  [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects  ObjectClass = \"DomainDNS\" | strcat SID \"-501\" SID | table SID] |  makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | table _time, Name, pszAttributeName, dwVersion, OriginatingDC | sort -_time</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"OriginatingDC\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(pszAttributeName=pwdLastSet%20OR%20pszAttributeName=SamAccountName%20OR%20pszAttributeName=userAccountControl%20OR%20pszAttributeName=LastlogonTimestamp)%20%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20ObjectClass%20=%20%22DomainDNS%22%20%7C%20strcat%20SID%20%22-501%22%20SID%20%7C%20table%20SID%5D%20%7C%20%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html tokens=\"true\" encoded=\"true\">\r\n        <![CDATA[\r\n          <br/>\r\n          ]]>\r\n      </html>\r\n      <single id=\"Krbtgt\">\r\n        <title>Krbtgt account:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$  sourcetype=adtimeline pszAttributeName=pwdLastSet [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects  ObjectClass = \"DomainDNS\" | strcat SID \"-502\" SID | table SID] | stats min(_time) as mintime,  values(dwVersion) as version | eval diff = (now() - mintime) / 86400 | eval freq = diff / version  | eval frequency=case(freq &gt;= 730, \"Krbtgt password is changed in average less than every two years\", freq &gt;= 365 , \"Krbtgt password is changed in average less than every one year\", 1=1, \"Krbtgt password is changed in average at least every year\") | stats count by frequency, freq | rangemap field=freq low=1-364 elevated=365-729 default=severe</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n        </search>\r\n        <option name=\"drilldown\">all</option>\r\n        <option name=\"height\">50</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20%20(sourcetype=adobjects%20OR%20sourcetype=adtimeline)%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20ObjectClass%20=%20%22DomainDNS%22%20%7C%20strcat%20SID%20%22-502%22%20SID%20%7C%20table%20SID%5D&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </single>\r\n      <table>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline pszAttributeName=pwdLastSet  [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects  ObjectClass = \"DomainDNS\" | strcat SID \"-502\" SID | table SID] |  makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) |  table _time, Name, pszAttributeName, dwVersion, OriginatingDC</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"map\">{\"1\":#DC4E41,\"2\":#DC4E41,\"3\":#DC4E41}</colorPalette>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20pszAttributeName=pwdLastSet%20%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20ObjectClass%20=%20%22DomainDNS%22%20%7C%20strcat%20SID%20%22-502%22%20SID%20%7C%20table%20SID%5D%20%7C%20%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>Accounts sensitive to AS-REP Roast attacks:</title>\r\n      <chart rejects=\"$show_html_asreproast1$\">\r\n        <title>Ratio of AS-REProastable accounts being privileged in the domain, userAccountControl and adminCount attributes:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\")  |  eval eval_asrep_bit = floor(userAccountControl / pow(2, 22)) %2 | search eval_asrep_bit = 1  | fillnull value=\"notset\" adminCount  | stats count as \"Admincount ratio for users with DONT_REQ_PREAUTH flag\" by adminCount</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_asreproast1\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_asreproast1\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.axisTitleX.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY2.visibility\">visible</option>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.rangeValues\">[0,4,4.1,7]</option>\r\n        <option name=\"charting.chart.style\">shiny</option>\r\n        <option name=\"charting.fieldColors\">{\"1\":0xFF0000}</option>\r\n        <option name=\"charting.gaugeColors\">[\"0xdc4e41\",\"0xf8be34\",\"0x53a051\"]</option>\r\n        <option name=\"charting.legend.placement\">right</option>\r\n        <option name=\"height\">236</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <option name=\"trellis.enabled\">0</option>\r\n        <option name=\"trellis.size\">medium</option>\r\n        <option name=\"trellis.splitBy\">Name</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22)%20%20%7C%20%20eval%20eval_asrep_bit%20=%20floor(userAccountControl%20/%20pow(2,%2022))%20%252%20%7C%20search%20eval_asrep_bit%20=%201%20%20%7C%20fillnull%20value=%22notset%22%20adminCount%20%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_asreproast1$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Ratio of AS-REProastable accounts being privileged in the domain, userAccountControl and adminCount attributes: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_asreproast2$\">\r\n        <title>AS-REP Roast accounts inventory:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_asreproast2\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_asreproast2\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\")   |  eval eval_asrep_bit = floor(userAccountControl / pow(2, 22)) %2 | search eval_asrep_bit = 1 | fillnull value=\"notset\" adminCount  | eval status = if((userAccountControl%4)&gt;=2,\"disabled\",\"enabled\")  | eval lastlogon_timestamp = strftime(lastLogonTimestamp/10000000 - 11644473600, \"%Y-%m-%dT%H:%M:%S\") | table DN, status, adminCount, lastlogon_timestamp, whenCreated | sort -lastlogon_timestamp</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <format type=\"color\" field=\"adminCount\">\r\n          <colorPalette type=\"map\">{\"0\":#A1D379,\"1\":#D98491,\"notset\":#A1D379}</colorPalette>\r\n        </format>\r\n        <format type=\"color\" field=\"status\">\r\n          <colorPalette type=\"map\">{\"enabled\":#A1D379,\"disabled\":#F8BE34}</colorPalette>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22)%20%20%20%7C%20%20eval%20eval_asrep_bit%20=%20floor(userAccountControl%20/%20pow(2,%2022))%20%252%20%7C%20search%20eval_asrep_bit%20=%201%20%20%7C%20fillnull%20value=%22notset%22%20adminCount%20%20%7C%20eval%20status%20=%20if((userAccountControl%254)%3E=2,%22disabled%22,%22enabled%22)%20%20%7C%20eval%20lastlogon_timestamp%20=%20strftime(lastLogonTimestamp/10000000%20-%2011644473600,%20%22%25Y-%25m-%25dT%25H:%25M:%25S%22)%20%0A%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_asreproast2$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">AS-REP Roast accounts inventory: No results</p>\r\n      </html>\r\n    </panel>\r\n    <panel>\r\n      <title>Kerberos delegation:</title>\r\n      <chart rejects=\"$show_html_deleg1$\">\r\n        <title>Ratio of accounts trusted for unconstrained/constrained delagation, userAccountControl attribute:</title>\r\n        <search>\r\n          <query>index=$ad_index$  host=$domain_host$  sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\" OR ObjectClass = \"Computer\")   |  eval eval_deleg_bit = floor(userAccountControl / pow(2, 19)) %2 | eval eval_cdeleg_bit = floor(userAccountControl / pow(2, 24)) %2  | search (eval_cdeleg_bit=1 OR eval_deleg_bit = 1 ) |  eval eval_dc_bit = floor(userAccountControl / pow(2, 13)) %2 | eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 | search eval_dc_bit = 0 AND eval_rodc_bit = 0 | eval DelegType =case(eval_cdeleg_bit == 1, \"Account trusted for constrainded delegation\", eval_deleg_bit == 1  , \"Account trusted for unconstrainded delegation\") |  stats count as \"Delegation type ratio\" by DelegType</query>\r\n          <earliest>$earliest$</earliest>\r\n          <latest>$latest$</latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_deleg1\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_deleg1\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.axisTitleX.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY2.visibility\">visible</option>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.chart.rangeValues\">[0,4,4.1,7]</option>\r\n        <option name=\"charting.chart.style\">shiny</option>\r\n        <option name=\"charting.fieldColors\">{\"Account trusted for unconstrainded delegation\":0xFF0000}</option>\r\n        <option name=\"charting.gaugeColors\">[\"0xdc4e41\",\"0xf8be34\",\"0x53a051\"]</option>\r\n        <option name=\"charting.legend.placement\">right</option>\r\n        <option name=\"height\">236</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <option name=\"trellis.enabled\">0</option>\r\n        <option name=\"trellis.size\">medium</option>\r\n        <option name=\"trellis.splitBy\">Name</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20%20host=$domain_host$%20%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22%20OR%20ObjectClass%20=%20%22Computer%22)%20%20%20%7C%20%20eval%20eval_deleg_bit%20=%20floor(userAccountControl%20/%20pow(2,%2019))%20%252%20%7C%20eval%20eval_cdeleg_bit%20=%20floor(userAccountControl%20/%20pow(2,%2024))%20%252%20%20%7C%20search%20(eval_cdeleg_bit=1%20OR%20eval_deleg_bit%20=%201%20)%20%7C%20%20eval%20eval_dc_bit%20=%20floor(userAccountControl%20/%20pow(2,%2013))%20%252%20%7C%20eval%20eval_rodc_bit%20=%20floor(userAccountControl%20/%20pow(2,%2026))%20%252%20%7C%20search%20eval_dc_bit%20=%200%20AND%20eval_rodc_bit%20=%200%20%7C%20eval%20DelegType%20=case(eval_cdeleg_bit%20==%201,%20%22Account%20trusted%20for%20constrainded%20delegation%22,%20eval_deleg_bit%20==%201%20%20,%20%22Account%20trusted%20for%20unconstrainded%20delegation%22)%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=$earliest$&amp;latest=$latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_deleg1$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Ratio of accounts trusted for unconstrained/constrained delagation, userAccountControl attribute: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_deleg2$\">\r\n        <title>Accounts trusted for unconstrained delegation inventory, userAccountControl attribute:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\" OR ObjectClass = \"Computer\")   |  eval eval_deleg_bit = floor(userAccountControl / pow(2, 19)) %2  | search  eval_deleg_bit = 1 | eval eval_dc_bit = floor(userAccountControl / pow(2, 13)) %2 |  eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 | search eval_dc_bit = 0 AND eval_rodc_bit = 0  | eval Status = if((userAccountControl%4)&gt;=2,\"disabled\",\"enabled\") | eval Status = if((userAccountControl%4)&gt;=2,\"disabled\",\"enabled\")  |   eval lastlogon_timestamp = strftime(lastLogonTimestamp/10000000 - 11644473600, \"%Y-%m-%dT%H:%M:%S\") | table DN, ObjectClass, Status, lastlogon_timestamp, whenCreated</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_deleg2\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_deleg2\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"Status\">\r\n          <colorPalette type=\"map\">{\"enabled\":#A1D379,\"disabled\":#F8BE34}</colorPalette>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22%20OR%20ObjectClass%20=%20%22Computer%22)%20%20%20%7C%20%20eval%20eval_deleg_bit%20=%20floor(userAccountControl%20/%20pow(2,%2019))%20%252%20%20%7C%20search%20%20eval_deleg_bit%20=%201%20%7C%20eval%20eval_dc_bit%20=%20floor(userAccountControl%20/%20pow(2,%2013))%20%252%20%7C%20%20eval%20eval_rodc_bit%20=%20floor(userAccountControl%20/%20pow(2,%2026))%20%252%20%7C%20search%20eval_dc_bit%20=%200%20AND%20eval_rodc_bit%20=%200%20%20%7C%20eval%20Status%20=%20if((userAccountControl%254)%3E=2,%22disabled%22,%22enabled%22)%20%7C%20eval%20Status%20=%20if((userAccountControl%254)%3E=2,%22disabled%22,%22enabled%22)%20%20%7C%20%20%20eval%20lastlogon_timestamp%20=%20strftime(lastLogonTimestamp/10000000%20-%2011644473600,%20%22%25Y-%25m-%25dT%25H:%25M:%25S%22)%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_deleg2$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Accounts trusted for unconstrained delegation inventory, userAccountControl attribute: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_deleg3$\">\r\n        <title>Accounts trusted for constrained delegation inventory, userAccountControl attribute:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$  sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\" OR ObjectClass = \"Computer\") | eval eval_cdeleg_bit = floor(userAccountControl / pow(2, 24)) %2 | search eval_cdeleg_bit=1 | eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 \r\n| search eval_rodc_bit = 0 \r\n|  rex \"(?ms)msDS-AllowedToDelegateTo.{1,100}&lt;LST&gt;(?&lt;AllowedToDelegateTotmp&gt;.*?)&lt;/LST&gt;\" | eval AllowedToDelegateTo= replace(AllowedToDelegateTotmp, \"(&lt;(.|)S&gt;|[\\\\n\\r])\" , \"\") | eval Status = if((userAccountControl%4)&gt;=2,\"disabled\",\"enabled\")  |   eval lastlogon_timestamp = strftime(lastLogonTimestamp/10000000 - 11644473600, \"%Y-%m-%dT%H:%M:%S\") | table  DN, ObjectClass, AllowedToDelegateTo, Status, lastlogon_timestamp, whenCreated</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_deleg3\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_deleg3\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"Status\">\r\n          <colorPalette type=\"map\">{\"enabled\":#A1D379,\"disabled\":#F8BE34}</colorPalette>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22%20OR%20ObjectClass%20=%20%22Computer%22)%20%7C%20eval%20eval_cdeleg_bit%20=%20floor(userAccountControl%20/%20pow(2,%2024))%20%252%20%7C%20search%20eval_cdeleg_bit=1%20%7C%20eval%20eval_rodc_bit%20=%20floor(userAccountControl%20/%20pow(2,%2026))%20%252%20%0A%7C%20search%20eval_rodc_bit%20=%200%20%0A%7C%20%20rex%20%22(%3Fms)msDS-AllowedToDelegateTo.%7B1,100%7D%3CLST%3E(%3F%3CAllowedToDelegateTotmp%3E.%2A%3F)%3C/LST%3E%22%20%7C%20eval%20AllowedToDelegateTo=%20replace(AllowedToDelegateTotmp,%20%22(%3C(.%7C)S%3E%7C%5B%5C%5Cn%5C%5Cr%5D)%22%20,%20%22%22)%20%7C%20eval%20Status%20=%20if((userAccountControl%254)%3E=2,%22disabled%22,%22enabled%22)%20%20%7C%20%20%20eval%20lastlogon_timestamp%20=%20strftime(lastLogonTimestamp/10000000%20-%2011644473600,%20%22%25Y-%25m-%25dT%25H:%25M:%25S%22)%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_deleg3$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Accounts trusted for constrained delegation inventory, userAccountControl attribute: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_deleg4$\">\r\n        <title>Resource based constrained delegation inventory, msDS-AllowedToActOnBehalfOfOtherIdentity attribute:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_deleg4\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_deleg4\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=\"adobjects\" (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\" OR ObjectClass = \"Computer\")  |  rex \"(?ms)msDS-AllowedToActOnBehalfOfOtherIdentity.{1,1500}&lt;MS&gt;(?&lt;AllowedToActOnBehalftmp&gt;.*?)&lt;/MS&gt;\" \r\n|  rex field=AllowedToActOnBehalftmp \"AccessToString\\\"&gt;(?&lt;AccountAllowedToActOnBehalf&gt;.+)&lt;/S&gt;\"  \r\n|  search AccountAllowedToActOnBehalf = \"*\" \r\n|  eval Status = if((userAccountControl%4)&gt;=2,\"disabled\",\"enabled\") | fillnull value=\"notset\" adminCount | table DN, AccountAllowedToActOnBehalf, Status, adminCount</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <format type=\"color\" field=\"adminCount\">\r\n          <colorPalette type=\"map\">{\"1\":#D98491,\"notset\":#A1D379,\"0\":#A1D379}</colorPalette>\r\n        </format>\r\n        <format type=\"color\" field=\"Status\">\r\n          <colorPalette type=\"map\">{\"enabled\":#A1D379,\"disabled\":#F8BE34}</colorPalette>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=%22adobjects%22%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22%20OR%20ObjectClass%20=%20%22Computer%22)%20%20%7C%20%20rex%20%22(%3Fms)msDS-AllowedToActOnBehalfOfOtherIdentity.%7B1,1500%7D%3CMS%3E(%3F%3CAllowedToActOnBehalftmp%3E.%2A%3F)%3C/MS%3E%22%20%0A%7C%20%20rex%20field=AllowedToActOnBehalftmp%20%22AccessToString%5C%22%3E(%3F%3CAccountAllowedToActOnBehalf%3E.%2B)%3C/S%3E%22%20%20%0A%7C%20%20search%20AccountAllowedToActOnBehalf%20=%20%22*%22%20%0A%7C%20%20eval%20Status%20=%20if((userAccountControl%254)%3E=2,%22disabled%22,%22enabled%22)%20%7C%20fillnull%20value=%22notset%22%20adminCount%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_deleg4$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Resource based constrained delegation inventory, msDS-AllowedToActOnBehalfOfOtherIdentity attribute: No results</p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n</form>\r\n"
  },
  {
    "path": "SA-ADTimeline/default/data/ui/views/suspicious_activity.xml",
    "content": "<form version=\"1.1\">\r\n  <label>Track suspicious activity</label>\r\n  <search>\r\n    <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline  | where usnLocalChange = usnOriginatingChange | stats earliest(_time) as firstevent | fields firstevent</query>\r\n    <earliest>0</earliest>\r\n    <latest></latest>\r\n    <done>\r\n      <set token=\"Dcinstall\">$result.firstevent$</set>\r\n    </done>\r\n  </search>\r\n  <fieldset submitButton=\"false\"></fieldset>\r\n  <row>\r\n    <panel>\r\n      <input type=\"dropdown\" token=\"ad_index\" searchWhenChanged=\"true\">\r\n        <label>Choose index to process:</label>\r\n        <search>\r\n          <query>| tstats latest(_time) where index=*  by index</query>\r\n        </search>\r\n        <selectFirstChoice>true</selectFirstChoice>\r\n        <fieldForLabel>index</fieldForLabel>\r\n        <fieldForValue>index</fieldForValue>\r\n      </input>\r\n      <input type=\"dropdown\" token=\"domain_host\" searchWhenChanged=\"true\">\r\n        <label>Choose AD Domain to process:</label>\r\n        <search>\r\n          <query>| tstats latest(_time) where index=$ad_index$ (sourcetype=adobjects OR sourcetype=gcobjects OR sourcetype=adtimeline)  by host</query>\r\n        </search>\r\n        <selectFirstChoice>true</selectFirstChoice>\r\n        <fieldForLabel>host</fieldForLabel>\r\n        <fieldForValue>host</fieldForValue>\r\n      </input>\r\n    </panel>\r\n    <panel>\r\n      <html>\r\n      <p style=\"text-align:center;\">\r\n          <img src=\"/static/app/SA-ADTimeline/images/logo.png\"/>\r\n        </p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>ACL modifications</title>\r\n                  <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1098/\" target=\"_blank\">T1098</a>\r\n        </p>\r\n      </html> \r\n      <chart>\r\n        <title>ACL modifications performed one year back, stats by ObjectClass per week:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline pszAttributeName=\"nTSecurityDescriptor\"  dwVersion &gt;= 2 | eval ObjectClass=if(ObjectClass==\"System.DirectoryServices.ResultPropertyValueCollection\",\"GCobject_ObjectClassNA\",ObjectClass) | timechart span=1w count by ObjectClass limit=0</query>\r\n          <earliest>-1y</earliest>\r\n          <latest>now</latest>\r\n        </search>\r\n        <option name=\"charting.axisTitleX.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY.visibility\">visible</option>\r\n        <option name=\"charting.axisTitleY2.visibility\">visible</option>\r\n        <option name=\"charting.chart\">column</option>\r\n        <option name=\"charting.chart.rangeValues\">[0,4,4.1,7]</option>\r\n        <option name=\"charting.chart.stackMode\">stacked</option>\r\n        <option name=\"charting.chart.style\">shiny</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"charting.gaugeColors\">[\"0xdc4e41\",\"0xf8be34\",\"0x53a051\"]</option>\r\n        <option name=\"charting.legend.placement\">right</option>\r\n        <option name=\"height\">236</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <option name=\"trellis.enabled\">0</option>\r\n        <option name=\"trellis.size\">medium</option>\r\n        <option name=\"trellis.splitBy\">Name</option>\r\n        <drilldown>\r\n          <eval token=\"drilldown.earliest\">if(isnull($row._time$),1,$row._time$)</eval>\r\n          <eval token=\"drilldown.latest\">if(isnull($row._time$),now(),$row._time$ + $row._span$)</eval>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20pszAttributeName=%22nTSecurityDescriptor%22%20%20dwVersion%20%3E=%202%20%20%7C%20eval%20ObjectClass=if(ObjectClass==%22System.DirectoryServices.ResultPropertyValueCollection%22,%22GCobject_ObjectClassNA%22,ObjectClass)%0A%7C%20%20search%20%20ObjectClass%20=%20%22$click.name2$%22&amp;earliest=$drilldown.earliest$&amp;latest=$drilldown.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <table>\r\n        <title>ACL modifications on AdminSDHolder and DomainDNS object:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline pszAttributeName=\"nTSecurityDescriptor\"  (ObjectClass = \"DomainDNS\" OR (Name= \"AdminSDHolder\" AND ObjectClass=\"container\")) |  makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | table _time, Name, pszAttributeName, dwVersion, OriginatingDC</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20((sourcetype=adtimeline%20AND%20pszAttributeName=%22nTSecurityDescriptor%22)%20OR%20sourcetype=adobjects)%20%20AND%20(ObjectClass%20=%20%22DomainDNS%22%20OR%20(Name=%20%22AdminSDHolder%22%20AND%20ObjectClass=%22container%22))%20%7C%20%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <table rejects=\"$show_html_acedomaindns$\">\r\n        <title>User or computers accounts having an ACE on DomainDNS object:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_acedomaindns\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_acedomaindns\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$  sourcetype=adtimeline (ObjectCategory = \"CN=Person,CN=Schema*\"  OR ObjectCategory = \"CN=Computer,CN=Schema*\") [search index=$ad_index$ host=$domain_host$  sourcetype=adobjects  ObjectClass = \"DomainDNS\" | rex field=SDDL \"(?&lt;Sid&gt;S-1-5-21-\\d{8,10}-\\d{8,10}-\\d{8,10}-\\d{4,10})\" max_match=0  |  stats count by Sid | return 1000 $Sid] | stats count by DN, SID | table DN, SID</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20%20((sourcetype=adtimeline%20OR%20sourcetype=adobjects%20OR%20sourcetype=gcobjects)%20AND%20(ObjectCategory%20=%20%22CN=Person,CN=Schema*%22%20%20OR%20ObjectCategory%20=%20%22CN=Computer,CN=Schema*%22))%20OR%20(sourcetype=adobjects%20%20AND%20ObjectClass%20=%20%22DomainDNS%22)%20%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20%20sourcetype=adobjects%20%20ObjectClass%20=%20%22DomainDNS%22%20%7C%20rex%20field=SDDL%20%22(%3F%3CSid%3ES-1-5-21-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D-%5Cd%7B4,10%7D)%22%20max_match=0%20%20%7C%20%20stats%20count%20by%20Sid%20%7C%20return%201000%20$Sid%5D%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22%20OR%20ObjectClass%20=%20%22DomainDNS%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_acedomaindns$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">User or computers accounts having an ACE on DomainDNS object: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_aceadminsd$\">\r\n        <title>User or computers accounts having an ACE on AdminSDHolder object:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_aceadminsd\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_aceadminsd\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$  sourcetype=adtimeline (ObjectCategory = \"CN=Person,CN=Schema*\"  OR ObjectCategory = \"CN=Computer,CN=Schema*\") [search index=$ad_index$ host=$domain_host$  sourcetype=adobjects  (ObjectClass = \"container\" AND Name= \"AdminSDHolder\") |  rex field=SDDL \"(?&lt;Sid&gt;S-1-5-21-\\d{8,10}-\\d{8,10}-\\d{8,10}-\\d{4,10})\" max_match=0  |  stats count by Sid | return 1000 $Sid] | stats count by DN,SID | table DN,SID</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20%20((sourcetype=adtimeline%20OR%20sourcetype=adobjects%20OR%20sourcetype=gcobjects)%20AND%20%20(ObjectCategory%20=%20%22CN=Person,CN=Schema*%22%20%20OR%20ObjectCategory%20=%20%22CN=Computer,CN=Schema*%22))%20OR%20(ObjectClass%20=%20%22container%22%20AND%20Name=%20%22AdminSDHolder%22)%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22container%22%20AND%20Name=%20%22AdminSDHolder%22)%20%7C%20%20rex%20field=SDDL%20%22(%3F%3CSid%3ES-1-5-21-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D-%5Cd%7B4,10%7D)%22%20max_match=0%20%20%7C%20%20stats%20count%20by%20Sid%20%7C%20return%201000%20$Sid%5D%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22%20OR%20ObjectClass%20=%20%22container%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_aceadminsd$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">User or computers accounts having an ACE on AdminSDHolder object: No results</p>\r\n      </html>\r\n      <chart>\r\n        <title>ACL modifications by ObjectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline pszAttributeName=\"nTSecurityDescriptor\"  dwVersion &gt;= 2  | eval ObjectClass=if(ObjectClass==\"System.DirectoryServices.ResultPropertyValueCollection\",\"GCobject_ObjectClassNA\",ObjectClass) | stats count by ObjectClass</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20pszAttributeName=%22nTSecurityDescriptor%22%20%20dwVersion%20%3E=%202%20%7C%20eval%20ObjectClass=if(ObjectClass==%22System.DirectoryServices.ResultPropertyValueCollection%22,%22GCobject_ObjectClassNA%22,ObjectClass)%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </chart>\r\n      <table>\r\n        <title>Least frequent object owners:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$  sourcetype=adobjects  | stats values(DN) count by Owner | where count &lt; 3 | sort count | table Owner, values(DN), count | rename values(DN) AS \"Objects owned\"</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20%20sourcetype=adobjects%20%20%7C%20stats%20values(DN)%20count%20by%20Owner%20%7C%20where%20count%20%3C%203%20%7C%20sort%20count%20%7C%20table%20Owner,%20values(DN),%20count%20%7C%20rename%20values(DN)%20AS%20%22Objects%20owned%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n    </panel>\r\n    <panel>\r\n      <title>User and computer accounts</title>\r\n                  <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1110/\" target=\"_blank\">T1110</a>, <a href=\"https://attack.mitre.org/techniques/T1531/\" target=\"_blank\">T1531</a>\r\n        </p>\r\n      </html> \r\n      <chart rejects=\"$show_html_lockout$\">\r\n        <title>Account lockouts</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline pszAttributeName=\"lockoutTime\" | timechart  span=1week count by pszAttributeName limit=0</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_lockout\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_lockout\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.chart\">column</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <eval token=\"drilldown.earliest\">if(isnull($row._time$),1,$row._time$)</eval>\r\n          <eval token=\"drilldown.latest\">if(isnull($row._time$),now(),$row._time$ + $row._span$)</eval>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20pszAttributeName=%22lockoutTime%22&amp;earliest=$drilldown.earliest$&amp;latest=$drilldown.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <table rejects=\"$show_html_lockout2$\">\r\n        <title>Top 5 account lockouts</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$show_html_lockout2$ == 0\">\r\n              <set token=\"show_html_lockout2\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_lockout2\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$  host=$domain_host$  sourcetype=adtimeline pszAttributeName=\"lockoutTime\" | sort -dwVersion | head 5 | table _time, DN, dwVersion</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#DC4E41\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20%20host=$domain_host$%20%20sourcetype=adtimeline%20pszAttributeName=%22lockoutTime%22%20%7C%20sort%20-dwVersion%20%7C%20head%205%20%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_lockout2$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Top 5 account lockouts: No results</p>\r\n      </html>\r\n      <html depends=\"$show_html_lockout$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Account lockouts: No results</p>\r\n      </html>\r\n                  <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1098/\" target=\"_blank\">T1098</a>, <a href=\"https://attack.mitre.org/techniques/T1531/\" target=\"_blank\">T1531</a>\r\n        </p>\r\n      </html> \r\n      <chart rejects=\"$show_html_addedremoveddgrp$\">\r\n        <title>Accounts added and removed from groups, frequency:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_addedremoveddgrp\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_addedremoveddgrp\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline ObjectClass=\"group\" pszAttributeName=\"Member\"  dwVersion != 0 | eval Test= if(dwVersion%2==0,\"Even\",\"odd\") | search Test=\"Even\" | stats count by dwVersion</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20ObjectClass=%22group%22%20pszAttributeName=%22Member%22%20dwVersion%20!=%200%20%20%7C%20eval%20Test=%20if(dwVersion%252==0,%22Even%22,%22odd%22)%20%7C%20search%20Test=%22Even%22%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_addedremoveddgrp$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Accounts added and removed from groups, frequency: No results</p>\r\n      </html>\r\n      <chart rejects=\"$show_html_addedremoveddgrptime$\">\r\n        <title>Accounts added and removed from groups, membership time in days:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_addedremoveddgrptime\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_addedremoveddgrptime\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline ObjectClass=\"group\" pszAttributeName=\"Member\" dwVersion != 0  | eval Test= if(dwVersion%2==0,\"Even\",\"odd\") | search Test=\"Even\" | eval ftimeCreatedT = strptime(ftimeCreated, \"%Y-%m-%dT%H:%M:%SZ\") | eval ftimeDeletedT = if(ftimeDeleted==\"1601-01-01T00:00:00Z\", strptime(ftimeLastOriginatingChange,\"%Y-%m-%dT%H:%M:%SZ\"), strptime(ftimeDeleted, \"%Y-%m-%dT%H:%M:%SZ\")) | fillnull value=0 ftimeDeletedT | eval TimeDiff = floor((ftimeDeletedT - ftimeCreatedT) / 86400) | stats count by TimeDiff</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20ObjectClass=%22group%22%20pszAttributeName=%22Member%22%20dwVersion%20!=%200%20%20%7C%20eval%20Test=%20if(dwVersion%252==0,%22Even%22,%22odd%22)%20%7C%20search%20Test=%22Even%22%20%7C%20eval%20ftimeCreatedT%20=%20strptime(ftimeCreated,%20%22%25Y-%25m-%25dT%25H:%25M:%25SZ%22)%20%7C%20eval%20ftimeDeletedT%20%3D%20if(ftimeDeleted%3D%3D%221601-01-01T00%3A00%3A00Z%22%2C%20strptime(ftimeLastOriginatingChange%2C%22%25Y-%25m-%25dT%25H%3A%25M%3A%25SZ%22)%2C%20strptime(ftimeDeleted%2C%20%22%25Y-%25m-%25dT%25H%3A%25M%3A%25SZ%22))%20%7C%20fillnull%20value=0%20ftimeDeletedT%20%7C%20eval%20TimeDiff%20=%20floor((ftimeDeletedT%20-%20ftimeCreatedT)%20/%2086400)%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_addedremoveddgrptime$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Accounts added and removed from groups, membership time in days: No results</p>\r\n      </html>\r\n      <chart rejects=\"$show_html_addedremoveddgrpou$\">\r\n        <title>Accounts added and removed from groups, member account OU:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_addedremoveddgrpou\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_addedremoveddgrpou\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline ObjectClass=\"group\" pszAttributeName=\"Member\" dwVersion != 0  | eval Test= if(dwVersion%2==0,\"Even\",\"odd\") | search Test=\"Even\" | makemv Member delim=\",\" | eval Member_OU = mvjoin(mvindex(Member, 1, mvcount(Member)),\",\") | stats count by Member_OU</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20ObjectClass=%22group%22%20pszAttributeName=%22Member%22%20dwVersion%20!=%200%20%7C%20eval%20Test=%20if(dwVersion%252==0,%22Even%22,%22odd%22)%20%7C%20search%20Test=%22Even%22%20%7C%20makemv%20Member%20delim=%22,%22%20%7C%20eval%20Member_OU%20=%20mvjoin(mvindex(Member,%201,%20mvcount(Member)),%22,%22)%20%7C%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_addedremoveddgrpou$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Accounts added and removed from groups, member account OU: No results</p>\r\n      </html>\r\n                  <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1178/\" target=\"_blank\">T1178</a>\r\n        </p>\r\n      </html> \r\n      <chart rejects=\"$show_html_sid1$\">\r\n        <title>SIDHistory and primaryGroupID editions</title>\r\n        <search>\r\n          <query>index=$ad_index$  host=$domain_host$ sourcetype=adtimeline pszAttributeName=\"SIDHistory\"  OR (pszAttributeName=\"primaryGroupID\" AND dwVersion &gt; 1 AND NOT DN = \"*,OU=Domain Controllers,*\") AND NOT (Name = \"*DEL\\:*\" AND ObjectClass = \"Computer\") | timechart  span=1week count by pszAttributeName limit=0</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_sid1\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_sid1\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.chart\">column</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <eval token=\"drilldown.earliest\">if(isnull($row._time$),1,$row._time$)</eval>\r\n          <eval token=\"drilldown.latest\">if(isnull($row._time$),now(),$row._time$ + $row._span$)</eval>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20%20host=$domain_host$%20sourcetype=adtimeline%20pszAttributeName=%22SIDHistory%22%20%20OR%20(pszAttributeName=%22primaryGroupID%22%20AND%20dwVersion%20%3E%201%20AND%20NOT%20DN%20=%20%22*,OU=Domain%20Controllers,*%22)%20AND%20NOT%20(Name%20=%20%22*DEL%5C:*%22%20AND%20ObjectClass%20=%20%22Computer%22)%20%7C%20%20search%20%20pszAttributeName%20=%20%22$click.name2$%22&amp;earliest=$drilldown.earliest$&amp;latest=$drilldown.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_sid1$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">SIDHistory and primaryGroupID editions: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_sid2$\">\r\n        <title>Suspicious SIDHistory values</title>\r\n        <search>\r\n          <query>index=$ad_index$  host=$domain_host$  (sourcetype=adobjects AND (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\" OR ObjectClass = \"Computer\" OR ObjectClass = \"Group\")) OR sourcetype=gcobjects\r\n|  rex  \"(?ms)sIDHistory.{1,100}&lt;LST&gt;(?&lt;SIDHistories&gt;.*?)&lt;/LST&gt;\" | rex field=SIDHistories \"(?&lt;Sid2&gt;(S-1-5-21-\\d{8,10}-\\d{8,10}-\\d{8,10}-\\d{3,10}|S-1-5-32-\\d{3}))\" max_match=0 \r\n| rex field=_raw \"sidhistory\\\"&gt;(?&lt;SIDHistories&gt;.+?)&lt;/S&gt;\"\r\n| rex field=SIDHistories \"(?&lt;Sid1&gt;(S-1-5-21-\\d{8,10}-\\d{8,10}-\\d{8,10}-\\d{3,10}|S-1-5-32-\\d{3}))\" max_match=0 | eval sidHs = mvappend(Sid1,Sid2)\r\n|  dedup sidHs |  mvexpand sidHs \r\n|  dedup sidHs\r\n|  rex field=SID \"(?&lt;DomainSid&gt;S-1-5-21-\\d{8,10}-\\d{8,10}-\\d{8,10})\" \r\n|  eval SuspiciousSIDHistory = if(like(sidHs,DomainSid.\"%\") OR like(sidHs,\"%-500\")  OR like(sidHs,\"%-518\") OR like(sidHs,\"%-498\") OR like(sidHs,\"%-519\") OR like(sidHs,\"%-512\") OR like(sidHs,\"%-516\") OR sidHs=\"S-1-5-32-550\" OR sidHs=\"S-1-5-32-549\" OR sidHs=\"S-1-5-32-551\" OR sidHs=\"S-1-5-32-544\"  OR sidHs=\"S-1-5-32-548\" ,sidHs,null)\r\n| search SuspiciousSIDHistory = \"*\" \r\n|  join SID \r\n    [search index=$ad_index$  host=$domain_host$  sourcetype=adtimeline pszAttributeName=sIDHistory \r\n    | \r\n    rename _time as LastSIDHistoryEditiontimeepoch |  fields LastSIDHistoryEditiontimeepoch, SID, dwVersion] \r\n|  eval LastSIDHistoryEditiontime = strftime(LastSIDHistoryEditiontimeepoch,\"%Y-%m-%d %H:%M:%S\") \r\n|  table LastSIDHistoryEditiontime, DN, SuspiciousSIDHistory, SID, dwVersion \r\n    |  sort -LastSIDHistoryEditiontime</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_sid2\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_sid2\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"SuspiciousSIDHistory\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"DN\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20%20host=$domain_host$%20%20(sourcetype=adobjects%20AND%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22%20OR%20ObjectClass%20=%20%22Computer%22%20OR%20ObjectClass%20=%20%22Group%22))%20OR%20sourcetype=gcobjects%20%0A%7C%20%20rex%20%20%22(%3Fms)sIDHistory.%7B1,100%7D%3CLST%3E(%3F%3CSIDHistories%3E.%2A%3F)%3C/LST%3E%22%20%7C%20rex%20field=SIDHistories%20%22(%3F%3CSid2%3E(S-1-5-21-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D-%5Cd%7B3,10%7D%7CS-1-5-32-%5Cd%7B3%7D))%22%20max_match=0%20%0A%7C%20rex%20field=_raw%20%22sidhistory%5C%22%3E(%3F%3CSIDHistories%3E.%2B%3F)%3C/S%3E%22%0A%7C%20rex%20field=SIDHistories%20%22(%3F%3CSid1%3E(S-1-5-21-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D-%5Cd%7B3,10%7D%7CS-1-5-32-%5Cd%7B3%7D))%22%20max_match=0%20%7C%20eval%20sidHs%20=%20mvappend(Sid1,Sid2)%0A%7C%20%20dedup%20sidHs%20%7C%20%20mvexpand%20sidHs%20%0A%7C%20%20dedup%20sidHs%0A%7C%20%20rex%20field=SID%20%22(%3F%3CDomainSid%3ES-1-5-21-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D-%5Cd%7B8,10%7D)%22%20%0A%7C%20%20eval%20SuspiciousSIDHistory%20=%20if(like(sidHs,DomainSid.%22%25%22)%20OR%20like(sidHs,%22%25-500%22)%20%20OR%20like(sidHs,%22%25-518%22)%20OR%20like(sidHs,%22%25-498%22)%20OR%20like(sidHs,%22%25-519%22)%20OR%20like(sidHs,%22%25-512%22)%20OR%20like(sidHs,%22%25-516%22)%20OR%20sidHs=%22S-1-5-32-550%22%20OR%20sidHs=%22S-1-5-32-549%22%20OR%20sidHs=%22S-1-5-32-551%22%20OR%20sidHs=%22S-1-5-32-544%22%20%20OR%20sidHs=%22S-1-5-32-548%22%20,sidHs,null)%0A%7C%20search%20SuspiciousSIDHistory%20=%20%22*%22%20%7C%20%20join%20SID%20%0A%20%20%20%20%5Bsearch%20index=$ad_index$%20%20host=$domain_host$%20%20sourcetype=adtimeline%20pszAttributeName=sIDHistory%20%0A%20%20%20%20%7C%20%0A%20%20%20%20rename%20_time%20as%20LastSIDHistoryEditiontimeepoch%20%7C%20%20fields%20LastSIDHistoryEditiontimeepoch,%20SID,%20dwVersion%5D%20%0A%7C%20%20eval%20LastSIDHistoryEditiontime%20=%20strftime(LastSIDHistoryEditiontimeepoch,%22%25Y-%25m-%25d%20%25H:%25M:%25S%22)%20%0A%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_sid2$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Suspicious SIDHistory values: No results</p>\r\n      </html>\r\n                  <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1098/\" target=\"_blank\">T1098</a>\r\n        </p>\r\n      </html>\r\n      <table rejects=\"$show_html_pwdbd$\">\r\n        <title>Possible password backdoor: Compare dBCSPwd LmPwdHistory ntPwdHistory unicodePwd and supplementalCredentials attributes modification date</title>\r\n        <search>\r\n          <query>index=$ad_index$  host=$domain_host$ sourcetype=adtimeline (ObjectClass=\"user\" OR ObjectClass=\"inetOrgPerson\" OR ObjectClass=\"Computer\") (pszAttributeName=\"dBCSPwd\"  OR pszAttributeName=\"lmPwdHistory\" OR pszAttributeName=\"ntPwdHistory\" OR pszAttributeName=\"unicodePwd\" OR pszAttributeName=\"supplementalCredentials\") AND NOT (Name = \"*DEL\\:*\")  | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) |  bucket _time span=5m | stats list(pszAttributeName) count by _time, DN, OriginatingDC | search count &lt; 4 \r\n| rename list(pszAttributeName) AS \"Attributes modified\"</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_pwdbd\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_pwdbd\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"count\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#FFFFFF\" minColor=\"#DC4E41\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20%20host=$domain_host$%20sourcetype=adtimeline%20(ObjectClass=%22user%22%20OR%20ObjectClass=%22inetOrgPerson%22%20OR%20ObjectClass=%22Computer%22)%20(pszAttributeName=%22dBCSPwd%22%20%20OR%20pszAttributeName=%22lmPwdHistory%22%20OR%20pszAttributeName=%22ntPwdHistory%22%20OR%20pszAttributeName=%22unicodePwd%22%20OR%20pszAttributeName=%22supplementalCredentials%22)%20AND%20NOT%20(Name%20=%20%22*DEL%5C:*%22)%20%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20%20bucket%20_time%20span=5m%20%7C%20stats%20list(pszAttributeName)%20count%20by%20_time,%20DN,%20OriginatingDC%20%0A%7C%20rename%20list(pszAttributeName)%20AS%20%22Attributes%20modified%22%20%0A%7C%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_pwdbd$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Possible password backdoor: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_rbcd$\">\r\n        <title>Resource based constrained delegation on privileged account or Domain Controller: msDS-AllowedToActOnBehalfOfOtherIdentity attribute</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_rbcd\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_rbcd\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline  pszAttributeName = \"msDS-AllowedToActOnBehalfOfOtherIdentity\"  [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects  (ObjectClass = \"user\" OR ObjectClass = \"inetOrgPerson\" OR ObjectClass = \"Computer\")  |  eval eval_dc_bit = floor(userAccountControl / pow(2, 13)) %2 |  eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 | search ((eval_dc_bit = 1 OR eval_rodc_bit = 1)  AND DN = \"*,OU=Domain Controllers,*\") OR  adminCount=1 | fields DN] | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) |  sort -_time  |  table _time, DN, pszAttributeName, OriginatingDC</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20%20(pszAttributeName%20=%20%22msDS-AllowedToActOnBehalfOfOtherIdentity%22%20OR%20pszAttributeName%20=%20%22pwdLastSet%22)%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20(ObjectClass%20=%20%22user%22%20OR%20ObjectClass%20=%20%22inetOrgPerson%22%20OR%20ObjectClass%20=%20%22Computer%22)%20%20%7C%20%20eval%20eval_dc_bit%20=%20floor(userAccountControl%20/%20pow(2,%2013))%20%252%20%7C%20%20eval%20eval_rodc_bit%20=%20floor(userAccountControl%20/%20pow(2,%2026))%20%252%20%7C%20search%20((eval_dc_bit%20=%201%20OR%20eval_rodc_bit%20=%201)%20%20AND%20DN%20=%20%22*,OU=Domain%20Controllers,*%22)%20OR%20%20adminCount=1%20%7C%20fields%20DN%5D%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_rbcd$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Resource based constrained delegation on privileged account or Domain Controller: No results</p>\r\n      </html>\r\n                  <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1112/\" target=\"_blank\">T1112</a>\r\n        </p>\r\n      </html> \r\n      <chart rejects=\"$show_html_pwddcc$\">\r\n        <title>Domain Controller password change frequency:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects  ObjectClass= \"Computer\" DN = \"*,OU=Domain Controllers,*\" |  eval eval_dc_bit = floor(userAccountControl / pow(2, 13)) %2 |  eval eval_rodc_bit = floor(userAccountControl / pow(2, 26)) %2 | search eval_dc_bit = 1 OR eval_rodc_bit = 1 | rex field=_raw \"pwdLastSet\\\"&gt;(?&lt;pwdLastSet&gt;.+?)&lt;/I64&gt;\"\r\n|  eval TimeDiff = round((lastLogonTimestamp - pwdLastSet) / (10000000 * 60 * 60 * 24)) \r\n|  eval DiffPwdLastSet= if(TimeDiff &lt; 32,\"OK less than 31 days\",\"NOK more than 31 days\") \r\n|  stats count by DiffPwdLastSet</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_pwddcc\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_pwddcc\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.chart\">pie</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"charting.fieldColors\">{\"NOK more than 31 days\":0xFF0000}</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adobjects%20%20ObjectClass=%20%22Computer%22%20DN%20=%20%22*,OU=Domain%20Controllers,*%22%20%7C%20%20eval%20eval_dc_bit%20=%20floor(userAccountControl%20/%20pow(2,%2013))%20%252%20%7C%20%20eval%20eval_rodc_bit%20=%20floor(userAccountControl%20/%20pow(2,%2026))%20%252%20%7C%20search%20eval_dc_bit%20=%201%20OR%20eval_rodc_bit%20=%201%20%7C%20rex%20field=_raw%20%22pwdLastSet%5C%22%3E(%3F%3CpwdLastSet%3E.%2B%3F)%3C/I64%3E%22%0A%7C%20%20eval%20TimeDiff%20=%20round((lastLogonTimestamp%20-%20pwdLastSet)%20/%20(10000000%20*%2060%20*%2060%20*%2024))%20%0A%7C%20%20eval%20DiffPwdLastSet=%20if(TimeDiff%20%3C%2032,%22OK%20less%20than%2031%20days%22,%22NOK%20more%20than%2031%20days%22)%20%0A%7C%20%20search%20$click.name$%20=%20%22$click.value$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_pwddcc$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Domain Controller password change frequency: No results</p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>GPOs</title>\r\n                  <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1484/\" target=\"_blank\">T1484</a>\r\n        </p>\r\n      </html>\r\n      <table rejects=\"$show_html_gpoaudit$\">\r\n        <title>Modifications on GPOs configuring audit settings:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline  ((pszAttributeName = \"gPCMachineExtensionNames\" OR pszAttributeName = \"nTSecurityDescriptor\" OR  pszAttributeName = \"versionNumber\") AND dwVersion &gt;= 2) OR pszAttributeName = \"whenCreated\" [search index=$ad_index$ host=$domain_host$ sourcetype=\"adobjects\" ObjectClass=groupPolicyContainer (\"*F3CCC681-B74C-4060-9F26-CD84525DCA2A*\" OR \"*0F3F3735-573D-9804-99E4-AB2A69BA5FD4*\") | fields DN] \r\n|  makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) \r\n| join DN [search  index=$ad_index$ host=$domain_host$ ObjectClass=groupPolicyContainer (\"*F3CCC681-B74C-4060-9F26-CD84525DCA2A*\" OR \"*0F3F3735-573D-9804-99E4-AB2A69BA5FD4*\") | fields DN, DisplayName]  \r\n|  join Name \r\n    [search index=$ad_index$ host=$domain_host$ sourcetype=\"adobjects\" (ObjectClass = \"domainDNS\" OR ObjectClass = \"site\" OR ObjectClass = \"organizationalUnit\")  | rex field=_raw \"gPLink\\\"&gt;(?&lt;gPLink&gt;.+?)&lt;/S&gt;\" \r\n |  search  gPLink = \"*\" \r\n|  rex field=gPLink \"(CN|cn)\\=(?&lt;Name&gt;\\{.+?\\}),\" max_match=0 \r\n| mvexpand Name\r\n|  stats values(DN) as Links by Name \r\n|  fields Name, Links ]\r\n|  table _time, DisplayName, pszAttributeName, dwVersion, Links, Name, OriginatingDC | sort -_time</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_gpoaudit\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_gpoaudit\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"OriginatingDC\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"DisplayName\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"dwVersion\">\r\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\r\n          <scale type=\"minMidMax\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20%20%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=%22adobjects%22%20ObjectClass=groupPolicyContainer%20(%22*F3CCC681-B74C-4060-9F26-CD84525DCA2A*%22%20OR%20%22*0F3F3735-573D-9804-99E4-AB2A69BA5FD4*%22)%20%7C%20fields%20DN%5D%20%0A%7C%20%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%0A%7C%20join%20DN%20%5Bsearch%20%20index=$ad_index$%20host=$domain_host$%20ObjectClass=groupPolicyContainer%20(%22*F3CCC681-B74C-4060-9F26-CD84525DCA2A*%22%20OR%20%22*0F3F3735-573D-9804-99E4-AB2A69BA5FD4*%22)%20%7C%20fields%20DN,%20DisplayName%5D%20%20%0A%7C%20%20join%20Name%20%0A%20%20%20%20%5Bsearch%20index=$ad_index$%20host=$domain_host$%20sourcetype=%22adobjects%22%20(ObjectClass%20=%20%22domainDNS%22%20OR%20ObjectClass%20=%20%22site%22%20OR%20ObjectClass%20=%20%22organizationalUnit%22)%20%20%7C%20rex%20field=_raw%20%22gPLink%5C%22%3E(%3F%3CgPLink%3E.%2B%3F)%3C/S%3E%22%20%0A%20%7C%20%20search%20%20gPLink%20=%20%22*%22%20%0A%7C%20%20rex%20field=gPLink%20%22(CN%7Ccn)%5C=(%3F%3CName%3E%5C%7B.%2B%3F%5C%7D),%22%20max_match=0%20%0A%7C%20mvexpand%20Name%0A%7C%20%20stats%20values(DN)%20as%20Links%20by%20Name%20%0A%7C%20%20fields%20Name,%20Links%20%5D%0A%7C%20%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_gpoaudit$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Modifications on GPOs configuring audit settings: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_breakgpp$\">\r\n        <title>Modifications breaking GPO processing:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_breakgpp\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_breakgpp\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=\"adtimeline\" ObjectClass=groupPolicyContainer ((pszAttributeName=\"versionNumber\" OR pszAttributeName=\"gPCFunctionalityVersion\") AND dwVersion &gt; 1) OR (pszAttributeName=\"gPCFileSysPath\" AND dwVersion &gt; 2)\r\n| join DN \r\n    [search index=$ad_index$ host=$domain_host$ sourcetype=\"adobjects\" ObjectClass=groupPolicyContainer \r\n    | rex field=_raw \"versionNumber\\\"&gt;(?&lt;versionNumber&gt;.+?)&lt;/I32&gt;\" \r\n    |  fields DN, DisplayName, versionNumber] \r\n| search pszAttributeName=\"gPCFileSysPath\" OR pszAttributeName=\"gPCFunctionalityVersion\" OR (pszAttributeName=\"versionNumber\" AND versionNumber = 0)\r\n|  table _time,  DisplayName, pszAttributeName, dwVersion</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n      </table>\r\n      <html depends=\"$show_html_breakgpp$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Modifications breaking GPO processing: No results</p>\r\n      </html>\r\n    </panel>\r\n  </row>\r\n  <row>\r\n    <panel>\r\n      <title>DCShadow detection</title>\r\n            <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1207/\" target=\"_blank\">T1207</a>\r\n        </p>\r\n      </html>\r\n      <chart rejects=\"$show_html_dcshadow$\">\r\n        <title>Possible DCShadow operations:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (ObjectClass=\"Server\" OR ObjectClass=\"nTDSDSA\") pszAttributeName=\"Isdeleted\" | eval whencreate=strptime(WhenCreated,\"%Y-%m-%d %H:%M:%S%Z\")  | eval timediff = _time - whencreate | search timediff &lt; 10 | timechart  span=1week count by pszAttributeName limit=0</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_dcshadow\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_dcshadow\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.chart\">column</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <eval token=\"drilldown.earliest\">if(isnull($row._time$),1,$row._time$)</eval>\r\n          <eval token=\"drilldown.latest\">if(isnull($row._time$),now(),$row._time$ + 604800)</eval>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(ObjectClass=%22Server%22%20OR%20ObjectClass=%22nTDSDSA%22)%20pszAttributeName=%22Isdeleted%22%20%7C%20eval%20whencreate=strptime(WhenCreated,%22%25Y-%25m-%25d%20%25H:%25M:%25S%25Z%22)%20%20%7C%20eval%20timediff%20=%20_time%20-%20whencreate%20%7C%20search%20timediff%20%3C%2010&amp;earliest=$drilldown.earliest$&amp;latest=$drilldown.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_dcshadow$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Possible DCShadow operations: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_usnOriginatingChang$\">\r\n        <title>Possible metadata timestomping, usnOriginatingChange detection:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline  | sort 0  uuidLastOriginatingDsaInvocationID, usnOriginatingChange  | autoregress usnOriginatingChange as Previous_usnOriginatingChange p=1 | autoregress ftimeLastOriginatingChange as Previous_ftimeLastOriginatingChange p=1 | autoregress uuidLastOriginatingDsaInvocationID as Previous_uuidLastOriginatingDsaInvocationID p=1 | delta _time AS timeDelta | search (timeDelta &lt; -60 NOT (ObjectClass=\"container\" AND Name=\"Deleted Objects\"))  | where uuidLastOriginatingDsaInvocationID = Previous_uuidLastOriginatingDsaInvocationID | stats count, list(DN) as DNs, list(pszAttributeName) as pszAttributeNames, list(usnOriginatingChange) as usnOriginatingChanges list(Previous_usnOriginatingChange) as prev_usnOriginatingChanges list(ftimeLastOriginatingChange) as ModificationTimes list(Previous_ftimeLastOriginatingChange) as prev_ModificationTimes by uuidLastOriginatingDsaInvocationID, pszLastOriginatingDsaDN | where count &gt; 1 |  makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | table usnOriginatingChanges, prev_usnOriginatingChanges, DNs, pszAttributeNames, ModificationTimes,prev_ModificationTimes, OriginatingDC, uuidLastOriginatingDsaInvocationID</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_usnOriginatingChang\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_usnOriginatingChang\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20%20%7C%20sort%200%20%20uuidLastOriginatingDsaInvocationID,%20usnOriginatingChange%20%20%7C%20autoregress%20usnOriginatingChange%20as%20Previous_usnOriginatingChange%20p=1%20%7C%20autoregress%20ftimeLastOriginatingChange%20as%20Previous_ftimeLastOriginatingChange%20p=1%20%7C%20autoregress%20uuidLastOriginatingDsaInvocationID%20as%20Previous_uuidLastOriginatingDsaInvocationID%20p=1%20%7C%20delta%20_time%20AS%20timeDelta%20%7C%20search%20(timeDelta%20%3C%20-60%20NOT%20(ObjectClass=%22container%22%20AND%20Name=%22Deleted%20Objects%22))%20%20%7C%20where%20uuidLastOriginatingDsaInvocationID%20=%20Previous_uuidLastOriginatingDsaInvocationID&amp;earliest=0&amp;latest=</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_usnOriginatingChang$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Possible metadata timestomping, usnOriginatingChange detection: No results</p>\r\n      </html>\r\n      <table rejects=\"$show_html_usnLocalChang$\">\r\n        <title>Possible metadata timestomping, usnLocalChange detection:</title>\r\n        <search>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_usnLocalChang\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_usnLocalChang\"></unset>\r\n            </condition>\r\n          </progress>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline earliest=\"$Dcinstall$\" | sort 0 usnLocalChange  | delta _time AS timeDelta |   autoregress usnLocalChange as Previous_usnLocalChange p=1 | autoregress ftimeLastOriginatingChange as Previous_ftimeLastOriginatingChange p=1 | search (timeDelta &lt; -2592000 NOT (ObjectClass=\"container\" AND Name=\"Deleted Objects\")) | makemv pszLastOriginatingDsaDN delim=\",CN=\" | eval OriginatingDC = mvindex(pszLastOriginatingDsaDN, 1, 1) | table usnLocalChange , DN, pszAttributeName,  ftimeLastOriginatingChange, OriginatingDC, uuidLastOriginatingDsaInvocationID, Previous_usnLocalChange, Previous_ftimeLastOriginatingChange</query>\r\n          <earliest>0</earliest>\r\n          <latest>now</latest>\r\n        </search>\r\n        <option name=\"count\">10</option>\r\n        <option name=\"drilldown\">cell</option>\r\n        <format type=\"color\" field=\"pszAttributeName\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <format type=\"color\" field=\"OriginatingDC\">\r\n          <colorPalette type=\"sharedList\"></colorPalette>\r\n          <scale type=\"sharedCategory\"></scale>\r\n        </format>\r\n        <drilldown>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20earliest=%22$Dcinstall$%22%20%7C%20sort%200%20usnLocalChange%20%20%7C%20delta%20_time%20AS%20timeDelta%20%7C%20%20%20autoregress%20usnLocalChange%20as%20Previous_usnLocalChange%20p=1%20%7C%20autoregress%20ftimeLastOriginatingChange%20as%20Previous_ftimeLastOriginatingChange%20p=1%20%7C%20search%20(timeDelta%20%3C%20-2592000%20NOT%20(ObjectClass=%22container%22%20AND%20Name=%22Deleted%20Objects%22))%20%7C%20makemv%20pszLastOriginatingDsaDN%20delim=%22,CN=%22%20%7C%20eval%20OriginatingDC%20=%20mvindex(pszLastOriginatingDsaDN,%201,%201)%20%7C%20%20search%20$click.name2$%20=%20%22$click.value2$%22&amp;earliest=0&amp;latest=now</link>\r\n        </drilldown>\r\n      </table>\r\n      <html depends=\"$show_html_usnLocalChang$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Possible metadata timestomping, usnLocalChange detection: No results</p>\r\n      </html>\r\n    </panel>\r\n    <panel>\r\n      <title>Schema and configuration partition suspicious modifications:</title>\r\n                  <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1098/\" target=\"_blank\">T1098</a>\r\n        </p>\r\n      </html> \r\n      <chart rejects=\"$show_html_schemconf$\">\r\n        <title>Schema: SearchFlags or defaultSecurityDescriptor attributes | Configuration: RightsGuid, LocalizationDisplayId, DsHeuristics or tombstoneLifetime attributes</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (pszAttributeName=\"SearchFlags\" OR pszAttributeName=\"defaultSecurityDescriptor\" OR pszAttributeName=\"RightsGuid\" OR pszAttributeName=\"LocalizationDisplayId\" OR pszAttributeName=\"DsHeuristics\" OR pszAttributeName=\"tombstoneLifetime\") dwVersion &gt;= 2  | timechart  span=1week count by pszAttributeName limit=0</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_schemconf\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_schemconf\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.chart\">column</option>\r\n        <option name=\"charting.chart.stackMode\">default</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <eval token=\"drilldown.earliest\">if(isnull($row._time$),1,$row._time$)</eval>\r\n          <eval token=\"drilldown.latest\">if(isnull($row._time$),now(),$row._time$ + $row._span$)</eval>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(pszAttributeName=%22SearchFlags%22%20OR%20pszAttributeName=%22defaultSecurityDescriptor%22%20OR%20pszAttributeName=%22RightsGuid%22%20OR%20pszAttributeName=%22LocalizationDisplayId%22%20OR%20pszAttributeName=%22DsHeuristics%22%20OR%20pszAttributeName=%22tombstoneLifetime%22)%20dwVersion%20%3E=%202%20%7C%20%20search%20%20pszAttributeName%20=%20%22$click.name2$%22&amp;earliest=$drilldown.earliest$&amp;latest=$drilldown.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_schemconf$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Schema and configuration partition suspicious modifications: No results</p>\r\n      </html>\r\n                                <html>\r\n      <p style=\"text-align:right;\">\r\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1114/\" target=\"_blank\">T1114</a>\r\n        </p>\r\n      </html> \r\n      <chart rejects=\"$show_html_mailexfil$\">\r\n        <title>Possible mail exfiltration on Exchange on prem msExchMRSRequest, msExchTransportRule and msExchPrivateMDB ObjectClass:</title>\r\n        <search>\r\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (ObjectClass=msExchMRSRequest AND pszAttributeName=\"isDeleted\") OR (ObjectClass=msExchTransportRule AND  pszAttributeName=msExchTransportRuleXml) OR (ObjectClass=msExchPrivateMDB AND pszAttributeName=nTSecurityDescriptor AND dwVersion &gt;= 2 ) OR (ObjectClass=msExchRoleAssignment AND  pszAttributeName=msExchRoleAssignmentFlags)  | bucket span=1week _time | stats count by _time ObjectClass | where ObjectClass != \"msExchRoleAssignment\" OR (ObjectClass=\"msExchRoleAssignment\" AND count &lt; 50) | xyseries _time,ObjectClass,count</query>\r\n          <earliest>0</earliest>\r\n          <latest></latest>\r\n          <progress>\r\n            <condition match=\"$job.resultCount$ == 0\">\r\n              <set token=\"show_html_mailexfil\">toto</set>\r\n            </condition>\r\n            <condition>\r\n              <unset token=\"show_html_mailexfil\"></unset>\r\n            </condition>\r\n          </progress>\r\n        </search>\r\n        <option name=\"charting.chart\">column</option>\r\n        <option name=\"charting.chart.stackMode\">stacked</option>\r\n        <option name=\"charting.drilldown\">all</option>\r\n        <option name=\"refresh.display\">progressbar</option>\r\n        <drilldown>\r\n          <eval token=\"drilldown.earliest\">if(isnull($row._time$),1,$row._time$)</eval>\r\n          <eval token=\"drilldown.latest\">if(isnull($row._time$),now(),$row._time$ + 604800)</eval>\r\n          <link target=\"_blank\">search?q=index=$ad_index$%20host=$domain_host$%20sourcetype=adtimeline%20(ObjectClass=msExchMRSRequest%20AND%20pszAttributeName=%22isDeleted%22)%20OR%20(ObjectClass=msExchTransportRule%20AND%20%20pszAttributeName=msExchTransportRuleXml)%20OR%20(ObjectClass=msExchPrivateMDB%20AND%20pszAttributeName=nTSecurityDescriptor%20AND%20dwVersion%20%3E=%202%20)%20OR%20(ObjectClass=msExchRoleAssignment%20AND%20%20pszAttributeName=msExchRoleAssignmentFlags)%20%20%7C%20%20search%20%20ObjectClass%20=%20%22$click.name2$%22&amp;earliest=$drilldown.earliest$&amp;latest=$drilldown.latest$</link>\r\n        </drilldown>\r\n      </chart>\r\n      <html depends=\"$show_html_mailexfil$\">\r\n         <p style=\"font-weight: bold !important;font-size:14px\">Possible mail exfiltration on Exchange on prem msExchMRSRequest, msExchTransportRule and msExchPrivateMDB ObjectClass: No results</p>\r\n      </html>\r\n      <html>\r\n            <p style=\"vertical-align:bottom;text-align:right;font-style:italic;font-size:x-small\">\r\n          © 2020 The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation.\r\n        </p>\r\n        </html>\r\n    </panel>\r\n  </row>\r\n</form>"
  },
  {
    "path": "SA-ADTimeline/default/data/ui/views/suspicious_exchange_activity.xml",
    "content": "<form version=\"1.1\">\n  <label>Track suspicious Exchange activity</label>\n  <fieldset submitButton=\"false\"></fieldset>\n  <row>\n    <panel>\n      <input type=\"dropdown\" token=\"ad_index\" searchWhenChanged=\"true\">\n        <label>Choose index to process:</label>\n        <search>\n          <query>| tstats latest(_time) where index=*  by index</query>\n        </search>\n        <selectFirstChoice>true</selectFirstChoice>\n        <fieldForLabel>index</fieldForLabel>\n        <fieldForValue>index</fieldForValue>\n      </input>\n      <input type=\"dropdown\" token=\"domain_host\" searchWhenChanged=\"true\">\n        <label>Choose AD Domain to process:</label>\n        <search>\n          <query>| tstats latest(_time) where index=$ad_index$ (sourcetype=adobjects OR sourcetype=gcobjects OR sourcetype=adtimeline)  by host</query>\n        </search>\n        <selectFirstChoice>true</selectFirstChoice>\n        <fieldForLabel>host</fieldForLabel>\n        <fieldForValue>host</fieldForValue>\n      </input>\n    </panel>\n  </row>\n  <row>\n    <panel>\n      <title>Microsoft Exchange infrastructure:</title>\n          <single>\n            <title>Microsoft Exchange schema information, rangeUpper attribute of ms-Exch-Schema-Version-Pt object:</title>\n            <search>\n              <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects (ObjectClass=attributeSchema AND Name=ms-Exch-Schema-Version-Pt)  | table Name | appendpipe [stats count | eval \"Name\"=\"Void\" | where count=0 | table \"Name\"] | eval checkExch =case(Name == \"ms-Exch-Schema-Version-Pt\", \"Exchange installed in the AD forest\", 1=1 , \"Exchange not installed in the AD forest\") | fields checkExch</query>\n              <earliest>$earliest$</earliest>\n              <latest>$latest$</latest>\n            </search>\n            <option name=\"drilldown\">all</option>\n            <option name=\"height\">50</option>\n            <option name=\"refresh.display\">progressbar</option>\n          </single>\n        <html encoded=\"1\">&lt;br/&gt;</html>\n          <single>\n            <search>\n              <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects (ObjectClass=attributeSchema AND Name=ms-Exch-Schema-Version-Pt)  | rex field=_raw \"rangeUpper\\\"&gt;(?&lt;rangeUpper&gt;.+?)&lt;/I32&gt;\" |  lookup ExchangeSchema_lookup rangeUpper AS rangeUpper OUTPUTNEW Exchange AS ExchangeV | stats count by ExchangeV, rangeUpper | rangemap field=rangeUpper low=15331-1000000 elevated=15312-15331 default=severe</query>\n              <earliest>$earliest$</earliest>\n              <latest>$latest$</latest>\n            </search>\n            <option name=\"drilldown\">none</option>\n            <option name=\"height\">50</option>\n            <option name=\"refresh.display\">progressbar</option>\n          </single>\n    </panel>\n    <panel>\n      <table>\n        <title>Microsoft Exchange servers, msExchExchangeServer ObjectClass:</title>\n        <search>\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects ObjectClass=msExchExchangeServer  | rex field=_raw \"&lt;S&gt;Version (?&lt;ExchVersion&gt;.+?)&lt;/S&gt;\" | stats count by Name, ExchVersion, whenCreated  | rename Name as \"Exchange server name\", ExchVersion as \"Exchange server version\", whenCreated as \"Exchange server creation time\" |  table \"Exchange server name\", \"Exchange server version\", \"Exchange server creation time\"</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <format type=\"color\" field=\"Exchange server version\">\n          <colorPalette type=\"sharedList\"></colorPalette>\n          <scale type=\"sharedCategory\"></scale>\n        </format>\n      </table>\n      <html encoded=\"1\">&lt;br/&gt;</html>\n    </panel>\n  </row>\n  <row>\n    <panel>\n      <title>Possible mail exfiltration</title>\n      <html>\n      <p style=\"text-align:right;\">\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1114/\" target=\"_blank\">T1114</a>\n        </p>\n      </html>\n      <chart>\n        <title>Exchange mailbox Forwarders, Transport rules and Remote Domain creation</title>\n        <search>\n          <progress>\n            <condition match=\"$job.resultCount$ == 0\">\n              <set token=\"show_html_lockout\">toto</set>\n            </condition>\n            <condition>\n              <unset token=\"show_html_lockout\"></unset>\n            </condition>\n          </progress>\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline pszAttributeName=\"msExchGenericForwardingAddress\" OR \"altRecipient\"  OR (ObjectCategory=\"CN=ms-Exch-Domain-Content-Config,CN=Schema,CN=Configuration,DC=labo,DC=local\" AND  pszAttributeName=\"whenCreated\" ) OR (ObjectClass=\"msExchTransportRule\" AND pszAttributeName=\"msExchTransportRuleXml\") | timechart  span=1week count by pszAttributeName limit=0 | rename whenCreated as RemoteDomainCreation</query>\n          <earliest>-5y@h</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"charting.axisTitleY.text\">stats by week</option>\n        <option name=\"charting.chart\">column</option>\n        <option name=\"charting.drilldown\">all</option>\n        <option name=\"refresh.display\">progressbar</option>\n      </chart>\n      <table>\n        <title>Accounts with forwarder attribute modified</title>\n        <search>\n          <query>index=$ad_index$  host=$domain_host$  sourcetype=adtimeline pszAttributeName=\"altRecipient\" OR pszAttributeName=\"msExchGenericForwardingAddress\" | makemv delim=\";\" _raw | eval Value=mvindex(_raw,9) | sort -_time |rename Value as \"Value (if altRecipient)\" | table _time, DN,  pszAttributeName, dwVersion, \"Value (if altRecipient)\"</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <option name=\"refresh.display\">progressbar</option>\n        <format type=\"color\" field=\"Value (if altRecipient)\">\n          <colorPalette type=\"expression\">case (like(value,\"CN\"), \"#FE5D26\" </colorPalette>\n        </format>\n      </table>\n      <table>\n        <title>Transport Rules forwarding messages</title>\n        <search>\n          <query>index=$ad_index$  host=$domain_host$ sourcetype=adobjects [search index=$ad_index$  host=$domain_host$ sourcetype=adtimeline (ObjectClass=msExchTransportRule AND  pszAttributeName=msExchTransportRuleXml) | table DN]| xpath outfield=WhenModified \"//DT[@N='Modified']\" | xpath outfield=whenCreated \"//DT[@N='whenCreated']\" | xpath outfield=transportRule \"//S[@N='msExchTransportRuleXml']\" | rex field=transportRule mode=sed \"s/_x000D_|_x000A_|_x0009_//g\" | xpath outfield=isActive field=transportRule \"//@enabled\" | xpath outfield=Recipient_address field=transportRule \"//fork/recipient/@address\" |xpath outfield=Action field=transportRule \"//action/@name\" |xpath outfield=Action_Detail field=transportRule \"//action/@externalName\" |xpath outfield=Action_Args field=transportRule \"//argument/@*\" | xpath outfield=Condition field=transportRule \"//condition\" | xpath outfield=Exception field=transportRule \"//fork[@exception='true/]\" |xpath outfield=Comments field=transportRule \"//rule/@comments\" |eval isActive=if(isnull(isActive),\"true\",isActive) |search Action IN (AddEnvelopeRecipient,RedirectMessage,ModerateMessageByUser,AddEnvelopeRecipient,AddToRecipient,AddCcRecipient,AddManagerAsRecipientType) |table WhenModified, whenCreated, Name, isActive, Recipient_address, Action, Action_Detail, Action_Args,Condition, Exception, Comments |sort -WhenModified</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <option name=\"refresh.display\">progressbar</option>\n        <format type=\"color\" field=\"isActive\">\n          <colorPalette type=\"sharedList\"></colorPalette>\n          <scale type=\"sharedCategory\"></scale>\n        </format>\n      </table>\n      <table>\n        <title>Remote Domains configuration details</title>\n        <search>\n          <query>index=$ad_index$  host=$domain_host$  sourcetype=adobjects ObjectCategory=\"CN=ms-Exch-Domain-Content-Config,CN=Schema,CN=Configuration,*\"| rex field=_raw  \"&lt;DT N=\\\"Modified\\\"&gt;(?&lt;Modified&gt;.+?)&lt;\\/DT&gt;\"| table _time, whenCreated, Modified, Name, Owner, DN</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <option name=\"refresh.display\">progressbar</option>\n        <format type=\"color\" field=\"Name\">\n          <colorPalette type=\"sharedList\"></colorPalette>\n          <scale type=\"sharedCategory\"></scale>\n        </format>\n      </table>\n      <chart>\n        <title>Exchange mailbox Import, Export, Discovery (msExchMRSRequest)</title>\n        <search>\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline ObjectClass=msExchMRSRequest AND  (pszAttributeName=\"isDeleted\" OR pszAttributeName=\"whenCreated\") | timechart  span=1week count by pszAttributeName limit=0 </query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"charting.axisTitleY.text\">stats by week</option>\n        <option name=\"charting.chart\">column</option>\n        <option name=\"charting.drilldown\">all</option>\n        <option name=\"refresh.display\">progressbar</option>\n\n      </chart>\n      <table>\n        <title>msExchMRSRequest details</title>\n        <search>\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects | search [search index=$ad_index$ host=$domain_host$ sourcetype=adtimeline ObjectClass=msExchMRSRequest AND (pszAttributeName=\"isDeleted\" OR pszAttributeName=\"whenCreated\")| eval temp=if(like(Name, \"%DEL:%\"), split(Name,\":\"), Name) | eval Object=if(mvcount(temp)=2,mvindex(temp,1),temp) | eval DN= \"*\" . Object . \"*\" | fields DN] | rex field=_raw \"&lt;DT N=\\\"Created\\\"&gt;(?&lt;Created&gt;.+?)&lt;\\/DT&gt;\" | rex field=_raw \"&lt;DT N=\\\"DisplayName\\\"&gt;(?&lt;DisplayName&gt;.+?)&lt;\\/DT&gt;\" | rex field=_raw \"&lt;S N=\\\"msExchMailboxMoveSourceUserLink\\\"&gt;(?&lt;msExchMailboxMoveSourceUserLink&gt;.+?)&lt;\\/S&gt;\" | rex field=_raw \"&lt;S N=\\\"msExchMailboxMoveFilePath\\\"&gt;(?&lt;msExchMailboxMoveFilePath&gt;.+?)&lt;\\/S&gt;\" | rex field=_raw \"&lt;S N=\\\"msExchMailboxMoveSourceMDBLink\\\"&gt;(?&lt;msExchMailboxMoveSourceMDBLink&gt;.+?)&lt;\\/S&gt;\" | rex field=_raw \"&lt;S N=\\\"msExchMailboxMoveTargetMDBLink\\\"&gt;(?&lt;msExchMailboxMoveTargetMDBLink&gt;.+?)&lt;\\/S&gt;\" | rex field=_raw \"&lt;S N=\\\"DistinguishedName\\\"&gt;(?&lt;DistinguishedName&gt;.+?)&lt;\\/S&gt;\" | table  Created, DisplayName,  msExchMailboxMoveSourceUserLink,  msExchMailboxMoveFilePath, msExchMailboxMoveSourceMDBLink,  msExchMailboxMoveTargetMDBLink, DistinguishedName | sort Created</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <option name=\"refresh.display\">progressbar</option>\n        <format type=\"color\" field=\"DisplayName\">\n          <colorPalette type=\"sharedList\"></colorPalette>\n          <scale type=\"sharedCategory\"></scale>\n        </format>\n        <format type=\"color\" field=\"msExchMailboxMoveFilePath\">\n          <colorPalette type=\"expression\">case (like(value,\"aspx\"),\"#E94F37\" )</colorPalette>\n        </format>\n      </table>\n\n    </panel>\n  </row>\n  <row>\n    <panel>\n      <title>Persistence</title>\n      <html>\n      <p style=\"text-align:right;\">\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1098/\" target=\"_blank\">T1098</a>\n        </p>\n      </html>\n      <chart>\n        <title>RBAC roles Editions</title>\n        <search>\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline ObjectClass=msExchRoleAssignment AND  pszAttributeName=msExchRoleAssignmentFlags  | bucket span=1week _time | stats count by _time ObjectClass | where ObjectClass != \"msExchRoleAssignment\" OR (ObjectClass=\"msExchRoleAssignment\" AND count &lt; 50) | xyseries _time,ObjectClass,count</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"charting.chart\">column</option>\n        <option name=\"charting.chart.stackMode\">stacked</option>\n        <option name=\"charting.drilldown\">all</option>\n        <option name=\"refresh.display\">progressbar</option>\n      </chart>\n      <table>\n        <title>RBAC Details</title>\n        <search>\n           <query>index=$ad_index$  sourcetype=adobjects ObjectClass=msExchRoleAssignment| rex field=_raw \"&lt;S N=\\\"msExchUserLink\\\"&gt;(?&lt;msExchUserLink&gt;.+?)&lt;\\/S&gt;\" | rex field=_raw \"&lt;S N=\\\"msExchRoleLink\\\"&gt;(?&lt;msExchRoleLink&gt;.+?)&lt;\\/S&gt;\" | rex field=_raw \"&lt;S N=\\\"msExchDomainRestrictionLink\\\"&gt;(?&lt;msExchDomainRestrictionLink&gt;.+?)&lt;\\/S&gt;\"| table _time, Name, msExchUserLink, msExchRoleLink, msExchDomainRestrictionLink | sort -_time</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <option name=\"refresh.display\">progressbar</option>\n        <format type=\"color\" field=\"dwVersion\">\n          <colorPalette type=\"minMidMax\" maxColor=\"#DC4E41\" minColor=\"#FFFFFF\"></colorPalette>\n          <scale type=\"minMidMax\"></scale>\n        </format>\n        <format type=\"color\" field=\"msExchRoleLink\">\n          <colorPalette type=\"expression\">case (like(value,\"UnScoped Role Management\"), \"#FE5D26\" , like(value,\"Role Management\"), \"#F2C078\" , like(value,\"Impersonation\") , \"#FAEDCA\" , like(value,\"Mailbox Search\"),\"#C1DBB3\" , like(value,\"Mailbox Search\"),\"#7EBC89\" , like(value,\"Mailbox Import Export\"),\"#E94F37\")</colorPalette>\n        </format>\n      </table>\n      <chart>\n        <title>msExch* object class ACLs Editions</title>\n        <search>\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (ObjectClass=msExch* AND pszAttributeName=nTSecurityDescriptor AND dwVersion &gt;= 2 )  | bucket span=1week _time | stats count by _time ObjectClass | where ObjectClass != \"msExchRoleAssignment\" OR (ObjectClass=\"msExchRoleAssignment\" AND count &lt; 50) | xyseries _time,ObjectClass,count</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"charting.chart\">column</option>\n        <option name=\"charting.chart.stackMode\">stacked</option>\n        <option name=\"charting.drilldown\">all</option>\n        <option name=\"refresh.display\">progressbar</option>\n      </chart>\n    </panel>\n  </row>\n  <row>\n    <panel>\n      <title>MsExchangeSecurityGroups</title>\n      <html>\n      <p style=\"text-align:right;\">\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1098/\" target=\"_blank\">T1098</a>\n        </p>\n      </html>\n      <table>\n        <title>Timeline, MsExchangeSecurityGroups:</title>\n        <search>\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adtimeline (pszAttributeName = member AND dwVersion != 0) OR (pszAttributeName = whenCreated) [search index=$ad_index$ host=$domain_host$ sourcetype=adobjects ObjectClass = \"group\" OU=\"Microsoft Exchange Security Groups\" | table DN] | table _time, DN, pszAttributeName, Member, dwVersion, ftimeCreated, ftimeDeleted | sort -_time</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <option name=\"refresh.display\">progressbar</option>\n        <format type=\"color\" field=\"dwVersion\">\n          <colorPalette type=\"minMidMax\" maxColor=\"#006D9C\" minColor=\"#FFFFFF\"></colorPalette>\n          <scale type=\"minMidMax\"></scale>\n        </format>\n        <format type=\"color\" field=\"DN\">\n          <colorPalette type=\"sharedList\"></colorPalette>\n          <scale type=\"sharedCategory\"></scale>\n        </format>\n        <format type=\"color\" field=\"Member\">\n          <colorPalette type=\"sharedList\"></colorPalette>\n          <scale type=\"sharedCategory\"></scale>\n        </format>\n      </table>\n      <table>\n        <title>Exchange security groups members:</title>\n        <search>\n          <query>index=$ad_index$ host=$domain_host$ sourcetype=adobjects  OU=\"Microsoft Exchange Security Groups\" Members=* | rex field=Members mode=sed \"s/&lt;S&gt;|&lt;\\/S&gt;|          //g\" | table whenCreated, Name, Members | sort -whenCreated</query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <option name=\"refresh.display\">progressbar</option>\n        <format type=\"color\" field=\"Name\">\n          <colorPalette type=\"expression\">case (match(value,\"Organization Management\"), \"#FE5D26\" , like(value,\"Exchange Servers\"), \"#F2C078\" , like(value,\"Hygiene Management\") , \"#FAEDCA\" , like(value,\"Exchange Windows Permissions\"),\"#C1DBB3\" , like(value,\"Exchange Trusted Subsystem\"),\"#7EBC89\" , like(value,\"Server Management\"),\"#685044\")</colorPalette>\n        </format>\n                <format type=\"color\" field=\"Members\">\n          <colorPalette type=\"expression\">case (match(value,\"Organization Management\"), \"#FE5D26\" , like(value,\"Exchange Servers\"), \"#F2C078\" , like(value,\"Hygiene Management\") , \"#FAEDCA\" , like(value,\"Exchange Windows Permissions\"),\"#C1DBB3\" , like(value,\"Exchange Trusted Subsystem\"),\"#7EBC89\" , like(value,\"Server Management\"),\"#685044\")</colorPalette>\n        </format>\n      </table>\n          </panel>\n  </row>\n<row>\n    <panel>\n      <title>Phishing</title>\n            <html>\n      <p style=\"text-align:right;\">\n          MITRE | ATT&amp;CK <a href=\"https://attack.mitre.org/techniques/T1566/\" target=\"_blank\">T1566</a>\n        </p>\n      </html>\n       <table>\n        <title>Transport Rules: track malicious disclaimer</title>\n        <search>\n          <query>index=$ad_index$  host=$domain_host$ sourcetype=adobjects [search index=$ad_index$  host=$domain_host$ sourcetype=adtimeline (ObjectClass=msExchTransportRule AND  pszAttributeName=msExchTransportRuleXml) | table DN]| xpath outfield=WhenModified \"//DT[@N='Modified']\" | xpath outfield=whenCreated \"//DT[@N='whenCreated']\" | xpath outfield=transportRule \"//S[@N='msExchTransportRuleXml']\" | rex field=transportRule mode=sed \"s/_x000D_|_x000A_|_x0009_//g\" | xpath outfield=isActive field=transportRule \"//@enabled\" | xpath outfield=Recipient_address field=transportRule \"//fork/recipient/@address\" |xpath outfield=Action field=transportRule \"//action/@name\" |xpath outfield=Action_Detail field=transportRule \"//action/@externalName\" |xpath outfield=Action_Args field=transportRule \"//argument/@*\" | xpath outfield=Condition field=transportRule \"//condition\" | xpath outfield=Exception field=transportRule \"//fork[@exception='true/]\" |xpath outfield=Comments field=transportRule \"//rule/@comments\" |eval isActive=if(isnull(isActive),\"true\",isActive) | search Action IN (ApplyHtmlDisclaimer) |table WhenModified, whenCreated, Name, isActive, Action, Action_Args,Condition, Exception, Comments |sort -WhenModified\n          </query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <option name=\"refresh.display\">progressbar</option>\n        <format type=\"color\" field=\"Action_Args\">\n          <colorPalette type=\"sharedList\"></colorPalette>\n          <scale type=\"sharedCategory\"></scale>\n        </format>\n      </table>\n      <table>\n        <title>Transport Rules: track SCL modifications</title>\n        <search>\n          <query>index=$ad_index$  host=$domain_host$ sourcetype=adobjects [search index=$ad_index$  host=$domain_host$ sourcetype=adtimeline (ObjectClass=msExchTransportRule AND  pszAttributeName=msExchTransportRuleXml) | table DN]| xpath outfield=WhenModified \"//DT[@N='Modified']\" | xpath outfield=whenCreated \"//DT[@N='whenCreated']\" | xpath outfield=transportRule \"//S[@N='msExchTransportRuleXml']\" | rex field=transportRule mode=sed \"s/_x000D_|_x000A_|_x0009_//g\" | xpath outfield=isActive field=transportRule \"//@enabled\" | xpath outfield=Recipient_address field=transportRule \"//fork/recipient/@address\" |xpath outfield=Action field=transportRule \"//action/@name\" |xpath outfield=Action_Detail field=transportRule \"//action/@externalName\" |xpath outfield=Action_Args field=transportRule \"//argument/@*\" | xpath outfield=Condition field=transportRule \"//condition\" | xpath outfield=Exception field=transportRule \"//fork[@exception='true/]\" |xpath outfield=Comments field=transportRule \"//rule/@comments\" |eval isActive=if(isnull(isActive),\"true\",isActive) | search (Action_Detail IN (SetScl) OR Action_Args IN(*SCL*)) |table WhenModified, whenCreated, Name, isActive, Action, Action_Args,Condition, Exception, Comments |sort -WhenModified\n          </query>\n          <earliest>0</earliest>\n          <latest></latest>\n        </search>\n        <option name=\"count\">10</option>\n        <option name=\"drilldown\">cell</option>\n        <option name=\"refresh.display\">progressbar</option>\n        <format type=\"color\" field=\"Action_Args\">\n          <colorPalette type=\"sharedList\"></colorPalette>\n          <scale type=\"sharedCategory\"></scale>\n        </format>\n      </table>\n          <html>\n            <p style=\"vertical-align:bottom;text-align:right;font-style:italic;font-size:x-small\">\n          2020 The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation.\n        </p>\n      </html>\n    </panel>\n  </row>\n</form>"
  },
  {
    "path": "SA-ADTimeline/default/props.conf",
    "content": "﻿\r\n[adtimeline]\r\nBREAK_ONLY_BEFORE_DATE =\r\nFIELD_DELIMITER = ;\r\nINDEXED_EXTRACTIONS = csv\r\nKV_MODE = none\r\nLINE_BREAKER = ([\\r\\n]+)\r\nNO_BINARY_CHECK = true\r\nSHOULD_LINEMERGE = false\r\nTZ = GMT\r\nMAX_DAYS_AGO = 10951\r\ncategory = Structured\r\ndisabled = false\r\npulldown_type = true\r\nCHARSET = UTF-8\r\n\r\n\r\n[adobjects]\r\nTRANSFORMS-adxml_remove_header = adxml_remove_header\r\nBREAK_ONLY_BEFORE = ^\\s\\s<Obj RefId=\"\\d+\">\r\nSHOULD_LINEMERGE = true\r\nLINE_BREAKER = ([\\r\\n]+)\r\nMAX_DAYS_AGO = 10951\r\nNO_BINARY_CHECK = true\r\nTIME_FORMAT = %Y-%m-%dT%H:%M:%S%z\r\nTIME_PREFIX = createTimeStamp\">\r\nTRUNCATE = 100000000\r\ncategory = Custom\r\ndisabled = false\r\npulldown_type = true\r\nCHARSET = UTF-8\r\nBREAK_ONLY_BEFORE_DATE = \r\nEXTRACT-DN = <S N=\"DistinguishedName\">(?<DN>.+?)</S>\r\nEXTRACT-Name = <S N=\"Name\">(?<Name>.+?)</S>\r\nEXTRACT-ObjectClass = <S N=\"ObjectClass\">(?<ObjectClass>.+?)</S>\r\nEXTRACT-ObjectCategory = <S N=\"ObjectCategory\">(?<ObjectCategory>.+?)</S>\r\nEXTRACT-SamAccountName = <S N=\"sAMAccountName\">(?<SamAccountName>.+?)</S>\r\nEXTRACT-SID = <Obj N=\"objectSid\" RefId=\".+?<ToString>(?<SID>.+?)</ToString>\r\nEXTRACT-SDDL = <S N=\"Sddl\">(?<SDDL>.+?)</S>\r\nEXTRACT-AccessToString = <S N=\"AccessToString\">(?<AccessToString>.+?)</S>\r\nEXTRACT-Owner = <S N=\"Owner\">(?<Owner>.+?)</S>\r\nEXTRACT-Members = <Obj N=\"member\" RefId=\".+?<LST>(?<Members>.+?)</LST>\r\nEXTRACT-MemberOf = <Obj N=\"memberOf\" RefId=\".+?<LST>(?<MemberOf>.+?)</LST>\r\nEXTRACT-adminCount = <I32 N=\"adminCount\">(?<adminCount>.+?)</I32>\r\nEXTRACT-userAccountControl = <I32 N=\"userAccountControl\">(?<userAccountControl>.+?)</I32>\r\nEXTRACT-lastLogonTimestamp = <I64 N=\"lastLogonTimestamp\">(?<lastLogonTimestamp>.+?)</I64>\r\nEXTRACT-DisplayName = <S N=\"DisplayName\">(?<DisplayName>.+?)</S>\r\nEXTRACT-whenCreated = <DT N=\"whenCreated\">(?<whenCreated>.+?)</DT>\r\nEXTRACT-dNSHostName = <S N=\"dNSHostName\">(?<dNSHostName>.+?)</S>\r\nEXTRACT-SPNs = (?ms)servicePrincipalName.{1,100}<LST>(?<SPNs>.*?)</LST>\r\nEXTRACT-serviceBindingInformation = <Obj N=\"serviceBindingInformation\" RefId=\".+?<LST>(?<serviceBindingInformation>.+?)</LST>\r\nEXTRACT-keywords = <Obj N=\"keywords\" RefId=\".+?<LST>(?<keywords>.+?)</LST>\r\nEXTRACT-serviceClassName = <S N=\"serviceClassName\">(?<serviceClassName>.+?)</S>\r\nMAX_EVENTS = 4096\r\n\r\n[gcobjects]\r\nTRANSFORMS-adxml_remove_header = adxml_remove_header\r\nBREAK_ONLY_BEFORE = ^\\s\\s<Obj RefId=\"\\d+\">\r\nSHOULD_LINEMERGE = true\r\nLINE_BREAKER = ([\\r\\n]+)\r\nMAX_DAYS_AGO = 10951\r\nNO_BINARY_CHECK = true\r\nTIME_FORMAT = %Y-%m-%dT%H:%M:%S\r\nTIME_PREFIX = <DT N=\"whencreated\">\r\nTZ = GMT\r\nTRUNCATE = 100000000\r\ncategory = Custom\r\ndisabled = false\r\npulldown_type = true\r\nCHARSET = UTF-8\r\nBREAK_ONLY_BEFORE_DATE = \r\nEXTRACT-DN = <S N=\"distinguishedname\">(?<DN>.+?)</S>\r\nEXTRACT-Name = <S N=\"name\">(?<Name>.+?)</S>\r\nEXTRACT-ObjectClass = <Obj N=\"objectclass\" RefId=\".+?<IE>(?<ObjectClass>.+?)</IE>\r\nEXTRACT-ObjectCategory = <S N=\"objectcategory\">(?<ObjectCategory>.+?)</S>\r\nEXTRACT-SamAccountName = <S N=\"samaccountname\">(?<SamAccountName>.+?)</S>\r\nEXTRACT-SID = <S N=\"objectsid\">(?<SID>.+?)</S>\r\nEXTRACT-userAccountControl = <I32 N=\"useraccountcontrol\">(?<userAccountControl>.+?)</I32>\r\nEXTRACT-lastLogonTimestamp = <I64 N=\"lastlogontimestamp\">(?<lastLogonTimestamp>.+?)</I64>\r\nEXTRACT-DisplayName = <S N=\"displayname\">(?<DisplayName>.+?)</S>\r\nEXTRACT-whenCreated = <DT N=\"whencreated\">(?<whenCreated>.+?)</DT>\r\nEXTRACT-dNSHostName = <S N=\"dnshostname\">(?<dNSHostName>.+?)</S>\r\nEXTRACT-SPNs = (?ms)serviceprincipalname.{1,100}<IE>(?<SPNs>.*?)</IE>\r\nEXTRACT-serviceBindingInformation1 = (?ms)servicebindinginformation.{1,100}<IE>(?<serviceBindingInformation>.*?)</IE>\r\nEXTRACT-serviceBindingInformation2 = <S N=\"servicebindinginformation\">(?<serviceBindingInformation>.+?)</S>\r\nEXTRACT-keywords1 = (?ms)keywords.{1,100}<IE>(?<keywords>.*?)</IE>\r\nEXTRACT-keywords2 = <S N=\"keywords\">(?<keywords>.+?)</S>\r\nMAX_EVENTS = 4096"
  },
  {
    "path": "SA-ADTimeline/default/transforms.conf",
    "content": "[adxml_remove_header]\r\nREGEX = ^<Objs Version=\r\nDEST_KEY = queue\r\nFORMAT = nullQueue\r\n\r\n[Schema_lookup]\r\nfilename = ObjectVersionSchema\r\n\r\n[fsmo_lookup]\r\nbatch_index_query = 0\r\ncase_sensitive_match = 1\r\nfilename = fsmoroleowner\r\n\r\n[ExchangeSchema_lookup]\r\nbatch_index_query = 0\r\ncase_sensitive_match = 1\r\nfilename = ExchangeSchemaVersions\r\n\r\n[CSE_lookup]\r\nbatch_index_query = 0\r\ncase_sensitive_match = 1\r\nfilename = CSE_matching"
  },
  {
    "path": "SA-ADTimeline/lookups/CSE_matching",
    "content": "GUID,CSE\r\r\n{35378EAC-683F-11D2-A89A-00C04FBBCFA2},Registry settings\r\r\n{0ACDD40C-75AC-47AB-BAA0-BF6DE7E7FE63},Wireless Group Policy\r\r\n{0E28E245-9368-4853-AD84-6DA3BA35BB75},Group Policy Environment\r\r\n{169EBF44-942F-4C43-87CE-13C93996EBBE},UEV Policy\r\r\n{16BE69FA-4209-4250-88CB-716CF41954E0},Central Access Policy Configuration\r\r\n{2A8FDC61-2347-4C87-92F6-B05EB91A201A},MitigationOptions\r\r\n{2BFCC077-22D2-48DE-BDE1-2F618D9B476D},AppV Policy\r\r\n{4B7C3B0F-E993-4E06-A241-3FBE06943684},Per-process Mitigation Options\r\r\n{17D89FEC-5C44-4972-B12D-241CAEF74509},Group Policy Local Users and Groups\r\r\n{1A6364EB-776B-4120-ADE1-B63A406A76B5},Group Policy Device Settings\r\r\n{25537BA6-77A8-11D2-9B6C-0000F8080861},Folder Redirection\r\r\n{3610EDA5-77EF-11D2-8DC5-00C04FA31A66},Microsoft Disk Quota\r\r\n{3A0DBA37-F8B2-4356-83DE-3E90BD5C261F},Group Policy Network Options\r\r\n{426031C0-0B47-4852-B0CA-AC3D37BFCB39},QoS Packet Scheduler\r\r\n{42B5FAAE-6536-11D2-AE5A-0000F87571E3},Scripts\r\r\n{4BCD6CDE-777B-48B6-9804-43568E23545D},Remote Desktop USB Redirection\r\r\n{4CFB60C1-FAA6-47F1-89AA-0B18730C9FD3},Process Group Policy For Zone Map\r\r\n{4D968B55-CAC2-4FF5-983F-0A54603781A3},Work Folders\r\r\n{5794DAFD-BE60-433F-88A2-1A31939AC01F},Group Policy Drive Maps\r\r\n{6232C319-91AC-4931-9385-E70C2B099F0E},Group Policy Folders\r\r\n{6A4C88C6-C502-4F74-8F60-2CB23EDC24E2},Group Policy Network Shares\r\r\n{7150F9BF-48AD-4DA4-A49C-29EF4A8369BA},Group Policy Files\r\r\n{728EE579-943C-4519-9EF7-AB56765798ED},Group Policy Data Sources\r\r\n{74EE6C03-5363-4554-B161-627540339CAB},Group Policy Ini Files\r\r\n{7909AD9E-09EE-4247-BAB9-7029D5F0A278},MDM Policy\r\r\n{7933F41E-56F8-41D6-A31C-4148A711EE93},Windows Search Group Policy\r\r\n{7B849A69-220F-451E-B3FE-2CB811AF94AE},Internet Explorer User Accelerators\r\r\n{827D319E-6EAC-11D2-A4EA-00C04F79F83A},Security settings\r\r\n{8A28E2C5-8D06-49A4-A08C-632DAA493E17},Deployed Printer Connections\r\r\n{91FBB303-0CD5-4055-BF42-E512A681B325},Group Policy Services\r\r\n{A2E30F80-D7DE-11D2-BBDE-00C04F86AE3B},Internet Explorer Branding\r\r\n{A3F3E39B-5D83-4940-B954-28315B82F0A8},Group Policy Folder Options\r\r\n{AADCED64-746C-4633-A97C-D61349046527},Group Policy Scheduled Tasks\r\r\n{B087BE9D-ED37-454F-AF9C-04291E351182},Group Policy Registry\r\r\n{B1BE8D72-6EAC-11D2-A4EA-00C04F79F83A},EFS recovery\r\r\n{B587E2B1-4D59-4E7E-AED9-22B9DF11D053},802.3 Group Policy\r\r\n{BC75B1ED-5833-4858-9BB8-CBF0B166DF9D},Group Policy Printers\r\r\n{C34B2751-1CF4-44F5-9262-C3FC39666591},Windows To Go Hibernate Options\r\r\n{C418DD9D-0D14-4EFB-8FBF-CFE535C8FAC7},Group Policy Shortcuts\r\r\n{C631DF4C-088F-4156-B058-4375F0853CD8},Microsoft Offline Files\r\r\n{C6DC5466-785A-11D2-84D0-00C04FB169F7},Software Installation\r\r\n{CDEAFC3D-948D-49DD-AB12-E578BA4AF7AA},TCPIP settings\r\r\n{BA649533-0AAC-4E04-B9BC-4DBAE0325B12},Windows To Go Startup Options\r\r\n{CF7639F3-ABA2-41DB-97F2-81E2C5DBFC5D},Internet Explorer Machine Accelerators\r\r\n{CFF649BD-601D-4361-AD3D-0FC365DB4DB7},Delivery Optimization GP extension\r\r\n{D76B9641-3288-4F75-942D-087DE603E3EA},AdmPwd (LAPS)\r\r\n{E437BC1C-AA7D-11D2-A382-00C04F991E27},IP Security\r\r\n{E47248BA-94CC-49C4-BBB5-9EB7F05183D0},Group Policy Internet Settings\r\r\n{E4F48E54-F38D-4884-BFB9-D4D2E5729C18},Group Policy Start Menu Settings\r\r\n{E5094040-C46C-4115-B030-04FB2E545B00},Group Policy Regional Options\r\r\n{E62688F0-25FD-4C90-BFF5-F508B9D2E31F},Group Policy Power Options\r\r\n{F3CCC681-B74C-4060-9F26-CD84525DCA2A},Audit Policy Configuration\r\r\n{F9C77450-3A41-477E-9310-9ACD617BD9E3},Group Policy Applications\r\r\n{FB2CA36D-0B40-4307-821B-A13B252DE56C},Enterprise QoS\r\r\n{FBF687E6-F063-4D9F-9F4F-FD9A26ACDD5F},Connectivity Platform\r\r\n"
  },
  {
    "path": "SA-ADTimeline/lookups/ExchangeSchemaVersions",
    "content": "\"Exchange\",\"rangeUpper\"\r\n\r\n\"Exchange 2019 CU10-CU11 schema version\",\"17003\"\r\n\r\n\"Exchange 2019 CU8-CU9 schema version\",\"17002\"\r\n\r\n\"Exchange 2019 CU2-CU7 schema version\",\"17001\"\r\n\r\n\"Exchange 2019 RTM-CU1 schema version\",\"17000\"\r\n\r\n\"Exchange 2016 CU19-CU21 schema version\",\"15333\"\r\n\r\n\"Exchange 2016 CU7-CU18 schema version\",\"15332\"\r\n\r\n\"Exchange 2016 CU6 schema version\",\"15330\"\r\n\r\n\"Exchange 2016 CU3-CU5 schema version\",\"15326\"\r\n\r\n\"Exchange 2016 CU2 schema version\",\"15325\"\r\n\r\n\"Exchange 2016 CU1 schema version\",\"15323\"\r\n\r\n\"Exchange 2016 RTM schema version\",\"15317\"\r\n\r\n\"Exchange 2013 CU7-CU23\",\"15312\"\r\n\r\n\"Exchange 2013 CU6 schema version\",\"15303\"\r\n\r\n\"Exchange 2013 CU5 schema version\",\"15300\"\r\n\r\n\"Exchange 2013 SP1 schema version\",\"15292\"\r\n\r\n\"Exchange 2013 CU3 schema version\",\"15283\"\r\n\r\n\"Exchange 2013 CU2 schema version\",\"15281\"\r\n\r\n\"Exchange 2013 CU1 schema version\",\"15254\"\r\n\r\n\"Exchange 2013 RTM schema version\",\"15137\"\r\n\r\n\"Exchange 2010 SP3 schema version\",\"14734\"\r\n\r\n\"Exchange 2010 SP2 schema version\",\"14732\"\r\n\r\n\"Exchange 2010 SP1 schema version\",\"14726\"\r\n\r\n\"Exchange 2010 RTM schema version\",\"14622\"\r\n\r\n\"Exchange 2007 SP3 schema version\",\"14625\"\r\n\r\n\"Exchange 2007 SP2 schema version\",\"14622\"\r\n\r\n\"Exchange 2007 SP1 schema version\",\"11116\"\r\n\r\n\"Exchange 2007 RTM schema version\",\"10637\"\r\n\r\n\"Exchange 2003 schema version\",\"6870\"\r\n\r\n\"Exchange 2000 schema version\",\"4406\"\r\n\r\n\"Exchange 2000 RTM schema version\",\"4397\"\r\n\r\n"
  },
  {
    "path": "SA-ADTimeline/lookups/ObjectVersionSchema",
    "content": "ObjectVersion,SchemaVersion\r\r\n13,Windows 2000 Server\r\r\n30,Windows 2003 Server\r\r\n31,Windows 2003R2 Server\r\r\n44,Windows 2008 Server\r\r\n47,Windows 2008R2 Server\r\r\n56,Windows 2012 Server\r\r\n69,Windows 2012R2 Server\r\r\n87,Windows 2016 Server\r\r\n88,Windows 2019 Server"
  },
  {
    "path": "SA-ADTimeline/lookups/fsmoroleowner",
    "content": "ObjectClass,FSMORole\r\r\ncrossRefContainer,Domain Naming Master\r\r\ndMD,Schema Master\r\r\ndomainDNS,PDC Emulator\r\r\ninfrastructureUpdate,Infrastructure Master\r\r\nrIDManager,RID Manager"
  },
  {
    "path": "SA-ADTimeline/metadata/default.meta",
    "content": "\r\n# Application-level permissions\r\n[]\r\naccess = read : [ user ], write : [ admin, power, sc_admin ]\r\nexport = system\r\nowner = nobody\r\n"
  }
]