OK. I've found the issues and wanted to put this here in case someone finds this in the future and wants to block powershell using an expert rule.
I ended up creating two expert rules. One is 'file' rule-type and the other is 'process'.
The file one looks like this:
Rule {
Process {
Include OBJECT_NAME { -v powershell.exe }
Include OBJECT_NAME { -v powershell_ise.exe }
Include OBJECT_NAME { -v pwsh.exe }
# exclude admin groups
Exclude AggregateMatch {
Include GROUP_SID { -v "S-1-16-12288" }
Include GROUP_SID { -v "S-1-16-16384" }
}
}
Target {
Match FILE {
Include -access "EXECUTE"
Include -access "READ"
}
}
}
The process one:
Rule {
Process {
Include OBJECT_NAME { -v powershell.exe }
Include OBJECT_NAME { -v powershell_ise.exe }
Include OBJECT_NAME { -v pwsh.exe }
# exclude admin groups
Exclude AggregateMatch {
Include GROUP_SID { -v "S-1-16-12288" }
Include GROUP_SID { -v "S-1-16-16384" }
Include GROUP_SID { -v "S-1-5-21-1150564198-587945205-751859383-123771" }
Include GROUP_SID { -v "S-1-5-21-1150564198-587945205-751859383-318856" }
}
}
Target {
Match PROCESS {
Include -access CREATE
Include -access DELETE
Include -access WRITE
}
}
}
Between these two rules, we're now able to prevent powershell, powershell_ise as well as command prompt PS shell.
I'm still trying to figure out how I can prevent it from being copy/pasted/renamed, tho.
Hi there,
Since you want certain users to be able to do it and the rest no, the easier way is to use the access protection in ENS.
I am using it like this:
Step1) Create a rule and include any file (*).
Step2) Add user name for exclusion later.
Step3) Create a subrule for the type "Processes"
Step4-1) Add as name or hash file for the Powershell engines (This is a subrule inside step3)
Step4-2) Add the data name which is .ps1 (This is a subrule inside step3)
Take look at the attached screen shots
Rule {
Target {
Match PROCESS {
Include OBJECT_NAME {
-v "powershell.exe"
-v "powershell_ise.exe"
-v "pwsh.exe"
}
Include -access "CREATE"
}}}
New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.
Thousands of customers use our Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership: