Skip to content

Instantly share code, notes, and snippets.

@jymcheong
Last active October 25, 2017 06:37
Show Gist options
  • Save jymcheong/8f1db345bca81d70f9a9b1f578bb0723 to your computer and use it in GitHub Desktop.
Save jymcheong/8f1db345bca81d70f9a9b1f578bb0723 to your computer and use it in GitHub Desktop.
$files = @("cscc.dat", "infpub.dat")
$files | foreach {
write-host $env:windir\$_
echo "" > $env:windir\$_
$acl = Get-Acl $env:windir\$_
$acl.SetAccessRuleProtection($true,$true) # removes inheritence
$acl | Set-Acl
$acl = Get-Acl $env:windir\$_
$acl.Access | %{$acl.RemoveAccessRule($_)} # removes rules
$acl | Set-Acl
}
@jymcheong
Copy link
Author

Run Powershell ISE as admin, paste the code in, click RUN.

@jymcheong
Copy link
Author

Tested on Win7 & 10. Latter will have some error but the 2 files are created and have equivalent effect as the GUI way as shared by Cybereason. Doing so effectively blocks the main DLL from writing to disk.

@jymcheong
Copy link
Author

For larger fleet, sys-admin may want to automate the execution upon logon or something equivalent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment