CmdID

CmdID / Rules / Windows

PowerShell Script Change Permission Via Set-Acl

A Sigma rule for process creation on Windows, by Nasreddine Bencherchali (Nextron Systems).

high 2 programs it names 5 everyday examples trip it

What it looks for

its detection, as SigmaHQ writes it
detection:
  selection_cmdlet:
    CommandLine|contains|all:
      - 'Set-Acl '
      - '-AclObject '
      - '-Path '
  selection_img:
    - OriginalFileName:
        - 'PowerShell.EXE'
        - 'pwsh.dll'
    - Image|endswith:
        - '\powershell.exe'
        - '\pwsh.exe'
  condition: all of selection_*

The rule’s detection, its selections and fields in order of name. The whole rule, with its references and false positives, is on SigmaHQ, by Nasreddine Bencherchali (Nextron Systems), under the Detection Rule License 1.1. CmdID evaluates it on a command line alone: a test on what a command line cannot show, such as the parent process or the user, is not met.

Command lines that trip it

everyday examples from tldr-pages, CC BY 4.0, each read by CmdID

Copy a security descriptor from one file to another on the page for set-acl

$OriginAcl = Get-Acl -Path path\to\file; Set-Acl -Path path\to\file -AclObject $OriginAclIdentify

Copy a security descriptor from one file to another on the page for Set-Acl

$DogACL = Get-Acl -Path "C:\Dog.txt" Set-Acl -Path "C:\Cat.txt" -AclObject $DogACLIdentify

Apply a security descriptor to multiple files on the page for Set-Acl

$NewAcl = Get-Acl File0.txt Get-ChildItem -Path "C:\temp" -Recurse -Include "*.txt" -Force | Set-Acl -AclObject $NewAclIdentify

Disable inheritance and preserve inherited access rules on the page for Set-Acl

$NewAcl = Get-Acl -Path "C:\Pets\Dog.txt" $isProtected = $true $preserveInheritance = $true $NewAcl.SetAccessRuleProtection($isProtected, $preserveInheritance) Set-Acl -Path "C:\Pets\Dog.txt" -AclObject $NewAclIdentify

Grant Administrators Full Control of the file on the page for Set-Acl

$NewAcl = Get-Acl -Path "C:\Pets\Dog.txt" # Set properties $identity = "BUILTIN\Administrators" $fileSystemRights = "FullControl" $type = "Allow" # Create new rule $fileSystemAccessRuleArgumentList = $identity, $fileSystemRights, $type $newParams = @{ TypeName = 'System.Security.AccessControl.FileSystemAccessRule' ArgumentList = $fileSystemAccessRuleArgumentList } $fileSystemAccessRule = New-Object @newParams # Apply new rule $NewAcl.SetAccessRule($fileSystemAccessRule) Set-Acl -Path "C:\Pets\Dog.txt" -AclObject $NewAclIdentify

Programs and files it names

their pages here