Created
June 28, 2017 07:28
-
-
Save andreafortuna/058011001874c9c19df6fda26a3ccf1f to your computer and use it in GitHub Desktop.
Local vaccine for #Petya / #NotPetya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$extensions = "", ".dat", ".dll" | |
$baseFileName = "C:\windows\perfc" | |
foreach ($extension in $extensions) | |
{ | |
$outFile = "{0}{1}" -f $baseFileName, $extension | |
Write-Host ("Creating file: {0}" -f $baseFileName) | |
New-Item $outFile -ItemType file -Value "Road block for Petya." -Force | |
$ACL = Get-ACL $outFile | |
$ACL.SetAccessRuleProtection($True, $False) # Remove inheritance. | |
$ACL.Access | % { $acl.RemoveAccessRule($_) } # Remove explicit ACL's. | |
$roRule = New-Object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Administrators", "Read", "Allow") # Administrators read-only. | |
$ACL.AddAccessRule($roRule) | |
Write-Host "Applying read-only ACL..." | |
Set-ACL $outFile $ACL | Out-Null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment