Kurobeats

lazy admin killswitch

Jun 27th, 2017
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. $extensions = "", ".dat", ".dll"
  2. $baseFileName = "C:\windows\perfc"
  3.  
  4. foreach ($extension in $extensions)
  5. {
  6. $outFile = "{0}{1}" -f $baseFileName, $extension
  7.  
  8. Write-Host ("Creating file: {0}" -f $baseFileName)
  9. New-Item $outFile -ItemType file -Value "Road block for Petya." -Force
  10.  
  11. $ACL = Get-ACL $outFile
  12. $ACL.SetAccessRuleProtection($True, $False) # Remove inheritance.
  13. $ACL.Access | % { $acl.RemoveAccessRule($_) } # Remove explicit ACL's.
  14. $roRule = New-Object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Administrators", "Read", "Allow") # Administrators read-only.
  15. $ACL.AddAccessRule($roRule)
  16.  
  17. Write-Host "Applying read-only ACL..."
  18. Set-ACL $outFile $ACL | Out-Null
  19. }
Advertisement
Add Comment
Please, Sign In to add comment