- Hardening AppLocker - Thu, Jun 25 2020
- AppLocker Audit vs. Enforced mode - Tue, Jun 23 2020
- Creating AppLocker rules from the Windows event log - Wed, Jun 17 2020
On the Event Collector server, you can run the below command to see what you have in the log:
Get-AppLockerFileInformation -EventLog -LogPath ForwardedEvents |Out-GridView
It might make sense to start by adding the -statistics parameter to see what has been blocked the most so you know what to focus on.
If you already have log files archived, you need to point to the file instead of the log name.
Get-AppLockerFileInformation -EventLog -LogPath "C:\Users\AppAdmin\Documents\AppLocker4sysops.evtx" | Out-GridView
I like using the GridView for quick operations, but in the beginning it might be easier to dump the content to Excel and first work in there before deciding what to whitelist. You can do that by replacing Out-GridView with Export-CSV.
There are numerous ways to approach choosing the things to whitelist. Some want to dump everything to a local GPO, edit there, export to an XML file, and import to an AD GPO. Some want to choose one by one. I'm not going to go through every option. Instead, I'll point you to the ones I use the most. I prefer the latter option.
To dump everything to a local GPO, use the following:
Get-AppLockerFileInformation -EventLog -LogPath ForwardedEvents | New-AppLockerPolicy -RuleType Publisher -User Everyone -IgnoreMissingFileInformation -Optimize | Set-AppLockerPolicy
After this, you can open GPEDIT.msc and find the new rules to edit and export in your application control policies.
What I normally do is take a specific app and make a publisher rule for it, merging it straight to a GPO in Active Directory, like this:
Get-AppLockerFileInformation -EventLog -LogPath ForwardedEvents | where-object -Property Publisher -like "O=INTEL*" | New-AppLockerPolicy -RuleType Publisher | Set-AppLockerPolicy -LDAP "LDAP://DC01.elaiho.int/CN={CD0E20D6-3069-49C1-80A4-37A133974362},CN=Policies,CN=System,DC=elaiho,DC=int" -Merge
You need to get the LDAP path to the object and the GUID for the GPO. Normally, after this, I will edit the rule to point to the publishing company instead of the specific app. Please read my first blog post to find the reasoning for this.
After creating your rules, it's time to audit for a few more weeks and make sure you will find fewer entries in the logs.
As I stated in the previous blog post, my normal run for an AppLocker project is:
- Install event log forwarding and the required GPOs.
- Create basic rules for auditing.
- Log for 3–4 weeks.
- Create the first custom rule set based on the logged
- Log for 3–4 weeks.
- Tweak the rules based on the logged events.
- Teach ServiceDesk to deal with AppLocker and inform users.
- Configure about 25% of the clients to use enforced mode and create a PANIC policy.
- Run for 3–4 weeks.
- Configure the rest (75%) of the clients to use enforced mode.
- Harden AppLocker.
- Include DLLs in the project. First audit all and then enforce, like with other executables.
So now we should be at step 6. You'll basically redo everything you did in this post.
Now it's a good time to prepare a note for users about the introduction of whitelisting and how to contact You/ServiceDesk if they get into trouble. Also take some time to teach ServiceDesk how to create rules or how to escalate to the correct contact.
Subscribe to 4sysops newsletter!
In the next blog post, we will move from Audit mode to Enforced mode.
I am thinking something like
Get-AppLockerFileInformation -EventType Denied -EventLog | where-object -Property Publisher -ne $null| New-AppLockerPolicy -RuleType Publisher | Set-AppLockerPolicy -LDAP "LDAP://xx.xxx.com/CN={gpoguid},CN=Policies,CN=System,DC=xx,DC=xxx,DC=com" -Merge
I havent tested, but could help in applocker maintenance, not having to catch temp folders and temp files from installation say.
Perhps even launch with invoke-command as a script block, or psexec powershell shell