Harden Windows with Windows Defender Application Control (WDAC)
This is a PowerShell script that configures Windows Defender Application Control (WDAC) on a Windows machine. The script requires elevated privileges to run and continues even if errors are encountered. It creates a new “Temp” directory in the C:\ drive and copies necessary Windows Defender configuration files to it. The script then enables WDAC by importing policies and adding necessary services. The script also enables the Intelligent Security Graph (ISG) and Managed Installer (MI) diagnostic events for troubleshooting. The script ends with a prompt to the user to restart the computer to make changes effective.
WDAC_V1_Default_Audit.xml
WDAC_V1_Recommended_Audit.xml
WDAC_V1_Default_Enforced.xml
WDAC_V1_Recommended_Enforced.xml
WDAC_V1_Default_Audit.bin
WDAC_V1_Recommended_Audit.bin
WDAC_V1_Default_Enforced.bin
WDAC_V1_Recommended_Enforced.bin
WDAC_V1_Default_Audit\{uid}.cip
WDAC_V1_Recommended_Audit\{uid}.cip
WDAC_V1_Default_Enforced\{uid}.cip
WDAC_V1_Recommended_Enforced\{uid}.cip
Update the following line in the script to use the policy that you desire locally:
$PolicyPath = "C:\temp\Windows Defender\CIP\WDAC_V1_Recommended_Enforced\*.cip"
#https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/deployment/deploy-wdac-policies-with-script
ForEach ($Policy in (Get-ChildItem -Recurse $PolicyPath).Fullname) {
$PolicyBinary = "$Policy"
$DestinationFolder = $env:windir+"\System32\CodeIntegrity\CIPolicies\Active\"
$RefreshPolicyTool = "./Files/EXECUTABLES/RefreshPolicy(AMD64).exe"
Copy-Item -Path $PolicyBinary -Destination $DestinationFolder -Force
& $RefreshPolicyTool
}
Alternatively, you may use Group Policy or Microsoft Intune to enforce the WDAC policies.
You can view the WDAC event logs in event viewer under:
Applications and Services Logs\Microsoft\Windows\CodeIntegrity\Operational
If manually downloaded, the script must be launched from an administrative powershell in the directory containing all the files from the GitHub Repository
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
Get-ChildItem -Recurse *.ps1 | Unblock-File
.\sos-wdachardening.ps1