Forked from mattifestation/ExtractDriversFromAuditLogs.ps1
Created
January 22, 2019 18:41
-
-
Save sasqwatch/43289ecace12d3225ad6de05af3ad220 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Create a temp dir in which to copy the drivers to whitelist | |
mkdir ScanMe | |
Get-WinEvent -LogName 'Microsoft-Windows-CodeIntegrity/Operational' -FilterXPath '*[System[EventID=3076]]' | ForEach-Object { | |
$DriverPath = $_.Properties[1].Value | |
# Normalize the paths | |
switch -Wildcard ($DriverPath) { | |
'\Device\HarddiskVolume4\*' { $DriverPath = "C:\$($DriverPath.Replace('\Device\HarddiskVolume4\', ''))" } | |
'System32*' { $DriverPath = "C:\Windows\$DriverPath" } | |
} | |
# Copy each driver to the new directory. We'll build the new policy rules from the drivers in here. | |
Copy-Item -Path $DriverPath -Destination ScanMe | |
} | |
# Get the signer info for all the | |
$NewDrivers = Get-SystemDriver -ScanPath .\ScanMe\ -NoShadowCopy | |
# Build policy rules based on those drivers | |
$NewDriverRules = New-CIPolicyRule -DriverFiles $NewDrivers -Level WHQLFilePublisher -Fallback FilePublisher | |
# Merge the original blank policy with the new one. | |
Merge-CIPolicy -OutputFilePath WhitelistPolicyDevRound1.xml -PolicyPaths Default_Deny_All_Audit_Drivers.xml -Rules $NewDriverRules | |
ConvertFrom-CIPolicy -XmlFilePath WhitelistPolicyDevRound1.xml -BinaryFilePath C:\Windows\System32\CodeIntegrity\SIPolicy.p7b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment